opendrift.models.openoil.adios.models.common.utilities
Tools for helping make our data models.
So far: making dataclasses read/writable as JSON
Module Contents
Classes
just like a list, but with the ability to turn it into JSON |
Functions
|
much like python's "Truthy" and Falsey", but we want some values |
|
class decorator that adds the ability to save a dataclass as JSON |
- opendrift.models.openoil.adios.models.common.utilities.something(val)[source]
much like python’s “Truthy” and Falsey”, but we want some values to not be false like zero, for instance
- opendrift.models.openoil.adios.models.common.utilities.dataclass_to_json(cls)[source]
class decorator that adds the ability to save a dataclass as JSON
All fields must be either JSON-able Python types or have be a type with a _to_json method
- class opendrift.models.openoil.adios.models.common.utilities.JSON_List[source]
Bases:
list
just like a list, but with the ability to turn it into JSON
A regular list can only be converted to JSON if it has JSON-able objects in it.
Note: must be subclassed, and the item_type attribute set
Initialize self. See help(type(self)) for accurate signature.
- item_type