Skip to content

Commit

Permalink
FIX: Give Optionals a default value
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Sep 26, 2024
1 parent a26bac7 commit b2d2801
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions schema/definitions/0.8.0/schema/fmu_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -5499,7 +5499,6 @@
}
},
"required": [
"attributes",
"size"
],
"title": "PointSpecification",
Expand Down Expand Up @@ -7792,6 +7791,7 @@
"type": "null"
}
],
"default": null,
"examples": [
1,
9999
Expand All @@ -7807,6 +7807,7 @@
"type": "null"
}
],
"default": null,
"examples": [
1,
9999
Expand All @@ -7824,8 +7825,6 @@
},
"required": [
"columns",
"num_columns",
"num_rows",
"size"
],
"title": "TableSpecification",
Expand Down
14 changes: 7 additions & 7 deletions src/fmu/dataio/_model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class Time(BaseModel):
.. note:: ``data.time`` items can currently hold a maximum of two values."""

t0: Optional[Timestamp] = None
t0: Optional[Timestamp] = Field(default=None)
"""The first timestamp. See :class:`Timestamp`."""

t1: Optional[Timestamp] = None
t1: Optional[Timestamp] = Field(default=None)
"""The second timestamp. See :class:`Timestamp`."""


Expand All @@ -65,16 +65,16 @@ class Seismic(BaseModel):
calculation: Optional[str] = Field(default=None, examples=["mean"])
"""The type of calculation applied."""

filter_size: Optional[float] = Field(allow_inf_nan=False, default=None)
filter_size: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The filter size applied."""

scaling_factor: Optional[float] = Field(allow_inf_nan=False, default=None)
scaling_factor: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The scaling factor applied."""

stacking_offset: Optional[str] = Field(default=None, examples=["0-15"])
"""The stacking offset applied."""

zrange: Optional[float] = Field(allow_inf_nan=False, default=None)
zrange: Optional[float] = Field(default=None, allow_inf_nan=False)
"""The z-range of these data."""


Expand Down Expand Up @@ -305,13 +305,13 @@ class Data(BaseModel):
"""Column names in the table which can be used for indexing. Only applicable if the
data object is a table."""

base: Optional[Layer] = None
base: Optional[Layer] = Field(default=None)
"""If the data represent an interval, this field can be used to represent its base.
See :class:`Layer`.
.. note:: ``top`` is required to use with this."""

top: Optional[Layer] = None
top: Optional[Layer] = Field(default=None)
"""If the data represent an interval, this field can be used to represent its top.
See :class:`Layer`.
Expand Down
6 changes: 3 additions & 3 deletions src/fmu/dataio/_model/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SurfaceSpecification(RowColumn):
class PointSpecification(BaseModel):
"""Specifies relevant values describing an xyz points object."""

attributes: Optional[List[str]]
attributes: Optional[List[str]] = Field(default_factory=list)
"""List of columns present in a table."""

size: int = Field(examples=[1, 9999])
Expand All @@ -65,10 +65,10 @@ class TableSpecification(BaseModel):
columns: List[str]
"""List of columns present in a table."""

num_columns: Optional[int] = Field(examples=[1, 9999])
num_columns: Optional[int] = Field(default=None, examples=[1, 9999])
"""The number of columns in a table."""

num_rows: Optional[int] = Field(examples=[1, 9999])
num_rows: Optional[int] = Field(default=None, examples=[1, 9999])
"""The number of rows in a table.."""

size: int = Field(examples=[1, 9999])
Expand Down

0 comments on commit b2d2801

Please sign in to comment.