diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 43a06cf..c2a2ca4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] os: [ubuntu-latest] fail-fast: false diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d12f6d8..4846901 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-ast - id: end-of-file-fixer @@ -23,23 +23,23 @@ repos: # args: [--config=pyproject.toml] - repo: https://github.com/keewis/blackdoc - rev: v0.3.8 + rev: v0.3.9 hooks: - id: blackdoc - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.287 + rev: v0.3.5 hooks: - id: ruff - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 24.3.0 hooks: - id: black language_version: python3 - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: @@ -51,6 +51,6 @@ repos: - id: add-trailing-comma - repo: https://github.com/tox-dev/pyproject-fmt - rev: "1.1.0" + rev: "1.7.0" hooks: - id: pyproject-fmt diff --git a/oceans/datasets.py b/oceans/datasets.py index c856eb6..815d63b 100644 --- a/oceans/datasets.py +++ b/oceans/datasets.py @@ -2,6 +2,7 @@ import warnings import numpy as np +import pooch from netCDF4 import Dataset from oceans.ocfis import get_profile, wrap_lon180 @@ -227,6 +228,16 @@ def woa_subset( return ds[[f"{v}_mn"]] # always return a dataset +def _download_etopo2(): + url = "https://github.com/pyoceans/python-oceans/releases/download" + version = "v2024.04" + + return pooch.retrieve( + url=f"{url}/{version}/ETOPO2v2c_f4.nc", + known_hash="sha256:30159a3f15a06398db3cae4ec75986bedc3317dda8e89d049ddc92ba1c352ff1", + ) + + @functools.lru_cache(maxsize=256) def etopo_subset(min_lon, max_lon, min_lat, max_lat, tfile=None, smoo=False): """ @@ -245,7 +256,7 @@ def etopo_subset(min_lon, max_lon, min_lat, max_lat, tfile=None, smoo=False): Based on trondkristiansen contourICEMaps.py """ if tfile is None: - tfile = "https://gamone.whoi.edu/thredds/dodsC/usgs/data0/bathy/ETOPO2v2c_f4.nc" + tfile = _download_etopo2() with Dataset(tfile, "r") as etopo: lons = etopo.variables["x"][:] @@ -276,7 +287,7 @@ def get_depth(lon, lat, tfile=None): >>> station_lon = [-40, -32] >>> station_lat = [-20, -20] >>> get_depth(station_lon, station_lat) - array([ -32.98816423, -4275.63374601]) + array([ -32.988163, -4275.634 ], dtype=float32) """ lon, lat = list(map(np.atleast_1d, (lon, lat))) diff --git a/oceans/filters.py b/oceans/filters.py index ffb376a..67dc971 100644 --- a/oceans/filters.py +++ b/oceans/filters.py @@ -415,7 +415,10 @@ def medfilt1(x, L=3): >>> L = 103 >>> xout = medfilt1(x=x, L=L) >>> ax = plt.subplot(212) - >>> (l1, l2,) = ax.plot( + >>> ( + ... l1, + ... l2, + ... ) = ax.plot( ... x ... ), ax.plot(xout) >>> ax.grid(True) @@ -608,7 +611,7 @@ def pl33tn(x, dt=1.0, T=33.0, mode="valid", t=None): import pandas as pd import xarray as xr - if isinstance(x, (xr.Dataset, pd.DataFrame)): + if isinstance(x, xr.Dataset | pd.DataFrame): raise TypeError("Input a DataArray not a Dataset, or a Series not a DataFrame.") if isinstance(x, pd.Series) and not isinstance( diff --git a/oceans/sw_extras/sw_extras.py b/oceans/sw_extras/sw_extras.py index 106dd6f..e25c1d3 100644 --- a/oceans/sw_extras/sw_extras.py +++ b/oceans/sw_extras/sw_extras.py @@ -168,7 +168,7 @@ def cph(bvfr2): Returns ------- cph : array_like - Brünt-Väisälä Frequency [ cylcles hour :sup:`-1`] + Brünt-Väisälä Frequency [ cycles hour :sup:`-1`] Examples -------- diff --git a/pyproject.toml b/pyproject.toml index d1b7ce5..a11fc8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,13 +16,12 @@ maintainers = [ {name = "Arnaldo Russo"}, {name = "Filipe Fernandes", email = "ocefpaf+oceans@gmail.com"}, ] -requires-python = ">=3.8" +requires-python = ">=3.10" classifiers = [ "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dynamic = [ "dependencies", @@ -57,7 +56,7 @@ write_to = "oceans/_version.py" write_to_template = "__version__ = '{version}'" [tool.ruff] -select = [ +lint.select = [ "A", # flake8-builtins "B", # flake8-bugbear "C4", # flake8-comprehensions @@ -68,14 +67,25 @@ select = [ ] target-version = "py311" line-length = 79 -ignore = [ +lint.ignore = [ "B905", # zip ztrict arg, enable only for py310 ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "docs/source/conf.py" = ["E402", "A001"] "oceans/plotting.py" = ["T201"] # `print` found +[tool.check-manifest] +ignore = [ + ".coveragerc", + "docs", + "docs/*", + "notebooks", + "notebooks/*", + "tests", + "tests/*", +] + [tool.pytest.ini_options] markers = [ "web: marks tests require connection (deselect with '-m \"not web\"')" @@ -93,14 +103,3 @@ exclude = ["docs", "tests"] verbose = 1 quiet = false color = true - -[tool.check-manifest] -ignore = [ - ".coveragerc", - "docs", - "docs/*", - "notebooks", - "notebooks/*", - "tests", - "tests/*", -] diff --git a/requirements-dev.txt b/requirements-dev.txt index baf312e..0063134 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,10 +1,10 @@ -black cartopy cf_xarray check-manifest nbsphinx netcdf4 pandas +pooch pytest pytest-cov pytest-xdist