From 6e2b5d845b3c6412c43d19bd62d58db83c0ee43d Mon Sep 17 00:00:00 2001 From: Callum Rollo Date: Wed, 1 Mar 2023 16:37:34 +0100 Subject: [PATCH 01/30] Add ctd to environment --- .binder/environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.binder/environment.yml b/.binder/environment.yml index 2310763..b986959 100644 --- a/.binder/environment.yml +++ b/.binder/environment.yml @@ -11,3 +11,4 @@ dependencies: - pandas-flavor >=0.1.2 - scipy - jupyter + - ctd From 682fe393899507addfcb01bb515ac0c67cf8a0ce Mon Sep 17 00:00:00 2001 From: Callum Rollo Date: Thu, 2 Mar 2023 08:22:55 +0100 Subject: [PATCH 02/30] specify latest dev version Co-authored-by: Filipe --- .binder/environment.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.binder/environment.yml b/.binder/environment.yml index b986959..d656961 100644 --- a/.binder/environment.yml +++ b/.binder/environment.yml @@ -11,4 +11,7 @@ dependencies: - pandas-flavor >=0.1.2 - scipy - jupyter - - ctd + - pip + - pip: + - ctd @ git+https://github.com/pyoceans/python-ctd@main + From 297df603c5e79d95a8d8d9cee78c48d608393334 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 Mar 2023 07:23:17 +0000 Subject: [PATCH 03/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .binder/environment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.binder/environment.yml b/.binder/environment.yml index d656961..45c3bf8 100644 --- a/.binder/environment.yml +++ b/.binder/environment.yml @@ -14,4 +14,3 @@ dependencies: - pip - pip: - ctd @ git+https://github.com/pyoceans/python-ctd@main - From 4b7c8cdf7cece7e48814b1a3c60aae991636d970 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Mar 2023 22:31:10 +0000 Subject: [PATCH 04/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/codespell-project/codespell: v2.2.2 → v2.2.4](https://github.com/codespell-project/codespell/compare/v2.2.2...v2.2.4) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1abe5d2..958b1a13 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,7 +42,7 @@ repos: - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell args: From a5147970f94fe485b269444f0aa252204f8ab16d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Apr 2023 23:32:28 +0000 Subject: [PATCH 05/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.1.0 → 23.3.0](https://github.com/psf/black/compare/23.1.0...23.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 958b1a13..739b6a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,7 +35,7 @@ repos: args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - id: black language_version: python3 From 49e134f7293d35583112ff9d5e849c61db5deeef Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 22:31:36 +0000 Subject: [PATCH 06/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.3.1 → v3.3.2](https://github.com/asottile/pyupgrade/compare/v3.3.1...v3.3.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 739b6a1..3e21fea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,7 +49,7 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.3.2 hooks: - id: pyupgrade args: From f1a641c309f5a27a761b570903aa722c8bda0303 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 May 2023 22:47:29 +0000 Subject: [PATCH 07/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.3.2 → v3.4.0](https://github.com/asottile/pyupgrade/compare/v3.3.2...v3.4.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e21fea..4de948a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,7 +49,7 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/pyupgrade - rev: v3.3.2 + rev: v3.4.0 hooks: - id: pyupgrade args: From e0584dbc47c435616b072ec2d5ef061cc57081d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 May 2023 07:04:21 +0000 Subject: [PATCH 08/30] Bump mamba-org/provision-with-micromamba from 15 to 16 Bumps [mamba-org/provision-with-micromamba](https://github.com/mamba-org/provision-with-micromamba) from 15 to 16. - [Release notes](https://github.com/mamba-org/provision-with-micromamba/releases) - [Commits](https://github.com/mamba-org/provision-with-micromamba/compare/v15...v16) --- updated-dependencies: - dependency-name: mamba-org/provision-with-micromamba dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/deploy-docs.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 0371cfb..e699067 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -20,7 +20,7 @@ jobs: fetch-depth: 0 - name: Setup Micromamba - uses: mamba-org/provision-with-micromamba@v15 + uses: mamba-org/provision-with-micromamba@v16 with: environment-file: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ed0e480..1e3df47 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup Micromamba - uses: mamba-org/provision-with-micromamba@v15 + uses: mamba-org/provision-with-micromamba@v16 with: environment-file: false From d653a7fce9e2e450f7d12ef53ce32e335b1c90e1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 12 Jun 2023 22:40:36 +0000 Subject: [PATCH 09/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.4.0 → v3.6.0](https://github.com/asottile/pyupgrade/compare/v3.4.0...v3.6.0) - [github.com/asottile/add-trailing-comma: v2.4.0 → v2.5.1](https://github.com/asottile/add-trailing-comma/compare/v2.4.0...v2.5.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4de948a..60623f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,13 +49,13 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/pyupgrade - rev: v3.4.0 + rev: v3.6.0 hooks: - id: pyupgrade args: - --py36-plus - repo: https://github.com/asottile/add-trailing-comma - rev: v2.4.0 + rev: v2.5.1 hooks: - id: add-trailing-comma From d0f8896fc7ea19a8fbc8096e425569b1194a34ed Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Jun 2023 23:03:17 +0000 Subject: [PATCH 10/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/codespell-project/codespell: v2.2.4 → v2.2.5](https://github.com/codespell-project/codespell/compare/v2.2.4...v2.2.5) - [github.com/asottile/pyupgrade: v3.6.0 → v3.7.0](https://github.com/asottile/pyupgrade/compare/v3.6.0...v3.7.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60623f8..f55a570 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,14 +42,14 @@ repos: - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.2.5 hooks: - id: codespell args: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/pyupgrade - rev: v3.6.0 + rev: v3.7.0 hooks: - id: pyupgrade args: From fdcd75cb72b779e04a6878e4f61a2cdbfe503488 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 21 Jun 2023 11:11:10 -0300 Subject: [PATCH 11/30] use ruff --- .pre-commit-config.yaml | 61 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f55a570..8fd6c50 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,33 +13,24 @@ repos: - id: file-contents-sorter files: requirements-dev.txt -- repo: https://github.com/econchick/interrogate - rev: 1.5.0 - hooks: - - id: interrogate - exclude: ^(docs|setup.py|tests) - args: [--config=pyproject.toml] - -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - exclude: docs/source/conf.py - args: [--max-line-length=105, --ignore=E203] - -- repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - additional_dependencies: [toml] - args: ["--profile", "black", "--filter-files"] - - repo: https://github.com/psf/black rev: 23.3.0 hooks: - id: black language_version: python3 +- repo: https://github.com/keewis/blackdoc + rev: v0.3.8 + hooks: + - id: blackdoc + +- repo: https://github.com/econchick/interrogate + rev: 1.5.0 + hooks: + - id: interrogate + exclude: ^(docs|tests) + args: [--config=pyproject.toml] + - repo: https://github.com/codespell-project/codespell rev: v2.2.5 @@ -48,14 +39,28 @@ repos: args: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo -- repo: https://github.com/asottile/pyupgrade - rev: v3.7.0 - hooks: - - id: pyupgrade - args: - - --py36-plus - - repo: https://github.com/asottile/add-trailing-comma rev: v2.5.1 hooks: - id: add-trailing-comma + +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.274 + hooks: + - id: ruff + +- repo: https://github.com/tox-dev/pyproject-fmt + rev: 0.12.1 + hooks: + - id: pyproject-fmt + +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 From bdec79feca8d331788303dae88ce35c6be1cb44c Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 21 Jun 2023 11:11:46 -0300 Subject: [PATCH 12/30] delete unused files --- .isort.cfg | 2 -- setup.cfg | 49 ------------------------------------------------- setup.py | 12 ------------ 3 files changed, 63 deletions(-) delete mode 100644 .isort.cfg delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index be273cd..0000000 --- a/.isort.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[settings] -known_third_party = gsw,matplotlib,numpy,pandas,pandas_flavor,pytest,setuptools diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 012e343..0000000 --- a/setup.cfg +++ /dev/null @@ -1,49 +0,0 @@ -[metadata] -name = ctd -description = Tools to load hydrographic data into pandas DataFrame -author = Filipe Fernandes -author_email = ocefpaf@gmail.com -url = https://github.com/pyoceans/python-ctd -long_description_content_type = text/markdown -long_description = file: README.md -license = BSD-3-Clause -license_files = 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 - Topic :: Scientific/Engineering - -[options] -zip_safe = True -install_requires = - chardet - gsw >=3.3.0 - matplotlib - numpy - pandas >=0.24.0 - pandas-flavor >=0.1.2 - scipy -python_requires = >=3.6 -packages = find: - -[sdist] -formats = gztar - -[check-manifest] -ignore = - *.yml - .coveragerc - docs - docs/* - notebooks - notebooks/* - tests - tests/* - -[flake8] -max-line-length = 105 -ignore = E203 diff --git a/setup.py b/setup.py deleted file mode 100644 index b451531..0000000 --- a/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup - -setup( - # 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="ctd", - use_scm_version={ - "write_to": "ctd/_version.py", - "write_to_template": '__version__ = "{version}"', - "tag_regex": r"^(?Pv)?(?P[^\+]+)(?P.*)?$", - }, -) From a3edd3244e4bdc9fb40bb14b2c0238692f5ab604 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 21 Jun 2023 11:12:03 -0300 Subject: [PATCH 13/30] move to pyproject.toml --- pyproject.toml | 77 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index afc1fba..c4bb7e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,79 @@ [build-system] -requires = ["setuptools>=41.2", "setuptools_scm", "wheel"] build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=41.2", + "setuptools_scm", + "wheel", +] + +[project] +name = "ctd" +description = "Tools to load hydrographic data into pandas DataFrame" +license = {text = "BSD-3-Clause"} +authors = [ + {name = "Filipe Fernandes", email = "ocefpaf+ctd@gmail.com"}, +] +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dynamic = [ + "dependencies", + "readme", + "version", +] +[project.urls] +documentation = "https://pyoceans.github.io/python-ctd" +homepage = "https://github.com/pyoceans/python-ctd" +repository = "https://github.com/pyoceans/python-ctd" + +[tool.setuptools] +packages = ["ctd"] +include-package-data = true +license-files = ["LICENSE.txt"] + +[tool.setuptools.dynamic] +dependencies = {file = ["requirements.txt"]} +readme = {file = "README.md", content-type = "text/markdown"} + +[tool.setuptools_scm] +write_to = "ctd/_version.py" +write_to_template = "__version__ = '{version}'" +tag_regex = "^(?Pv)?(?P[^\\+]+)(?P.*)?$" + +[tool.ruff] +select = [ + "A", # flake8-builtins + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "F", # flakes + "I", # import sorting + "T20", # flake8-print + "UP", # upgrade +] +target-version = "py39" +line-length = 80 + +[tool.ruff.per-file-ignores] +"docs/source/conf.py" = [ + "E402", + "A001", +] + +[tool.check-manifest] +ignore = [ + "*.yml", + ".coveragerc", + "docs", + "docs/*", + "notebooks", + "notebooks/*", + "tests", + "tests/*", +] [tool.interrogate] ignore-init-method = true @@ -10,7 +83,7 @@ ignore-semiprivate = false ignore-private = false ignore-module = false fail-under = 95 -exclude = ["setup.py", "docs", "tests"] +exclude = ["docs", "tests"] verbose = 1 quiet = false color = true From e82da77469fc811abe40bcb7bfc5d0e0120b4088 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Wed, 21 Jun 2023 11:18:07 -0300 Subject: [PATCH 14/30] run-precommits and use setup-micromamba --- .github/workflows/deploy-docs.yml | 32 +++++++++++-------------- .github/workflows/pypi.yml | 13 +++++----- .github/workflows/tests.yml | 17 +++++++------ ctd/plotting.py | 6 ++--- ctd/processing.py | 10 ++++---- ctd/read.py | 40 ++++++++++++++++++------------- 6 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index e699067..46e1830 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -19,35 +19,31 @@ jobs: with: fetch-depth: 0 - - name: Setup Micromamba - uses: mamba-org/provision-with-micromamba@v16 + - name: Setup Micromamba Python + uses: mamba-org/setup-micromamba@v1 with: - environment-file: false + environment-name: TEST + init-shell: bash + create-args: >- + python=3 --file requirements.txt --file requirements-dev.txt --channel conda-forge - - name: Build environment + - name: Install ctd shell: bash -l {0} run: | - micromamba create --name TEST python=3 --file requirements.txt --file requirements-dev.txt --channel conda-forge - micromamba activate TEST python -m pip install -e . --no-deps --force-reinstall - - name: Get the version - id: get_version - run: echo ::set-output name=VERSION::$(python setup.py --version) - - name: Build documentation shell: bash -l {0} - run: | + run: > set -e - micromamba activate TEST - jupyter nbconvert --to notebook --execute notebooks/quick_intro.ipynb --output=quick_intro-output.ipynb - mv notebooks/*output.ipynb docs/source/ - pushd docs - make clean html linkcheck - popd + && jupyter nbconvert --to notebook --execute notebooks/quick_intro.ipynb --output=quick_intro-output.ipynb + && mv notebooks/*output.ipynb docs/source/ + && pushd docs + && make clean html linkcheck + && popd - name: Deploy - if: github.event_name == 'release' || github.event_name == 'push' + if: success() && github.event_name == 'release' uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 91db72b..2eebf21 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -9,6 +9,10 @@ on: types: - published +defaults: + run: + shell: bash + jobs: packages: runs-on: ubuntu-latest @@ -22,13 +26,10 @@ jobs: - name: Get tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - shell: bash - name: Install build tools run: | - python -m pip install --upgrade pip wheel setuptools setuptools_scm build twine - - shell: bash + python -m pip install --upgrade pip build twine - name: Build binary wheel run: python -m build --sdist --wheel . --outdir dist @@ -36,13 +37,11 @@ jobs: - name: CheckFiles run: | ls dist - shell: bash - name: Test wheels run: | - cd dist && python -m pip install ctd*.whl + cd dist && python -m pip install *.whl python -m twine check * - shell: bash - name: Publish a Python distribution to PyPI if: success() && github.event_name == 'release' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e3df47..343de1f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,33 +10,32 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11"] os: [windows-latest, ubuntu-latest, macos-latest] fail-fast: false steps: - uses: actions/checkout@v3 - - name: Setup Micromamba - uses: mamba-org/provision-with-micromamba@v16 + - name: Setup Micromamba Python ${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@v1 with: - environment-file: false + environment-name: TEST + init-shell: bash + create-args: >- + python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge - - name: Python ${{ matrix.python-version }} + - name: Install ctd shell: bash -l {0} run: | - micromamba create --name TEST python=${{ matrix.python-version }} --file requirements.txt --file requirements-dev.txt --channel conda-forge - micromamba activate TEST python -m pip install -e . --no-deps --force-reinstall - name: Tests shell: bash -l {0} run: | - micromamba activate TEST python -m pytest -rxs tests - name: Doctests shell: bash -l {0} run: | - micromamba activate TEST python -m pytest -s -rxs --doctest-modules -vv ctd diff --git a/ctd/plotting.py b/ctd/plotting.py index a8ec726..260f80f 100644 --- a/ctd/plotting.py +++ b/ctd/plotting.py @@ -29,7 +29,7 @@ def plot_cast(df, secondary_y=False, label=None, ax=None, *args, **kwargs): y_inverted = False if not getattr(ax, "y_inverted", False): - setattr(ax, "y_inverted", True) + ax.y_inverted = True y_inverted = True if secondary_y: @@ -40,11 +40,11 @@ def plot_cast(df, secondary_y=False, label=None, ax=None, *args, **kwargs): if isinstance(df, pd.DataFrame): labels = label if label else df.columns - for k, (col, series) in enumerate(df.items()): + for k, (_col, series) in enumerate(df.items()): ax.plot(series, series.index, label=labels[k]) elif isinstance(df, pd.Series): label = label if label else str(df.name) - ax.plot(df.values, df.index, label=label, *args, **kwargs) + ax.plot(df.values, df.index, *args, label=label, **kwargs) ax.set_ylabel(ylabel) ax.set_xlabel(xlabel) diff --git a/ctd/processing.py b/ctd/processing.py index 6582d5e..8aecc11 100644 --- a/ctd/processing.py +++ b/ctd/processing.py @@ -62,16 +62,16 @@ def lp_filter(df, sample_rate=24.0, time_constant=0.15): >>> import matplotlib.pyplot as plt >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> raw = ctd.from_cnv(data_path.joinpath('CTD-spiked-unfiltered.cnv.bz2')) - >>> prc = ctd.from_cnv(data_path.joinpath('CTD-spiked-filtered.cnv.bz2')) + >>> raw = ctd.from_cnv(data_path.joinpath("CTD-spiked-unfiltered.cnv.bz2")) + >>> prc = ctd.from_cnv(data_path.joinpath("CTD-spiked-filtered.cnv.bz2")) >>> kw = {"sample_rate": 24.0, "time_constant": 0.15} >>> original = prc.index.values >>> unfiltered = raw.index.values >>> filtered = raw.lp_filter(**kw).index.values >>> fig, ax = plt.subplots() - >>> l1, = ax.plot(original, 'k', label='original') - >>> l2, = ax.plot(unfiltered, 'r', label='unfiltered') - >>> l3, = ax.plot(filtered, 'g', label='filtered') + >>> (l1,) = ax.plot(original, "k", label="original") + >>> (l2,) = ax.plot(unfiltered, "r", label="unfiltered") + >>> (l3,) = ax.plot(filtered, "g", label="filtered") >>> leg = ax.legend() Notes diff --git a/ctd/read.py b/ctd/read.py index 384a3b2..46266b4 100644 --- a/ctd/read.py +++ b/ctd/read.py @@ -202,7 +202,7 @@ def from_bl(fname): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> df = ctd.from_bl(str(data_path.joinpath('bl', 'bottletest.bl'))) + >>> df = ctd.from_bl(str(data_path.joinpath("bl", "bottletest.bl"))) >>> df._metadata["time_of_reset"] datetime.datetime(2018, 6, 25, 20, 8, 55) @@ -231,7 +231,7 @@ def from_btl(fname): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> bottles = ctd.from_btl(data_path.joinpath('btl', 'bottletest.btl')) + >>> bottles = ctd.from_btl(data_path.joinpath("btl", "bottletest.btl")) """ f = _read_file(fname) @@ -291,10 +291,13 @@ def from_btl(fname): try: df[column] = df[column].astype(float) except ValueError: - warnings.warn("Could not convert %s to float." % column) + warnings.warn( + f"Could not convert {column} to float.", + stacklevel=2, + ) df["Date"] = pd.to_datetime(df["Date"]) - setattr(df, "_metadata", metadata) + df._metadata = metadata return df @@ -307,8 +310,8 @@ def from_edf(fname): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> cast = ctd.from_edf(data_path.joinpath('XBT.EDF.gz')) - >>> ax = cast['temperature'].plot_cast() + >>> cast = ctd.from_edf(data_path.joinpath("XBT.EDF.gz")) + >>> ax = cast["temperature"].plot_cast() """ f = _read_file(fname) @@ -370,7 +373,7 @@ def from_edf(fname): "header": "\n".join(header), "serial": serial, } - setattr(df, "_metadata", metadata) + df._metadata = metadata return df @@ -383,9 +386,9 @@ def from_cnv(fname): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> cast = ctd.from_cnv(data_path.joinpath('CTD_big.cnv.bz2')) + >>> cast = ctd.from_cnv(data_path.joinpath("CTD_big.cnv.bz2")) >>> downcast, upcast = cast.split() - >>> ax = downcast['t090C'].plot_cast() + >>> ax = downcast["t090C"].plot_cast() """ f = _read_file(fname) @@ -451,10 +454,13 @@ def from_cnv(fname): try: df[column] = df[column].astype(float) except ValueError: - warnings.warn("Could not convert %s to float." % column) + warnings.warn( + f"Could not convert {column} to float.", + stacklevel=2, + ) metadata["name"] = str(name) - setattr(df, "_metadata", metadata) + df._metadata = metadata return df @@ -468,9 +474,9 @@ def from_fsi(fname, skiprows=9): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> cast = ctd.from_fsi(data_path.joinpath('FSI.txt.gz')) + >>> cast = ctd.from_fsi(data_path.joinpath("FSI.txt.gz")) >>> downcast, upcast = cast.split() - >>> ax = downcast['TEMP'].plot_cast() + >>> ax = downcast["TEMP"].plot_cast() """ f = _read_file(fname) @@ -487,7 +493,7 @@ def from_fsi(fname, skiprows=9): df.set_index("PRES", drop=True, inplace=True) df.index.name = "Pressure [dbar]" metadata = {"name": str(fname)} - setattr(df, "_metadata", metadata) + df._metadata = metadata return df @@ -505,7 +511,7 @@ def rosette_summary(fname): >>> from pathlib import Path >>> import ctd >>> data_path = Path(__file__).parents[1].joinpath("tests", "data") - >>> fname = data_path.joinpath('CTD/g01l01s01.ros') + >>> fname = data_path.joinpath("CTD/g01l01s01.ros") >>> ros = ctd.rosette_summary(fname) >>> ros = ros.groupby(ros.index).mean() >>> ros.pressure.values.astype(int) @@ -526,7 +532,7 @@ def from_castaway_csv(fname): Example -------- >>> import ctd - >>> cast = ctd.from_castaway_csv('tests/data/castaway_data.csv') + >>> cast = ctd.from_castaway_csv("tests/data/castaway_data.csv") >>> cast.columns Index(['depth', 'temperature', 'conductivity', 'specific_conductance', 'salinity', 'sound_velocity', 'density'], @@ -561,6 +567,6 @@ def from_castaway_csv(fname): for line in meta: metadata[line[0]] = line[1] metadata["units"] = units - setattr(df, "_metadata", metadata) + df._metadata = metadata return df From 93854cf016c14cdf9e3d33d40bb7829ae47660c2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Jul 2023 23:09:01 +0000 Subject: [PATCH 15/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v2.5.1 → v3.0.0](https://github.com/asottile/add-trailing-comma/compare/v2.5.1...v3.0.0) - https://github.com/charliermarsh/ruff-pre-commit → https://github.com/astral-sh/ruff-pre-commit - [github.com/astral-sh/ruff-pre-commit: v0.0.274 → v0.0.276](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.274...v0.0.276) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8fd6c50..77a2d53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,12 +40,12 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/add-trailing-comma - rev: v2.5.1 + rev: v3.0.0 hooks: - id: add-trailing-comma -- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.274 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.276 hooks: - id: ruff From 16b8418427f22ea95421419e081302a0c8a427eb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 00:15:27 +0000 Subject: [PATCH 16/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.3.0 → 23.7.0](https://github.com/psf/black/compare/23.3.0...23.7.0) - [github.com/asottile/add-trailing-comma: v3.0.0 → v3.0.1](https://github.com/asottile/add-trailing-comma/compare/v3.0.0...v3.0.1) - [github.com/astral-sh/ruff-pre-commit: v0.0.276 → v0.0.281](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.276...v0.0.281) - [github.com/tox-dev/pyproject-fmt: 0.12.1 → 0.13.0](https://github.com/tox-dev/pyproject-fmt/compare/0.12.1...0.13.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77a2d53..6bcd66d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - id: black language_version: python3 @@ -40,17 +40,17 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.0 + rev: v3.0.1 hooks: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.276 + rev: v0.0.281 hooks: - id: ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: 0.12.1 + rev: 0.13.0 hooks: - id: pyproject-fmt From bbe39ad4612ced80ca986e8a99ab4646f0920cdb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 23:53:50 +0000 Subject: [PATCH 17/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.281...v0.0.282) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6bcd66d..067b226 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.281 + rev: v0.0.282 hooks: - id: ruff From 9c02dadbc8aec98088760941b8f8e2a860e128bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:12:51 +0000 Subject: [PATCH 18/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/add-trailing-comma: v3.0.1 → v3.1.0](https://github.com/asottile/add-trailing-comma/compare/v3.0.1...v3.1.0) - [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.287](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.282...v0.0.287) - [github.com/tox-dev/pyproject-fmt: 0.13.0 → 1.1.0](https://github.com/tox-dev/pyproject-fmt/compare/0.13.0...1.1.0) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 067b226..5a503da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,17 +40,17 @@ repos: - --ignore-words-list=pres,nd,te,afe,ue,wil,tey,te,ot,fo - repo: https://github.com/asottile/add-trailing-comma - rev: v3.0.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.282 + rev: v0.0.287 hooks: - id: ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: 0.13.0 + rev: 1.1.0 hooks: - id: pyproject-fmt From 5154311e48124ee12f8966ae4a11639cbaf2a28b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 06:36:32 +0000 Subject: [PATCH 19/30] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/deploy-docs.yml | 2 +- .github/workflows/pypi.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 46e1830..31f9735 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -15,7 +15,7 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 2eebf21..d2011f0 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -17,7 +17,7 @@ jobs: packages: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 343de1f..91e9b50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Micromamba Python ${{ matrix.python-version }} uses: mamba-org/setup-micromamba@v1 From 0dfca46fbf3f1cce1c704beb25ddc75c9b087fa8 Mon Sep 17 00:00:00 2001 From: Filipe Fernandes Date: Tue, 5 Sep 2023 12:52:51 -0300 Subject: [PATCH 20/30] fix with ruff --- tests/test_plotting.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_plotting.py b/tests/test_plotting.py index 2503ede..01e3401 100644 --- a/tests/test_plotting.py +++ b/tests/test_plotting.py @@ -18,8 +18,8 @@ def _assert_is_valid_plot_return_object(objs): assert isinstance(el, plt.Axes), ( "one of 'objs' is not a " "matplotlib Axes instance, " - "type encountered {!r}" - "".format(el.__class__.__name__) + f"type encountered {el.__class__.__name__!r}" + "" ) else: assert isinstance(objs, (plt.Artist, tuple, dict)), ( From b7b94bfe1d62524138e86363aa22018771458491 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 01:06:42 +0000 Subject: [PATCH 21/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.7.0 → 23.9.1](https://github.com/psf/black/compare/23.7.0...23.9.1) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](https://github.com/codespell-project/codespell/compare/v2.2.5...v2.2.6) - [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.292](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.287...v0.0.292) - [github.com/tox-dev/pyproject-fmt: 1.1.0 → 1.2.0](https://github.com/tox-dev/pyproject-fmt/compare/1.1.0...1.2.0) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5a503da..ef15867 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 hooks: - id: black language_version: python3 @@ -33,7 +33,7 @@ repos: - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: @@ -45,12 +45,12 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.287 + rev: v0.0.292 hooks: - id: ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.1.0 + rev: 1.2.0 hooks: - id: pyproject-fmt From 90d96caebef120a68db913bbc1bd80cef0771ab0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 01:07:19 +0000 Subject: [PATCH 22/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index c4bb7e7..a0a721e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] dynamic = [ "dependencies", From 36b22deb73be606e925b4e4377f1c9c8224f4e9c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:30:09 +0000 Subject: [PATCH 23/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/psf/black: 23.9.1 → 23.10.1](https://github.com/psf/black/compare/23.9.1...23.10.1) - [github.com/keewis/blackdoc: v0.3.8 → v0.3.9](https://github.com/keewis/blackdoc/compare/v0.3.8...v0.3.9) - [github.com/astral-sh/ruff-pre-commit: v0.0.292 → v0.1.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.0.292...v0.1.4) - [github.com/tox-dev/pyproject-fmt: 1.2.0 → 1.4.1](https://github.com/tox-dev/pyproject-fmt/compare/1.2.0...1.4.1) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ef15867..433ab22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace exclude: tests/data @@ -14,13 +14,13 @@ repos: files: requirements-dev.txt - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black language_version: python3 - repo: https://github.com/keewis/blackdoc - rev: v0.3.8 + rev: v0.3.9 hooks: - id: blackdoc @@ -45,12 +45,12 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.292 + rev: v0.1.4 hooks: - id: ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.2.0 + rev: 1.4.1 hooks: - id: pyproject-fmt From c6b76c01fe89aa1bd78cd6e9241a928618c78198 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Dec 2023 18:28:50 +0000 Subject: [PATCH 24/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) - [github.com/astral-sh/ruff-pre-commit: v0.1.4 → v0.1.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.4...v0.1.6) - [github.com/tox-dev/pyproject-fmt: 1.4.1 → 1.5.3](https://github.com/tox-dev/pyproject-fmt/compare/1.4.1...1.5.3) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 433ab22..6da8192 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - id: black language_version: python3 @@ -45,12 +45,12 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.4 + rev: v0.1.6 hooks: - id: ruff - repo: https://github.com/tox-dev/pyproject-fmt - rev: 1.4.1 + rev: 1.5.3 hooks: - id: pyproject-fmt From 4beb7f0cd55453f643a3b5ac8cdf80401c432b12 Mon Sep 17 00:00:00 2001 From: Patrick Upson Date: Wed, 6 Dec 2023 11:15:41 -0400 Subject: [PATCH 25/30] added fix for issue #196 and unit test --- ctd/read.py | 5 +- tests/data/btl/blank_line_header.btl | 198 +++++++++++++++++++++++++++ tests/test_read.py | 11 ++ 3 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 tests/data/btl/blank_line_header.btl diff --git a/ctd/read.py b/ctd/read.py index 46266b4..5d8f729 100644 --- a/ctd/read.py +++ b/ctd/read.py @@ -166,7 +166,10 @@ def _parse_seabird(lines, ftype): break else: # btl. # There is no *END* like in a .cnv file, skip two after header info. - if not (line.startswith("*") | line.startswith("#")): + + # if this line isn't completely blank and doesn't start with a # or a * + # then we assume we've finished reading the header section. + if line != "" and not (line.startswith("*") | line.startswith("#")): # Fix commonly occurring problem when Sbeox.* exists in the file # the name is concatenated to previous parameter # example: diff --git a/tests/data/btl/blank_line_header.btl b/tests/data/btl/blank_line_header.btl new file mode 100644 index 0000000..5a9b732 --- /dev/null +++ b/tests/data/btl/blank_line_header.btl @@ -0,0 +1,198 @@ +* Sea-Bird SBE25 Data File: +* FileName = C:\Users\Science\Documents\CAR2022102\ctd data\22102007.hex +* Software Version 1.59 +* Temperature SN = Sbe03_1817 +* Conductivity SN = Sbe04-0735 +* System UpLoad Time = Mar 31 2022 08:30:05 +** Latitude: 41 12.513 N +** Longitude: 067 09.722 W +** Ship: CFA3098 CCGS Capt Jacques Cartier +** Cruise: CAR2022102 +** Station_Label:755 +** Set_number:007 +** Stratum_number:5Z41 +** Station: 007 +** Sounding: 61 +** ID_Start:474815 +** Event_Comments: 2022 Georges Bank SurveyKP +* ds +* SBE 25 CTD V 4.0a SN 184 03/31/22 11:27:10.920 +* external pressure sensor, range = 1500 psia, tcval = 16 +* xtal = 9437427 clk = 32767.537 vmain = 12.5 iop = 4 vlith = 3.9 +* ncasts = 1 samples = 5815 free = 49165 lwait = 0 msec +* +* CTD configuration: +* number of scans averaged = 1, data stored at 8 scans per second +* real time data transmitted at 8 scans per second +* minimum conductivity frequency for pump turn on = 1500 +* battery type = ALKALINE +* +* 7 external voltages sampled +* stored voltage # 0 = external voltage 0 +* stored voltage # 1 = external voltage 1 +* stored voltage # 2 = external voltage 2 +* stored voltage # 3 = external voltage 3 +* stored voltage # 4 = external voltage 4 +* stored voltage # 5 = external voltage 5 +* stored voltage # 6 = external voltage 6 +* + + +* S> +* dh +* cast 0 03/31 10:46:00 smpls 0 to 5814 nv = 7 avg = 1 stp = switch of + +* S> +# interval = seconds: 0.125 +# start_time = Mar 31 2022 10:46:00 [Instrument's time stamp, header] +# +# +# +# +# Sbe03_1817 +# 24-Nov-2004 +# +# 1 +# 3.68120516e-003 +# 6.00510844e-004 +# 1.36911401e-005 +# 1.80939934e-006 +# 5918.752 +# 4.85872870e-003 +# 6.78186362e-004 +# 2.69032925e-005 +# 2.15066050e-006 +# 1000.000 +# 1.00000000 +# 0.0000 +# +# +# +# +# +# Sbe04-0735 +# 07-Jan-2009 +# 1 +# +# 0.0000 +# 2000.0000 +# 0 +# +# 0.00000000e+000 +# 0.00000000e+000 +# -9.57000000e-008 +# 0.00000000e+000 +# 0.0 +# 0.00000000e+000 +# +# +# -3.99405308e+000 +# 4.26940024e-001 +# 2.75670483e-004 +# 7.86847868e-006 +# -9.57000000e-008 +# 3.2500e-006 +# +# 0.00000000e+000 +# +# 1.00000000 +# 0.00000 +# +# +# +# +# +# Sbe29-0274 +# 12-Jan-2009 +# 7.888379e+002 +# -2.082626e-001 +# 3.829048e-007 +# 0.00000 +# +# +# +# +# +# Sbe43-1157 +# 23-May-2017 +# 1 +# +# +# 0.0000 +# 0.0000e+000 +# 0.0000 +# 0.00e+000 +# 0.0000 +# 0.0 +# +# +# +# 4.8000e-001 +# -0.5166 +# -3.8247e-003 +# 1.8386e-004 +# -2.9783e-006 +# 2.5826e+000 +# 1.92634e-004 +# -4.64803e-002 +# 3.6000e-002 +# 1.6900 +#

-3.3000e-002

+#

5.0000e+003

+#

1.4500e+003

+#
+#
+#
+# +# +# +# +# +# +# +# +# +# +# +# +# Mini-175028 +# 28 Jan 1998 +# 0.067 +# 5.419 +# 0.000 +# +# +# +# +# +# +# +# +# SPQA-4859 +# 04-Sept-2014 +# -0.77060200 +# -3.52671700 +# 4.28000000 +# 1.00000000 +# 0.00000000 +# +# +#
+# datcnv_date = Apr 19 2022 11:52:32, 7.26.6.28 +# datcnv_in = C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.hex C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\Pinky1_Sbe25-0184standalone_Apr2022.xmlcon +# datcnv_ox_hysteresis_correction = yes +# datcnv_bottle_scan_range_source = BL file +# datcnv_scans_per_bottle = 37 +# bottlesum_date = Apr 19 2022 11:52:36, 7.26.6.28 +# bottlesum_in = C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.ros C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\Pinky1_Sbe25-0184standalone_Apr2022.xmlcon C:\Users\PROUDFOOTMA\Documents\.MISSIONS\2022\CAR2022102_WinterGF\Data\CTD\Reprocessed_Pinky\CTDDATA\22102007.BL +# bottlesum_ox_tau_correction = yes + Bottle Bottle Date Sbeox0ML/L Sal00 Potemp090C Sigma-é00 Scan TimeS PrSM T090C C0S/m Sbeox0V FlCM Par + Position S/N Time + 4 474818 Mar 31 2022 6.0542 33.2232 6.7908 26.0473 792 98.875 5.556 6.7912 3.348640 2.3385 5.3210 2.2323e+00 (avg) + 10:47:36 11 1.353 0.329 0.0067 0.000340 0.0249 0.3117 1.9796e-01 (sdev) + 3 474817 Mar 31 2022 6.7306 33.2207 6.7863 26.0459 3250 406.125 26.130 6.7886 3.349098 2.5941 5.8026 4.8180e-02 (avg) + 10:52:43 11 1.353 0.503 0.0009 0.000096 0.0016 0.2241 6.2121e-03 (sdev) + 2 474816 Mar 31 2022 6.7188 33.2219 6.7951 26.0457 3691 461.250 51.103 6.7996 3.351271 2.5846 6.2792 3.1472e-03 (avg) + 10:53:38 11 1.353 0.476 0.0026 0.000221 0.0019 0.3323 1.0053e-04 (sdev) + 1 474815 Mar 31 2022 6.7283 33.2220 6.7985 26.0453 3969 496.000 59.278 6.8037 3.352000 2.5782 6.0967 2.0116e-03 (avg) + 10:54:13 11 1.353 0.365 0.0004 0.000037 0.0022 0.2897 0.0000e+00 (sdev) diff --git a/tests/test_read.py b/tests/test_read.py index 400a790..0ae60d4 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -112,6 +112,17 @@ def test_header_parse(): np.testing.assert_almost_equal(xbt._metadata["lat"], -19.7174805) +def test_header_parse_blank_line(): + # check that a BTL file can still be loaded if the header section contains blank lines + + # if the blank line in the header causes the reader to exit before reading the file + # the line looking for the Date in the ctd.from_btl() will throw a ValueError. + btl = ctd.from_btl(data_path.joinpath("btl", "blank_line_header.btl",)) + + # if a value error wasn't thrown, ensure the names array for the _metadata was set + assert btl._metadata["names"].index("Date") + + def test_pressure_field_labels(): """ Support different pressure field labels encountered in Sea-Bird cnv files. From 294ded7de00a69f2e5ccd47d999d0fa8e201f084 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 06:10:53 +0000 Subject: [PATCH 26/30] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index d2011f0..f35388f 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.x" From d05e833e428a5d9912f6e89bbe2e0d7bc826176a Mon Sep 17 00:00:00 2001 From: Patrick Upson Date: Sat, 9 Dec 2023 12:41:12 -0400 Subject: [PATCH 27/30] Update ctd/read.py Yes, looks good if that's how you want to tackle it Co-authored-by: Filipe --- ctd/read.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ctd/read.py b/ctd/read.py index 5d8f729..17a567e 100644 --- a/ctd/read.py +++ b/ctd/read.py @@ -166,10 +166,9 @@ def _parse_seabird(lines, ftype): break else: # btl. # There is no *END* like in a .cnv file, skip two after header info. - - # if this line isn't completely blank and doesn't start with a # or a * - # then we assume we've finished reading the header section. - if line != "" and not (line.startswith("*") | line.startswith("#")): + # Skip empty lines. + if not line: + continue # Fix commonly occurring problem when Sbeox.* exists in the file # the name is concatenated to previous parameter # example: From 2c9b8193c84ab9ef3595e1535ad1e79ebe4d3317 Mon Sep 17 00:00:00 2001 From: Patrick Upson Date: Mon, 11 Dec 2023 10:17:01 -0400 Subject: [PATCH 28/30] fixed update that caused multiple unit-test failures --- ctd/read.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ctd/read.py b/ctd/read.py index 17a567e..d56e195 100644 --- a/ctd/read.py +++ b/ctd/read.py @@ -169,6 +169,8 @@ def _parse_seabird(lines, ftype): # Skip empty lines. if not line: continue + + if not (line.startswith("*") | line.startswith("#")): # Fix commonly occurring problem when Sbeox.* exists in the file # the name is concatenated to previous parameter # example: From 2b17186e87129f300e78d46c68842e046f2f89cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:24:50 +0000 Subject: [PATCH 29/30] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.11.0 → 23.12.1](https://github.com/psf/black/compare/23.11.0...23.12.1) - [github.com/astral-sh/ruff-pre-commit: v0.1.6 → v0.1.9](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.6...v0.1.9) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6da8192..3e26f60 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: files: requirements-dev.txt - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black language_version: python3 @@ -45,7 +45,7 @@ repos: - id: add-trailing-comma - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.6 + rev: v0.1.9 hooks: - id: ruff From 6d9231b720ad19d438ff2ffc765445cc87cf6bd4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:35:17 +0000 Subject: [PATCH 30/30] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_read.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_read.py b/tests/test_read.py index 0ae60d4..b4f7864 100644 --- a/tests/test_read.py +++ b/tests/test_read.py @@ -117,7 +117,12 @@ def test_header_parse_blank_line(): # if the blank line in the header causes the reader to exit before reading the file # the line looking for the Date in the ctd.from_btl() will throw a ValueError. - btl = ctd.from_btl(data_path.joinpath("btl", "blank_line_header.btl",)) + btl = ctd.from_btl( + data_path.joinpath( + "btl", + "blank_line_header.btl", + ), + ) # if a value error wasn't thrown, ensure the names array for the _metadata was set assert btl._metadata["names"].index("Date")