Skip to content

Commit

Permalink
Python 3.8 compatibility (#194)
Browse files Browse the repository at this point in the history
* Python 3.8 compatibility

* files for Travis CI

* Added py27 compatibility

Co-authored-by: Uchida Takaya <[email protected]>
  • Loading branch information
Takaya Uchida and Uchida Takaya committed Mar 6, 2020
1 parent 0f505f7 commit 1fb9cc2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ matrix:
env: CONDA_ENV=py36
- python: 3.6
env: CONDA_ENV=py36-xarraymaster
- python: 3.7
env: CONDA_ENV=py37
- python: 3.8
env: CONDA_ENV=py38

before_install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
Expand Down
17 changes: 17 additions & 0 deletions ci/environment-py37.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.7
- xarray
- dask
- numpy
- pytest
- future
- zarr
- cftime
- pip:
- cachetools
- fsspec
- codecov
- pytest-cov
17 changes: 17 additions & 0 deletions ci/environment-py38.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: test_env
channels:
- conda-forge
dependencies:
- python=3.8
- xarray
- dask
- numpy
- pytest
- future
- zarr
- cftime
- pip:
- cachetools
- fsspec
- codecov
- pytest-cov
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
'Intended Audience :: Science/Research',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Topic :: Scientific/Engineering',
]

INSTALL_REQUIRES = ['xarray >= 0.10.1', 'dask >= 0.12', 'cachetools']
INSTALL_REQUIRES = ['xarray >= 0.10.1', 'dask >= 1.0', 'cachetools']
SETUP_REQUIRES = ['pytest-runner']
TESTS_REQUIRE = ['pytest >= 2.8', 'coverage']
TESTS_REQUIRE = ['pytest >= 4.0', 'coverage']

DESCRIPTION = "Read MITgcm mds binary files into xarray"
def readme():
Expand Down
12 changes: 9 additions & 3 deletions xmitgcm/mds_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ def open_mdsdataset(data_dir, grid_dir=None,
for coord in ['k', 'k_l', 'k_u', 'k_p1']})
datasets.insert(0, grid_dataset)
# apply chunking
ds = xr.auto_combine(datasets)
if sys.version_info[0] < 3:
ds = xr.auto_combine(datasets)
else:
ds = xr.combine_by_coords(datasets)
if swap_dims:
ds = _swap_dimensions(ds, geometry)
if grid_vars_to_coords:
Expand Down Expand Up @@ -311,9 +314,12 @@ def _swap_dimensions(ds, geometry, drop_old=True):
for orig_dim in ds.dims:
if 'swap_dim' in ds[orig_dim].attrs:
new_dim = ds[orig_dim].attrs['swap_dim']
ds = ds.swap_dims({orig_dim: new_dim})
ds = ds.swap_dims({orig_dim: new_dim})
if drop_old:
ds = ds.drop(orig_dim)
if sys.version_info[0] < 3:
ds = ds.drop(orig_dim)
else:
ds = ds.drop_vars(orig_dim)
return ds


Expand Down

0 comments on commit 1fb9cc2

Please sign in to comment.