Skip to content
Snippets Groups Projects
Commit 43e343a6 authored by jlaura's avatar jlaura Committed by GitHub
Browse files

Fixes failing tests (#113)

* Fixes failing tests

* removes python 3.5 support

* Skips conda upload if a PR
parent 3a2219eb
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,10 @@ os:
- osx
env:
- PYTHON_VERSION=3.5 HAS_GDAL=true
- PYTHON_VERSION=3.6 HAS_GDAL=true
- PYTHON_VERSION=3.5 HAS_GDAL=false
- PYTHON_VERSION=3.6 HAS_GDAL=false
- PYTHON_VERSION=3.7 HAS_GDAL=true
- PYTHON_VERSION=3.7 HAS_GDAL=false
before_install:
# We do this conditionally because it saves us some downloading if the
# version is the same.
......@@ -56,7 +55,10 @@ after_success:
- conda config --set anaconda_upload no
- conda build recipe -q
- builddir=(`conda build recipe --output`)
- anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir --label dev --force;
- |
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
anaconda -t="$CONDA_UPLOAD_TOKEN" upload $builddir --force;
fi
# Docs to gh-pages
- source activate test # Reactivate the env to have all deps installed.
......
......@@ -3,8 +3,8 @@ channels:
- conda-forge
- usgs-astrogeology
dependencies:
- libgdal
- gdal
- libgdal < 3
- gdal < 3
- numpy
- pyproj
- h5py
......@@ -22,4 +22,4 @@ dependencies:
- pytest-cov
- sh
- coveralls
- nbsphinx
\ No newline at end of file
- nbsphinx
......@@ -191,6 +191,7 @@ class GeoDataset(object):
@property
def forward_affine(self):
print(self.geotransform)
self._fa = affine.Affine.from_gdal(*self.geotransform)
return self._fa
......@@ -460,6 +461,7 @@ class GeoDataset(object):
(Latitude, Longitude) corresponding to the given (x,y).
"""
lon, lat = self.forward_affine * (x,y)
lon, lat, _ = self.coordinate_transformation.TransformPoint(lon, lat)
return lat, lon
......
......@@ -17,7 +17,7 @@ def read_yaml(inputfile):
"""
try:
with open(inputfile, 'r') as f:
ydict = yaml.load(f)
ydict = yaml.safe_load(f)
except: # pragma: no cover
raise IOError('Unable to load YAML file.')
return ydict
......@@ -62,7 +62,9 @@ class TestMercator(unittest.TestCase):
def test_spheroid(self):
sphere = self.dataset.spheroid
self.assertAlmostEqual(sphere[0], 3396190.0, 6)
self.assertEqual(self.dataset.spheroid, (3396190.0, 3376200.0, 169.8944472236118))
self.assertAlmostEqual(self.dataset.spheroid[0], 3396190.0)
self.assertAlmostEqual(self.dataset.spheroid[1], 3376200.0)
self.assertAlmostEqual(self.dataset.spheroid[2], 169.8944472236118)
self.assertAlmostEqual(sphere[1], 3376200.0, 6)
self.assertAlmostEqual(sphere[2], 169.8944472236118, 6)
......@@ -225,17 +227,17 @@ class TestWriter(unittest.TestCase):
UNIT["Meter",1.0]]"""
io_gdal.array_to_raster(self.arr, 'test.tif', projection=wktsrs)
expected_srs = """PROJCS["Moon2000_Mercator180",
GEOGCS["GCS_Moon_2000",
DATUM["Moon_2000",
SPHEROID["Moon_2000_IAU_IAG",1737400,0]],
PRIMEM["Reference_Meridian",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mercator_2SP"],
PARAMETER["central_meridian",180],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
PARAMETER["standard_parallel_1",0],
UNIT["Meter",1]]"""
GEOGCS["GCS_Moon_2000",
DATUM["Moon_2000",
SPHEROID["Moon_2000_IAU_IAG",1737400,0]],
PRIMEM["Reference_Meridian",0],
UNIT["Degree",0.017453292519943295]],
PROJECTION["Mercator_2SP"],
PARAMETER["central_meridian",180],
PARAMETER["false_easting",0],
PARAMETER["false_northing",0],
PARAMETER["standard_parallel_1",0],
UNIT["Meter",1]]"""
dataset = io_gdal.GeoDataset('test.tif')
test_srs = dataset.spatial_reference.__str__()
self.assertEqual(test_srs.split(), expected_srs.split())
......
......@@ -52,7 +52,8 @@ def test_export_to_proj4(srs_mars):
Check that proj4 is not supporting Moon2000_Mercator
"""
proj4 = srs_mars.ExportToProj4()
assert proj4 == '+proj=merc +lon_0=180 +lat_ts=0 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs '
for element in '+proj=merc +lon_0=180 +lat_ts=0 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs'.split():
assert element in proj4
@pytest.mark.skipif(gdal is None, reason="GDAL not installed")
def test_scale_factor(srs_mars):
......
......@@ -32,7 +32,7 @@ def setup_logging(path=get_path('logging.json'),
config = json.load(f)
elif logtype == '.yaml':
import yaml
config = yaml.load(f.read())
config = yaml.safe_load(f.read())
logging.config.dictConfig(config)
else:
logging.basicConfig(level=level)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment