Skip to content

Commit

Permalink
Use the latest greatest Python deps (#1618)
Browse files Browse the repository at this point in the history
Fixes #1573

This only fixes us to the first version of pandera that supports numpy
2, the rest should follow automatically.

I took longer than I want to admit to find that the previous `[None, 1]`
is now silently coerced to `[0,1]` and therefore passed validation, and
failed the test.

I also (still?) see
```
tests/test_model.py::test_xugrid[model0]
  <frozen importlib._bootstrap>:488: RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 16 from C header, got 96 from PyObject
```

Which is probably due to xugrid/netcdf/meshkernel(?) using something
compiled against a different numpy version.

---------

Co-authored-by: Martijn Visser <[email protected]>
  • Loading branch information
evetion and visr authored Jul 9, 2024
1 parent aae4f71 commit 08c6856
Show file tree
Hide file tree
Showing 6 changed files with 11,008 additions and 10,595 deletions.
21,586 changes: 10,998 additions & 10,588 deletions pixi.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test-ribasim-api = "pytest --basetemp=python/ribasim_api/tests/temp --junitxml=r

[feature.dev.tasks]
# Installation
install-julia = "juliaup add 1.10.4 && juliaup override set 1.10.4"
install-julia = "juliaup add 1.10.4 && juliaup override unset && juliaup override set 1.10.4"
install-pre-commit = "pre-commit install"
install-ci = { depends_on = ["install-julia", "update-registry-julia"] }
install = { depends_on = [
Expand Down Expand Up @@ -156,9 +156,9 @@ netCDF4 = "*"
numpy = "*"
pandas = "*"
pandas-stubs = "*"
pandera = ">=0.18"
pandera = ">=0.20"
pip = "*"
pyarrow = "<15"
pyarrow = "*"
pydantic = ">=2"
pyogrio = "*"
pytest = "*"
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies = [
"matplotlib",
"numpy",
"pandas",
"pandera >= 0.18",
"pandera >= 0.20",
"pyarrow",
"pydantic ~= 2.0",
"pyogrio",
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/geometry/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class NodeData(NamedTuple):
geometry: Point


class EdgeSchema(pa.SchemaModel):
class EdgeSchema(pa.DataFrameModel):
name: Series[str] = pa.Field(default="")
from_node_type: Series[str] = pa.Field(nullable=True)
from_node_id: Series[Int32] = pa.Field(default=0, coerce=True)
Expand Down
2 changes: 1 addition & 1 deletion python/ribasim/ribasim/geometry/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
__all__ = ("NodeTable",)


class NodeSchema(pa.SchemaModel):
class NodeSchema(pa.DataFrameModel):
node_id: Series[Int32] = pa.Field(ge=0)
name: Series[str] = pa.Field(default="")
node_type: Series[str] = pa.Field(default="")
Expand Down
5 changes: 4 additions & 1 deletion python/ribasim/tests/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def test_validation(edge):

with pytest.raises(ValidationError):
df = gpd.GeoDataFrame(
data={"from_node_id": [1, 1], "to_node_id": [None, 3]},
data={
"from_node_id": [1, 1],
"to_node_id": ["foo", 3],
}, # None is coerced to 0 without errors
geometry=[None, None],
)
EdgeTable(df=df)
Expand Down

0 comments on commit 08c6856

Please sign in to comment.