Skip to content

Commit

Permalink
[#981] add_diagnostic_from_file(returnas=bool) implemented, with prop…
Browse files Browse the repository at this point in the history
…er default values
  • Loading branch information
dvezinet committed Oct 26, 2024
1 parent 48a4b55 commit ed7e080
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 7 additions & 3 deletions tofu/data/_class08_Diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,22 +1478,26 @@ def save_diagnostic_to_file(
def add_diagnostic_from_file(
self,
pfe=None,
returnas=False,
):
""" Adds a diagnostic instance (and necessary optics) from json file
Parameters
----------
pfe : str
pfe : str
path/file.ext to desired file
returnas: bool
whether to return the Collection instance
Returns
-------
TYPE
DESCRIPTION.
coll: Collection instance
optional
"""

return _saveload_from_file.load(
coll=self,
pfe=pfe,
returnas=returnas,
)
21 changes: 18 additions & 3 deletions tofu/data/_class08_loadfromjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@


import numpy as np
import datastock as ds


# #################################################################
Expand All @@ -24,15 +25,17 @@ def main(
pfe=None,
coll=None,
fname=None,
returnas=None,
):

# ----------------
# check inputs
# --------------

dout = _check(
dout, returnas = _check(
coll=coll,
pfe=pfe,
returnas=returnas,
)

# ----------------
Expand Down Expand Up @@ -63,7 +66,8 @@ def main(
din=dout['diagnostic'],
)

return coll
if returnas is True:
return coll


# #################################################################
Expand All @@ -75,6 +79,7 @@ def main(
def _check(
coll=None,
pfe=None,
returnas=None,
):

# --------------------
Expand All @@ -99,7 +104,17 @@ def _check(
)
raise Exception(msg)

return dout
# -------------
# returnas
# -------------

returnas = ds._generic_check._check_var(
returnas, 'returnas',
types=bool,
default=True,
)

return dout, returnas


# #################################################################
Expand Down
2 changes: 2 additions & 0 deletions tofu/data/_class08_saveload_from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def save(
def load(
pfe=None,
coll=None,
returnas=None,
):

# ----------------
Expand All @@ -138,6 +139,7 @@ def load(
coll=coll,
pfe=pfe,
fname=fname,
returnas=returnas,
)


Expand Down

0 comments on commit ed7e080

Please sign in to comment.