Skip to content

Commit

Permalink
Merge pull request #71 from DocOtak/rcaneill_add_citation2
Browse files Browse the repository at this point in the history
add citation, update readthedoc config, add 3.12 in CI
  • Loading branch information
rcaneill authored May 28, 2024
2 parents 475bd8b + dfd6fb6 commit a6df06f
Show file tree
Hide file tree
Showing 32 changed files with 1,554 additions and 1,546 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,19 @@ on:
branches: [ master ]

jobs:
style:
name: Code linting checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose"
version: "22.3.0"

build:
name: build (${{ matrix.os }}, ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install / build
Expand All @@ -41,34 +31,51 @@ jobs:
pip install .
test:
name: test (${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint)
runs-on: ${{ matrix.os }}
name: test (ubuntu-latest, ${{ matrix.python-version }}, ${{ matrix.pint }} Pint, packages version ${{ matrix.version }})
runs-on: "ubuntu-latest"
env:
poetry_version: 1.3.2
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
poetry-version: [1.3.2]
python-version: ["3.9", "3.10", "3.11", "3.12"]
pint: ["with", "without"]
version: ["lock"]
include:
- python-version: "3.9"
version: "minimal"
pint: "with"
- python-version: "3.12"
version: "maximal"
pint: "with"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry==${{ matrix.poetry-version }}
run: pipx install poetry==${{ env.poetry_version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install udunits
run: sudo apt-get install -y libudunits2-dev
- name: update lock file
if: matrix.version == 'maximal'
run: poetry update
- name: Install dependencies
run: |
poetry install
poetry install --with dev
poetry run pip install cf_units==3.0.1
- if: matrix.pint == 'with'
name: Install pint and pint-xarray
run: |
poetry install -E pint
- name: use minimal versions for lock file
if: matrix.version == 'minimal'
run: |
pipx install pdm==2.15.2
poetry run pdm lock --strategy direct_minimal_versions -v -G :all
poetry run pdm install -v -G :all
- name: Test with pytest
run: |
poetry run pytest gsw_xarray/tests
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build and publish to pypi
uses: JRubics/[email protected]
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: format and lint

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
# Update output format to enable automatic inline annotations.
- name: Run Ruff
run: ruff check --output-format=github .
- name: Run Ruff format
run: ruff format --check .
25 changes: 3 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ruff
.ruff_cache

# These files are generated on doc build and shoudl not be kept in VC
docs/_attr_table.rst
docs/ARGO_example.nc
Expand Down Expand Up @@ -65,16 +68,6 @@ cover/
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

Expand All @@ -92,18 +85,6 @@ target/
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
Expand Down
13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
hooks:
- id: black
language_version: python3
- id: ruff
name: lint with ruff
- id: ruff
name: sort imports with ruff
args: [--select, I, --fix]
- id: ruff-format
name: format with ruff
4 changes: 1 addition & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ build:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
# Install dependencies with 'docs' extra
- poetry install -E docs
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs

sphinx:
configuration: docs/conf.py
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

v0.4.0 - not released
---------------------
This release adds an accessor for xarray. Support for python 3.8 is dropped and 3.12 is added.

v0.3.0 - 2022-08-09
-------------------
This release focused on supporting Pint quantities.
Expand Down
25 changes: 25 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: gsw-xarray
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Romain
family-names: Caneill
email: [email protected]
orcid: 'https://orcid.org/0000-0001-6649-4275'
- given-names: Andrew
family-names: Barna
orcid: 'https://orcid.org/0000-0002-5203-8954'
identifiers:
- type: doi
value: 10.5281/zenodo.8297618
repository-code: 'https://github.com/DocOtak/gsw-xarray'
abstract: >-
Wrapper for gsw that will add CF attributes to
xarray.DataArray outputs
license: BSD-3-Clause
27 changes: 22 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
:alt: pypi package
.. |conda forge| image:: https://img.shields.io/conda/vn/conda-forge/gsw-xarray
:target: https://anaconda.org/conda-forge/gsw-xarray
.. |zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.8297618.svg
:target: https://doi.org/10.5281/zenodo.8297618
:alt: zenodo DOI

gsw-xarray: Wrapper for gsw that adds CF attributes
===================================================
|CI Status| |Documentation Status| |pypi| |conda forge|
|CI Status| |Documentation Status| |pypi| |conda forge| |zenodo|

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

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

Pipenv
......

Inside a pipenv environment: ``pipenv install gsw-xarray``.
Citation
--------

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

.. code:: bibtex
@book{mcdougall2011getting,
author = {McDougall, T. J. and Barker, P. M.},
title = {Getting started with TEOS-10 and the Gibbs Seawater (GSW) Oceanographic Toolbox},
year = {2011},
pages = {28},
publisher = {SCOR/IAPSO WG127},
isbn = {978-0-646-55621-5}
}
You can also cite gsw-xarray by using the zenodo DOI |zenodo|.

Contributor guide
-----------------
Expand All @@ -257,7 +271,7 @@ Then go to your local clone of gsw-xarray and launch installation:
.. code:: bash
cd /path/to/your/gsw-xarray
poetry install
poetry install --with dev
You can then activate the environment by launching a shell
within the virtual environment:
Expand All @@ -272,6 +286,9 @@ You can check that the tests pass locally:
pytest gsw_xarray/tests
You can install `pre-commit <https://pre-commit.com/#install>`_ to run the linting
automatically at each commit.

Release (for maintainers only)
..............................

Expand Down
10 changes: 5 additions & 5 deletions docs/gen_attr_table.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from sphinx.util import progress_message

from inspect import signature

from sphinx.util import progress_message

import gsw_xarray
from gsw_xarray._names import _names
from gsw_xarray._attributes import _func_attrs
from gsw_xarray._arguments import input_properties
from gsw_xarray._attributes import _func_attrs
from gsw_xarray._names import _names

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

Expand Down Expand Up @@ -33,7 +33,7 @@ def _add_attrs(list_table, attrs, label):
props["standard_name"] = "sea_ice_temperature"
else:
props["standard_name"] = "sea_water_temperature"
if arg == "p" and not "ice" in name:
if arg == "p" and "ice" not in name:
props["standard_name"] = "sea_water_pressure"
for prop in props:
list_table += f" * {prop}: ``{props.get(prop)}``\n"
Expand Down
18 changes: 12 additions & 6 deletions gsw_xarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
__version__ = "0.3.0"

from importlib import import_module

import gsw

import gsw_xarray._accessor # noqa: F401

from ._core import _wrapped_funcs
from ._util import submodule_all_compat, get_attribute, _compat
import gsw_xarray._accessor
from ._options import set_options, get_options, set_non_cf_name, set_cf_name_preference
from ._options import ( # noqa: F401
get_options,
set_cf_name_preference,
set_non_cf_name,
set_options,
)
from ._util import _compat, get_attribute
from ._util_module import submodule_all_compat

gsw_xarray_specific_functions = [
"set_options",
Expand All @@ -15,10 +21,10 @@
"set_cf_name_preference",
]

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

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


# See PEP 562
def __getattr__(name):
return get_attribute(name)
Expand Down
Loading

0 comments on commit a6df06f

Please sign in to comment.