diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml index 58f3aad..3492be9 100644 --- a/.github/workflows/cibuildwheel.yml +++ b/.github/workflows/cibuildwheel.yml @@ -42,7 +42,7 @@ jobs: CIBW_BUILD_FRONTEND: build CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_TEST_SKIP: "*_arm64" - CIBW_TEST_REQUIRES: pytest + CIBW_TEST_REQUIRES: pytest pandas>=2 CIBW_TEST_COMMAND: > python -c "import gsw; print(f'gsw v{gsw.__version__}')" && python -m pytest --pyargs gsw diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e1dc55..d66864e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,13 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-ast - id: debug-statements - id: check-added-large-files - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell exclude: > @@ -17,3 +17,25 @@ repos: )$ args: - --ignore-words-list=nin,preformed,wih, + +- repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.9.2 + hooks: + - id: pyproject-fmt + + +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.260 + hooks: + - id: ruff + +ci: + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit.com hooks + + for more information, see https://pre-commit.ci + autofix_prs: false + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: monthly + skip: [] + submodules: false diff --git a/MANIFEST.in b/MANIFEST.in index 26612e3..4fa7475 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,9 +4,9 @@ include README.md graft gsw recursive-include src *.c recursive-include src *.h -include src/c_gsw/LICENSE prune docs +prune .github prune tools prune notebooks prune *.egg-info diff --git a/gsw/tests/test_xarray.py b/gsw/tests/test_xarray.py index e424dd4..0d95550 100644 --- a/gsw/tests/test_xarray.py +++ b/gsw/tests/test_xarray.py @@ -14,6 +14,9 @@ import numpy as np from numpy.testing import assert_allclose +import pandas as pd + + import gsw from gsw._utilities import Bunch from check_functions import parse_check_functions @@ -141,3 +144,13 @@ def test_xarray_with_coords(): chunked = gsw.z_from_p(p,lat_chunk) assert_allclose(xarray, expected) assert_allclose(chunked, expected) + +def test_pandas_20(): + df = pd.DataFrame( + { + "pressure": [0, 10, 20], + "latitude": [70, 70, 70], + } + ) + depth = -1 * gsw.z_from_p(df["pressure"], df["latitude"]) + assert isinstance(depth, pd.core.series.Series) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5bc1231..a19aae0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,99 @@ [build-system] -requires = ["pip>9.0.1", "setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4", "oldest-supported-numpy", "build"] build-backend = "setuptools.build_meta" +requires = [ + "build", + "oldest-supported-numpy", + "pip>9.0.1", + "setuptools>=42", + "setuptools_scm[toml]>=3.4", + "wheel", +] + +[project] +name = "gsw" +description = "Gibbs Seawater Oceanographic Package of TEOS-10" +license = {text = "BSD-3-Clause"} +authors = [ + {name = "Eric Firing, Filipe Fernandes", email = "efiring@hawaii.edu"}, +] +requires-python = ">=3.8" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering", +] +dynamic = [ + "readme", + "version", +] +dependencies = [ + "numpy>=1.21", +] +[project.urls] +documentation = "https://teos-10.github.io/GSW-Python/" +homepage = "https://www.teos-10.org/" +repository = "https://github.com/TEOS-10/GSW-python" + +[tool.setuptools] +license-files = ["LICENSE.txt"] +zip-safe = false +include-package-data = true +packages = ["gsw", "gsw.tests"] + + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +readme = {file = "README.md", content-type = "text/markdown"} + +[tool.setuptools_scm] +write_to = "gsw/_version.py" +write_to_template = "__version__ = '{version}'" +tag_regex = "^(?Pv)?(?P[^\\+]+)(?P.*)?$" + +[tool.check-manifest] +ignore = [ + "*.yml", + ".coveragerc", + "docs", + "docs/*", + "*.enc", + "tools", + "tools/*", + "gsw/_version.py", +] + +[tool.ruff] +select = [ + "A", # flake8-builtins + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "F", # flakes + "I", # import sorting + # "T20", # flake8-print + "UP", # upgrade +] +target-version = "py38" +line-length = 105 + +ignore = [ + "F401", + "E501", + "E713", +] + +exclude = [ + "tools", +] + +[tool.ruff.per-file-ignores] +"docs/source/conf.py" = [ + "A001", +] diff --git a/requirements-dev.txt b/requirements-dev.txt index 7ba2df0..6876fea 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -7,4 +7,5 @@ sphinx sphinx_rtd_theme twine xarray +pandas>=2 dask diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7ce214b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,47 +0,0 @@ -[metadata] -name = gsw -description = Gibbs Seawater Oceanographic Package of TEOS-10 -author = Eric Firing, Filipe Fernandes -author_email = efiring@hawaii.edu -url = https://github.com/TEOS-10/GSW-python -long_description = file: README.md -long_description_content_type = text/markdown -license = BSD -license_file = LICENSE.txt -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Science/Research - Operating System :: OS Independent - License :: OSI Approved :: BSD License - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Topic :: Scientific/Engineering - - -[options] -zip_safe = False -install_requires = - numpy -python_requires = >=3.8 -packages = find: -include_package_data = True - -[check-manifest] -ignore = - *.yml - .coveragerc - docs - docs/* - *.enc - tools - tools/* - gsw/_version.py - -[flake8] -max-line-length = 105 -select = C,E,F,W,B,B950 -ignore = E203, E501, W503, E713 diff --git a/setup.py b/setup.py index 2d05343..a94b43d 100644 --- a/setup.py +++ b/setup.py @@ -50,14 +50,6 @@ def build_extensions(self): ] config = { - # The package metadata is specified in setup.cfg but GitHub's downstream dependency graph - # does not work unless we put the name this here too. - "name": "gsw", - "use_scm_version": { - "write_to": "gsw/_version.py", - "write_to_template": '__version__ = "{version}"', - "tag_regex": r"^(?Pv)?(?P[^\+]+)(?P.*)?$", - }, "ext_modules": [Extension("gsw._gsw_ufuncs", ufunc_src_list)], "include_dirs": [os.path.join(rootpath, "src", "c_gsw")], "cmdclass": {"build_ext": build_ext},