diff --git a/.travis.yml b/.travis.yml index 96bf55c9eb009db242168a4ce72fee8d46a75670..6f5b18e4c093df6f27de45ea9aa1dfce3344cb54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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. diff --git a/environment.yml b/environment.yml index 653b3078295a64f73cef95a3d0f40da48683254b..908f0616db23410b855a1976b11505f3d1229907 100644 --- a/environment.yml +++ b/environment.yml @@ -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 diff --git a/plio/io/io_gdal.py b/plio/io/io_gdal.py index 9573c0fc6b5c871a3a84644d8ac01aa2747b94c2..5fa66a57824272b6082d2290de7a3c7856fa562c 100644 --- a/plio/io/io_gdal.py +++ b/plio/io/io_gdal.py @@ -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 diff --git a/plio/io/io_yaml.py b/plio/io/io_yaml.py index 59d1a70d9d24fc43f8a68b658826b27a81c069fb..a3c800126b1a6290f5061e5028bf053ce06c57e6 100644 --- a/plio/io/io_yaml.py +++ b/plio/io/io_yaml.py @@ -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 diff --git a/plio/io/tests/test_io_gdal.py b/plio/io/tests/test_io_gdal.py index 5bb1991e421196761cabc7ce78e18bc00255001d..0423ca3f74d26d502c12162755f521eef5496200 100644 --- a/plio/io/tests/test_io_gdal.py +++ b/plio/io/tests/test_io_gdal.py @@ -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()) diff --git a/plio/io/tests/test_metadata.py b/plio/io/tests/test_metadata.py index df63a0096f2d086f8c05cef5cd340f574576aee5..6eef483cd94b475aeb771033fd3c316731b4aa67 100644 --- a/plio/io/tests/test_metadata.py +++ b/plio/io/tests/test_metadata.py @@ -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): diff --git a/plio/utils/log.py b/plio/utils/log.py index b578eae374a314e6c2a1f19e96e5db2dfa2cc95a..162d01043e7fd84442cb4b45c49338390b5a4b26 100644 --- a/plio/utils/log.py +++ b/plio/utils/log.py @@ -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)