Skip to content

Commit a6df06f

Browse files
authored
Merge pull request #71 from DocOtak/rcaneill_add_citation2
add citation, update readthedoc config, add 3.12 in CI
2 parents 475bd8b + dfd6fb6 commit a6df06f

32 files changed

+1554
-1546
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,19 @@ on:
1010
branches: [ master ]
1111

1212
jobs:
13-
style:
14-
name: Code linting checks
15-
runs-on: ubuntu-latest
16-
steps:
17-
- uses: actions/checkout@v3
18-
- uses: psf/black@stable
19-
with:
20-
options: "--check --verbose"
21-
version: "22.3.0"
22-
2313
build:
2414
name: build (${{ matrix.os }}, ${{ matrix.python-version }})
2515
runs-on: ${{ matrix.os }}
2616
strategy:
2717
fail-fast: false
2818
matrix:
2919
os: ["ubuntu-latest", "macos-latest"]
30-
python-version: ["3.8", "3.9", "3.10", "3.11"]
20+
python-version: ["3.9", "3.10", "3.11", "3.12"]
3121

3222
steps:
33-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
3424
- name: Set up Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v4
25+
uses: actions/setup-python@v5
3626
with:
3727
python-version: ${{ matrix.python-version }}
3828
- name: Install / build
@@ -41,34 +31,51 @@ jobs:
4131
pip install .
4232
4333
test:
44-
name: test (${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint)
45-
runs-on: ${{ matrix.os }}
34+
name: test (ubuntu-latest, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint, packages version ${{ matrix.version }})
35+
runs-on: "ubuntu-latest"
36+
env:
37+
poetry_version: 1.3.2
4638
strategy:
4739
fail-fast: false
4840
matrix:
49-
os: ["ubuntu-latest"]
50-
python-version: ["3.8", "3.9", "3.10", "3.11"]
51-
poetry-version: [1.3.2]
41+
python-version: ["3.9", "3.10", "3.11", "3.12"]
5242
pint: ["with", "without"]
43+
version: ["lock"]
44+
include:
45+
- python-version: "3.9"
46+
version: "minimal"
47+
pint: "with"
48+
- python-version: "3.12"
49+
version: "maximal"
50+
pint: "with"
5351
steps:
54-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v4
5553
- name: Install poetry
56-
run: pipx install poetry==${{ matrix.poetry-version }}
54+
run: pipx install poetry==${{ env.poetry_version }}
5755
- name: Set up Python ${{ matrix.python-version }}
58-
uses: actions/setup-python@v4
56+
uses: actions/setup-python@v5
5957
with:
6058
python-version: ${{ matrix.python-version }}
6159
cache: 'poetry'
6260
- name: Install udunits
6361
run: sudo apt-get install -y libudunits2-dev
62+
- name: update lock file
63+
if: matrix.version == 'maximal'
64+
run: poetry update
6465
- name: Install dependencies
6566
run: |
66-
poetry install
67+
poetry install --with dev
6768
poetry run pip install cf_units==3.0.1
6869
- if: matrix.pint == 'with'
6970
name: Install pint and pint-xarray
7071
run: |
7172
poetry install -E pint
73+
- name: use minimal versions for lock file
74+
if: matrix.version == 'minimal'
75+
run: |
76+
pipx install pdm==2.15.2
77+
poetry run pdm lock --strategy direct_minimal_versions -v -G :all
78+
poetry run pdm install -v -G :all
7279
- name: Test with pytest
7380
run: |
7481
poetry run pytest gsw_xarray/tests

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jobs:
88
build:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212
- name: Build and publish to pypi
1313
uses: JRubics/[email protected]
1414
with:
15-
pypi_token: ${{ secrets.PYPI_TOKEN }}
15+
pypi_token: ${{ secrets.PYPI_TOKEN }}

.github/workflows/ruff.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: format and lint
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Install Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: "3.11"
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install ruff
22+
# Update output format to enable automatic inline annotations.
23+
- name: Run Ruff
24+
run: ruff check --output-format=github .
25+
- name: Run Ruff format
26+
run: ruff format --check .

.gitignore

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# ruff
2+
.ruff_cache
3+
14
# These files are generated on doc build and shoudl not be kept in VC
25
docs/_attr_table.rst
36
docs/ARGO_example.nc
@@ -65,16 +68,6 @@ cover/
6568
*.mo
6669
*.pot
6770

68-
# Django stuff:
69-
*.log
70-
local_settings.py
71-
db.sqlite3
72-
db.sqlite3-journal
73-
74-
# Flask stuff:
75-
instance/
76-
.webassets-cache
77-
7871
# Scrapy stuff:
7972
.scrapy
8073

@@ -92,18 +85,6 @@ target/
9285
profile_default/
9386
ipython_config.py
9487

95-
# pyenv
96-
# For a library or package, you might want to ignore these files since the code is
97-
# intended to run in multiple environments; otherwise, check them in:
98-
# .python-version
99-
100-
# pipenv
101-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
102-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
103-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
104-
# install all needed dependencies.
105-
#Pipfile.lock
106-
10788
# poetry
10889
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
10990
# This is especially recommended for binary packages to ensure reproducibility, and is more

.pre-commit-config.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/psf/black
5-
rev: 22.3.0
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.4.5
66
hooks:
7-
- id: black
8-
language_version: python3
7+
- id: ruff
8+
name: lint with ruff
9+
- id: ruff
10+
name: sort imports with ruff
11+
args: [--select, I, --fix]
12+
- id: ruff-format
13+
name: format with ruff

.readthedocs.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ build:
1313
# Install poetry
1414
# https://python-poetry.org/docs/#installing-manually
1515
- pip install poetry
16-
# Tell poetry to not use a virtual environment
17-
- poetry config virtualenvs.create false
1816
post_install:
1917
# Install dependencies with 'docs' extra
20-
- poetry install -E docs
18+
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
2119

2220
sphinx:
2321
configuration: docs/conf.py

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
v0.4.0 - not released
5+
---------------------
6+
This release adds an accessor for xarray. Support for python 3.8 is dropped and 3.12 is added.
7+
48
v0.3.0 - 2022-08-09
59
-------------------
610
This release focused on supporting Pint quantities.

CITATION.cff

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This CITATION.cff file was generated with cffinit.
2+
# Visit https://bit.ly/cffinit to generate yours today!
3+
4+
cff-version: 1.2.0
5+
title: gsw-xarray
6+
message: >-
7+
If you use this software, please cite it using the
8+
metadata from this file.
9+
type: software
10+
authors:
11+
- given-names: Romain
12+
family-names: Caneill
13+
14+
orcid: 'https://orcid.org/0000-0001-6649-4275'
15+
- given-names: Andrew
16+
family-names: Barna
17+
orcid: 'https://orcid.org/0000-0002-5203-8954'
18+
identifiers:
19+
- type: doi
20+
value: 10.5281/zenodo.8297618
21+
repository-code: 'https://github.com/DocOtak/gsw-xarray'
22+
abstract: >-
23+
Wrapper for gsw that will add CF attributes to
24+
xarray.DataArray outputs
25+
license: BSD-3-Clause

README.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
:alt: pypi package
1010
.. |conda forge| image:: https://img.shields.io/conda/vn/conda-forge/gsw-xarray
1111
:target: https://anaconda.org/conda-forge/gsw-xarray
12+
.. |zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.8297618.svg
13+
:target: https://doi.org/10.5281/zenodo.8297618
14+
:alt: zenodo DOI
1215

1316
gsw-xarray: Wrapper for gsw that adds CF attributes
1417
===================================================
15-
|CI Status| |Documentation Status| |pypi| |conda forge|
18+
|CI Status| |Documentation Status| |pypi| |conda forge| |zenodo|
1619

1720
gsw-xarray is a wrapper for `gsw python <https://github.com/TEOS-10/GSW-python>`_
1821
that will add CF attributes to xarray.DataArray outputs.
@@ -229,11 +232,22 @@ Conda
229232

230233
Inside a conda environment: ``conda install -c conda-forge gsw-xarray``.
231234

232-
Pipenv
233-
......
234235

235-
Inside a pipenv environment: ``pipenv install gsw-xarray``.
236+
Citation
237+
--------
236238

239+
If you use gsw-xarray, please cite the reference paper for the upstream gsw library: McDougall, T.J. and P.M. Barker, 2011: Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox, 28pp., SCOR/IAPSO WG127, ISBN 978-0-646-55621-5
240+
241+
.. code:: bibtex
242+
@book{mcdougall2011getting,
243+
author = {McDougall, T. J. and Barker, P. M.},
244+
title = {Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox},
245+
year = {2011},
246+
pages = {28},
247+
publisher = {SCOR/IAPSO WG127},
248+
isbn = {978-0-646-55621-5}
249+
}
250+
You can also cite gsw-xarray by using the zenodo DOI |zenodo|.
237251

238252
Contributor guide
239253
-----------------
@@ -257,7 +271,7 @@ Then go to your local clone of gsw-xarray and launch installation:
257271
.. code:: bash
258272
259273
cd /path/to/your/gsw-xarray
260-
poetry install
274+
poetry install --with dev
261275
262276
You can then activate the environment by launching a shell
263277
within the virtual environment:
@@ -272,6 +286,9 @@ You can check that the tests pass locally:
272286
273287
pytest gsw_xarray/tests
274288
289+
You can install `pre-commit <https://pre-commit.com/#install>`_ to run the linting
290+
automatically at each commit.
291+
275292
Release (for maintainers only)
276293
..............................
277294

docs/gen_attr_table.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from sphinx.util import progress_message
2-
31
from inspect import signature
42

3+
from sphinx.util import progress_message
4+
55
import gsw_xarray
6-
from gsw_xarray._names import _names
7-
from gsw_xarray._attributes import _func_attrs
86
from gsw_xarray._arguments import input_properties
7+
from gsw_xarray._attributes import _func_attrs
8+
from gsw_xarray._names import _names
99

1010
input_units = {i: input_properties[i]["units"] for i in input_properties}
1111

@@ -33,7 +33,7 @@ def _add_attrs(list_table, attrs, label):
3333
props["standard_name"] = "sea_ice_temperature"
3434
else:
3535
props["standard_name"] = "sea_water_temperature"
36-
if arg == "p" and not "ice" in name:
36+
if arg == "p" and "ice" not in name:
3737
props["standard_name"] = "sea_water_pressure"
3838
for prop in props:
3939
list_table += f" * {prop}: ``{props.get(prop)}``\n"

gsw_xarray/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
__version__ = "0.3.0"
22

3-
from importlib import import_module
4-
53
import gsw
4+
5+
import gsw_xarray._accessor # noqa: F401
6+
67
from ._core import _wrapped_funcs
7-
from ._util import submodule_all_compat, get_attribute, _compat
8-
import gsw_xarray._accessor
9-
from ._options import set_options, get_options, set_non_cf_name, set_cf_name_preference
8+
from ._options import ( # noqa: F401
9+
get_options,
10+
set_cf_name_preference,
11+
set_non_cf_name,
12+
set_options,
13+
)
14+
from ._util import _compat, get_attribute
15+
from ._util_module import submodule_all_compat
1016

1117
gsw_xarray_specific_functions = [
1218
"set_options",
@@ -15,10 +21,10 @@
1521
"set_cf_name_preference",
1622
]
1723

18-
_compat_modules = {name: import_module(f".{name}", "gsw_xarray") for name in _compat}
1924

2025
__all__ = submodule_all_compat("gsw") + list(_compat)
2126

27+
2228
# See PEP 562
2329
def __getattr__(name):
2430
return get_attribute(name)

0 commit comments

Comments
 (0)