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

Schemas: Only set default value for node_id not for all integer columns #1392

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 10 additions & 10 deletions python/ribasim/ribasim/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BasinStaticSchema(_BaseSchema):


class BasinSubgridSchema(_BaseSchema):
subgrid_id: Series[Int32] = pa.Field(nullable=False, default=0)
subgrid_id: Series[Int32] = pa.Field(nullable=False)
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
basin_level: Series[float] = pa.Field(nullable=False)
subgrid_level: Series[float] = pa.Field(nullable=False)
Expand All @@ -51,7 +51,7 @@ class BasinTimeSchema(_BaseSchema):
class DiscreteControlConditionSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
listen_node_type: Series[str] = pa.Field(nullable=False)
listen_node_id: Series[Int32] = pa.Field(nullable=False, default=0)
listen_node_id: Series[Int32] = pa.Field(nullable=False)
variable: Series[str] = pa.Field(nullable=False)
greater_than: Series[float] = pa.Field(nullable=False)
look_ahead: Series[float] = pa.Field(nullable=True)
Expand All @@ -78,14 +78,14 @@ class FlowBoundaryTimeSchema(_BaseSchema):
class FlowDemandStaticSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
demand: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)


class FlowDemandTimeSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
time: Series[Timestamp] = pa.Field(nullable=False)
demand: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)


class FractionalFlowStaticSchema(_BaseSchema):
Expand All @@ -110,15 +110,15 @@ class LevelDemandStaticSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
min_level: Series[float] = pa.Field(nullable=False)
max_level: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)


class LevelDemandTimeSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
time: Series[Timestamp] = pa.Field(nullable=False)
min_level: Series[float] = pa.Field(nullable=False)
max_level: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)


class LinearResistanceStaticSchema(_BaseSchema):
Expand Down Expand Up @@ -153,7 +153,7 @@ class PidControlStaticSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
active: Series[pa.BOOL] = pa.Field(nullable=True)
listen_node_type: Series[str] = pa.Field(nullable=False)
listen_node_id: Series[Int32] = pa.Field(nullable=False, default=0)
listen_node_id: Series[Int32] = pa.Field(nullable=False)
target: Series[float] = pa.Field(nullable=False)
proportional: Series[float] = pa.Field(nullable=False)
integral: Series[float] = pa.Field(nullable=False)
Expand All @@ -164,7 +164,7 @@ class PidControlStaticSchema(_BaseSchema):
class PidControlTimeSchema(_BaseSchema):
node_id: Series[Int32] = pa.Field(nullable=False, default=0)
listen_node_type: Series[str] = pa.Field(nullable=False)
listen_node_id: Series[Int32] = pa.Field(nullable=False, default=0)
listen_node_id: Series[Int32] = pa.Field(nullable=False)
time: Series[Timestamp] = pa.Field(nullable=False)
target: Series[float] = pa.Field(nullable=False)
proportional: Series[float] = pa.Field(nullable=False)
Expand Down Expand Up @@ -207,7 +207,7 @@ class UserDemandStaticSchema(_BaseSchema):
demand: Series[float] = pa.Field(nullable=False)
return_factor: Series[float] = pa.Field(nullable=False)
min_level: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)


class UserDemandTimeSchema(_BaseSchema):
Expand All @@ -216,4 +216,4 @@ class UserDemandTimeSchema(_BaseSchema):
demand: Series[float] = pa.Field(nullable=False)
return_factor: Series[float] = pa.Field(nullable=False)
min_level: Series[float] = pa.Field(nullable=False)
priority: Series[Int32] = pa.Field(nullable=False, default=0)
priority: Series[Int32] = pa.Field(nullable=False)
2 changes: 1 addition & 1 deletion utils/templates/schemas.py.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class _BaseSchema(pa.DataFrameModel):
{% for m in models %}
class {{m[:name]}}Schema(_BaseSchema):
{% for f in m[:fields] %}
{% if (f[2] == "Series[Int32]") %}
{% if (f[1] == :node_id) %}
{{ f[1] }}: {{ f[2] }} = pa.Field(nullable={{ f[3] }}, default=0)
{% else %}
{{ f[1] }}: {{ f[2] }} = pa.Field(nullable={{ f[3] }})
Expand Down
Loading