Skip to content

Commit

Permalink
add uses_complex class attribute and automatic save arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
slevang committed Oct 7, 2024
1 parent 28f82aa commit b445f5e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xeofs/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BaseModel(ABC):
"""

extra_modules = []
uses_complex = False

def __init__(self):
# Define model parameters
Expand Down Expand Up @@ -142,6 +143,9 @@ def save(
if not save_data:
dt = insert_placeholders(dt)

if self.uses_complex and engine == "h5netcdf":
kwargs = {"invalid_netcdf": True} | kwargs

Check warning on line 147 in xeofs/base_model.py

View check run for this annotation

Codecov / codecov/patch

xeofs/base_model.py#L146-L147

Added lines #L146 - L147 were not covered by tests

write_model_tree(dt, path, overwrite=overwrite, engine=engine, **kwargs)

@classmethod
Expand Down
2 changes: 2 additions & 0 deletions xeofs/cross/cpcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,8 @@ class ComplexCPCCA(CPCCA):
"""

uses_complex = True

def __init__(
self,
n_modes: int = 2,
Expand Down
2 changes: 2 additions & 0 deletions xeofs/single/eof.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class ComplexEOF(EOF):
"""

uses_complex = True

def __init__(
self,
n_modes: int = 2,
Expand Down
2 changes: 2 additions & 0 deletions xeofs/single/pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class POP(BaseModelSingleSet):
"""

uses_complex = True

def __init__(
self,
n_modes: int = 2,
Expand Down

0 comments on commit b445f5e

Please sign in to comment.