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 a333a33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
15 changes: 7 additions & 8 deletions src/fmu/dataio/_model/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Timestamp(BaseModel):
being marked and a string label for this timestamp."""

label: Optional[str] = Field(
default=None,
examples=["base", "monitor", "mylabel"],
)
"""A string label corresponding to the timestamp."""
Expand All @@ -46,10 +45,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 +64,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 +304,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
4 changes: 3 additions & 1 deletion src/fmu/dataio/_model/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ class File(BaseModel):
)
"""The path of a file relative to the case root."""

checksum_md5: Optional[str] = Field(examples=["kjhsdfvsdlfk23knerknvk23"])
checksum_md5: Optional[str] = Field(
default=None, examples=["kjhsdfvsdlfk23knerknvk23"]
)
"""A valid MD5 checksum of the file."""

size_bytes: Optional[int] = Field(default=None)
Expand Down
2 changes: 1 addition & 1 deletion 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 Down

0 comments on commit a333a33

Please sign in to comment.