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

fix overflow errors numpy v2 #51

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SCM syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
26 changes: 10 additions & 16 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
- uses: prefix-dev/setup-pixi@v0.8.1
with:
python-version: '3.11'
miniforge-variant: Mambaforge
miniforge-version: latest
use-mamba: true

- name: Setup env
run: |
python make_env.py full -p 3.11 -n pyflwdir -o environment-doc.yml
mamba env create -f environment-doc.yml
mamba run -n pyflwdir pip install -e .
pixi-version: "v0.39.2"
environments: default
locked: false
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

# if we're not publishing we don't have to write them, so we might as well
# save ourself a bunch of IO time
- name: Build dummy docs
if: ${{ github.event_name == 'pull_request' }}
run: |
mamba run -n pyflwdir sphinx-build ./docs ./docs/_build -b dummy -W
pixi run docs-dummy

- name: Build html docs
if: ${{ github.event_name != 'pull_request' }}
run: |
mamba run -n pyflwdir sphinx-build -M html ./docs ./docs/_build -W
echo "DOC_VERSION=$(mamba run -n pyflwdir python -c 'from pyflwdir import __version__ as v; print("dev" if "dev" in v else "v"+v)')" >> $GITHUB_ENV
pixi run docs-html
echo "DOC_VERSION=$(pixi run version)" >> $GITHUB_ENV

- name: Upload to GitHub Pages
if: ${{ github.event_name != 'pull_request'}}
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/test_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,19 @@ jobs:
cancel-in-progress: true
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: pip
- uses: prefix-dev/setup-pixi@v0.8.1
with:
# caching, see https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
python-version: '3.11'
cache: 'pip'
cache-dependency-path: pyproject.toml

# true if cache-hit occurred on the primary key
- name: Cache hit
run: echo '${{ steps.pip.outputs.cache-hit }}'

# build environment with pip
- name: Install pyflwdir
run: |
pip install --upgrade pip
pip install .[test]
pip list
pixi-version: "v0.39.2"
environments: test-py312
locked: false
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

# run test
- name: Test
run: |
export NUMBA_DISABLE_JIT=1
python -m pytest --verbose --cov=pyflwdir --cov-report xml
run: pixi run -e test-py312 test-cov-xml

# upload coverage
- uses: codecov/codecov-action@v3
33 changes: 9 additions & 24 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,24 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ['3.9', '3.10','3.11']
python-version: ['39', '310','311', '312']
runs-on: ubuntu-latest
timeout-minutes: 30
concurrency:
group: ${{ github.workflow }}-${{ matrix.python-version }}-${{ github.ref }}
cancel-in-progress: true
steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: pip
- uses: prefix-dev/setup-pixi@v0.8.1
with:
# caching, see https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#caching-packages
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: pyproject.toml

# true if cache-hit occurred on the primary key
- name: Cache hit
run: echo '${{ steps.pip.outputs.cache-hit }}'

# build environment with pip
- name: Install pyflwdir
run: |
pip install --upgrade pip
pip install .[test]
pip list
pixi-version: "v0.39.2"
environments: test-py${{ matrix.python-version }}
locked: false
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}

# run test
- name: Test
run: |
python -m pytest --verbose --cov=pyflwdir --cov-report xml

# upload coverage
- uses: codecov/codecov-action@v3
run: pixi run -e test-py${{ matrix.python-version }} test
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ venv.bak/
.spyderproject
.spyproject

# VScode
.vscode

# PyCharm
.idea

Expand All @@ -128,4 +125,7 @@ _pyflwdir
scripts

pyflwdir*.yml
pixi.lock

# pixi environments
.pixi
*.egg-info
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ repos:
- id: check-yaml
- id: check-added-large-files
- id: check-ast
- id: check-json
- id: debug-statements
- id: mixed-line-ending
# make sure notebooks are stripped of output before committing
Expand Down
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Python Debugger: Current File with Arguments",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"args": [
"${command:pickArgs}"
],
"env": {"NUMBA_DISABLE_JIT": "1"},

}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ Change Log
in development
**************

0.6.0 (19-12-2024)
********************
* Fixed numpy 2.0 compatibility issues
* Fixed bug in strahler stream order method when more than two streams meet.
* Fixed support for interger type DEMs in `from_dem` and `dem.fill_depressions` methods
* Add support for py 3.12
* Add support for pixi

0.5.8 (06-Oct-2023)
********************
Expand Down
47 changes: 17 additions & 30 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,70 +108,56 @@ First, clone pyflwdir's ``git`` repo and navigate into the repository:
$ git clone git@github.com:Deltares/pyflwdir.git
$ cd pyflwdir

Then, make and activate a new pyflwdir conda environment based on the environment.yml
file contained in the repository:
Install pixi from `pixi.sh <pixi.sh>`__ to manage the development environment.
To install the package in development mode, use the following command:

.. code-block:: console

$ conda env create -f envs/pyflwdir-dev.yml
$ conda activate pyflwdir-dev
$ pixi install
$ pixi run install-pre-commit

Finally, build and install PyFlwDir:

.. code-block:: console

$ pip install -e .
This will install the package in development mode and install the required dependencies.

Running the tests
^^^^^^^^^^^^^^^^^

PyFlwDir's tests live in the tests folder and generally match the main package layout.
Test should be run from the tests folder.

Note that to get a coverage report we need to disable numba jit. This can be done
by setting the environment variable ``NUMBA_DISABLE_JIT=1``, see
`numba docs <https://numba.pydata.org/numba-doc/dev/reference/envvars.html#envvar-NUMBA_DISABLE_JIT>`_

To run the entire suite and the code coverage report.
To run the tests, use the following command:

.. code-block:: console

$ python -m pytest --verbose --cov=pyflwdir --cov-report term-missing
$ pixi run test

To run the tests with coverage, numba needs to be disabled.
This is done by setting the environment variable NUMBA_DISABLE_JIT to 1.
These arguments are combined in the following command:

.. code-block:: console

$ python -m pytest --verbose --cov=pyflwdir --cov-report term-missing
$ pixi run test-cov

A single test file:

.. code-block:: console

$ python -m pytest --verbose test_pyflwdir.py
$ pixi run python -m pytest --verbose test_pyflwdir.py

A single test:

.. code-block:: console

$ python -m pytest --verbose test_pyflwdir.py::test_save
$ pixi run python -m pytest --verbose test_pyflwdir.py::test_save

Running code format checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

The code formatting will be checked based on the `black clode style
<https://black.readthedocs.io/en/stable/the_black_code_style.html>`__ during ci.
Make sure the check below returns *All done!* before commiting your edits.

To check the formatting of your code:

.. code-block:: console

$ black --check .

To automatically reformat your code:

.. code-block:: console

$ black .
$ pixi run lint

Creating a release
^^^^^^^^^^^^^^^^^^
Expand All @@ -188,7 +174,8 @@ Creating a release

.. code-block:: console

$ python setup.py sdist bdist_wheel
$ flit build
$ python -m twine check dist/*

4. Then use twine to upload our wheels to pypi. It will prompt you for your username and password.

Expand Down
27 changes: 13 additions & 14 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name: pyflwdir

channels:
- conda-forge
- conda-forge

# note that these are the developer dependencies,
# if you only want the user dependencies, see
# install_requires in setup.py
dependencies:
# required
- python>=3.9
- pyflwdir
# optional for notebooks
- cartopy>=0.20
- descartes
- geopandas>=0.8
- jupyter
- matplotlib
- rasterio
- affine
- cartopy>=0.20
- descartes
- geopandas>0.8
- jupyter
- matplotlib
- numba>=0.54,<1.0
- numpy
- pandoc
- python~=3.12.0
- rasterio
- scipy
9 changes: 2 additions & 7 deletions examples/basins.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.10.5 ('hydromt-dev')",
"display_name": "default",
"language": "python",
"name": "python3"
},
Expand All @@ -267,12 +267,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.5"
},
"vscode": {
"interpreter": {
"hash": "3808d5b5b54949c7a0a707a38b0a689040fa9c90ab139a050e41373880719ab1"
}
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down
11 changes: 5 additions & 6 deletions examples/streams.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
"source": [
"# vectorize stream order for plotting\n",
"feats = flw.streams(stream_mask, strord=strahler)\n",
"gdf = gpd.GeoDataFrame.from_features(feats, crs=crs)"
"gdf = gpd.GeoDataFrame.from_features(feats, crs=crs)\n",
"gdf.to_file(\"rhine_strahler.geojson\", driver=\"GeoJSON\")"
]
},
{
Expand Down Expand Up @@ -171,11 +172,9 @@
}
],
"metadata": {
"interpreter": {
"hash": "1d6565df54f631b3318aa7a4d6d8532e5ca49bf98056c57553f6cb4464998323"
},
"kernelspec": {
"display_name": "Python 3.9.7 64-bit ('pyflwdir': conda)",
"display_name": "default",
"language": "python",
"name": "python3"
},
"language_info": {
Expand All @@ -188,7 +187,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.11.11"
}
},
"nbformat": 4,
Expand Down
Loading
Loading