Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use numpy >=1.20 #70

Merged
merged 9 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/keeping-your-actions-up-to-date-with-dependabot

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "Bot"
84 changes: 0 additions & 84 deletions .github/workflows/push.yml

This file was deleted.

18 changes: 11 additions & 7 deletions .github/workflows/publish.yml → .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@
name: Publish to PyPI

on:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:

pypi-build:
packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.x
python-version: "3.10"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot use latest Python until we resolve the netcdf4<1.6.1 pin.


- name: Get tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
Expand All @@ -37,12 +40,13 @@ jobs:

- name: Test wheels
run: |
cd dist && python -m pip install pocean_core*.whl
cd dist && python -m pip install *.whl
python -m twine check *
shell: bash

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
if: success() && github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
38 changes: 38 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests

on:
pull_request:
push:
branches: [main]

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Micromamba
uses: mamba-org/provision-with-micromamba@v15
with:
environment-file: false

- name: Python ${{ matrix.python-version }}
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 --disable-warnings
2 changes: 1 addition & 1 deletion pocean/dsg/timeseriesProfile/r.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def from_dataframe(cls, df, output, **kwargs):
profile[j] = pname
row_size[j] = len(pfg)
if s_ind is not None:
s_ind[j] = np.asscalar(np.argwhere(station[:] == pfg[axes.station].dropna().iloc[0]))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numpy depreaction fix.

s_ind[j] = np.argwhere(station[:] == pfg[axes.station].dropna().iloc[0]).item()

# Add back in the z axes that was removed when calculating data_columns
# and ignore variables that were stored in the profile index
Expand Down
3 changes: 3 additions & 0 deletions pocean/dsg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def get_geographic_attributes(df, axes=None):

if len(set(coords)) == 1:
geoclass = Point
# The set is to workaround the fact tht pocean
# relied in a shapely<2 bug to pass a vector here instead of a point.
coords = set(coords)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you want to leave this as-is or to re-write it but it was relying on a bad behavior before. One cannot pass 4 coords to a Point class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Shapely 2.0 release notes:

The Point(..) constructor no longer accepts a sequence of coordinates consisting of more than one coordinate pair (previously, subsequent coordinates were ignored) (#1600).

elif len(coords) > 2:
geoclass = Polygon
else:
Expand Down
2 changes: 1 addition & 1 deletion pocean/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def create_ncvar_from_series(ncd, var_name, dimensions, series, **kwargs):
elif series.dtype.kind in ['U', 'S'] or series.dtype in [str]:
# AttributeError: cannot set _FillValue attribute for VLEN or compound variable
v = ncd.createVariable(var_name, get_dtype(series), dimensions, **kwargs)
elif series.dtype == np.object:
elif series.dtype == object:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Numpy deprecation.

# Try to downcast to an int and then just take the type of the result
# If we can't convert to a numeric use a string
try:
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cftime>=1.2.1
netcdf4
numpy>=1.15
netcdf4<1.6.1
numpy>=1.20
pandas>=1.0.5
python-dateutil
pytz
shapely
shapely>=2
simplejson
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ classifiers =
packages = find:
install_requires =
cftime>=1.2.1
netcdf4
numpy>=1.15
netcdf4<1.6.1
Copy link
Member Author

@ocefpaf ocefpaf Mar 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pin will hurt us when trying to install pocean in modern envs.
I was unable to fix the failing tests without it. Iris wrote a whole new class to solve that. I was hoping for an easier solution here :-/

numpy>=1.20
pandas>=1.0.5
python-dateutil
pytz
shapely
shapely>=2
simplejson
tests_require =
pytest
Expand Down