diff --git a/tofu/data/_class08_Diagnostic.py b/tofu/data/_class08_Diagnostic.py index 89788db8c..a8bc488e0 100644 --- a/tofu/data/_class08_Diagnostic.py +++ b/tofu/data/_class08_Diagnostic.py @@ -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, ) \ No newline at end of file diff --git a/tofu/data/_class08_loadfromjson.py b/tofu/data/_class08_loadfromjson.py index 6c5eecd7b..6dfb901d4 100644 --- a/tofu/data/_class08_loadfromjson.py +++ b/tofu/data/_class08_loadfromjson.py @@ -10,6 +10,7 @@ import numpy as np +import datastock as ds # ################################################################# @@ -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, ) # ---------------- @@ -63,7 +66,8 @@ def main( din=dout['diagnostic'], ) - return coll + if returnas is True: + return coll # ################################################################# @@ -75,6 +79,7 @@ def main( def _check( coll=None, pfe=None, + returnas=None, ): # -------------------- @@ -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 # ################################################################# diff --git a/tofu/data/_class08_saveload_from_file.py b/tofu/data/_class08_saveload_from_file.py index 1357a1dd2..959fc84b6 100644 --- a/tofu/data/_class08_saveload_from_file.py +++ b/tofu/data/_class08_saveload_from_file.py @@ -118,6 +118,7 @@ def save( def load( pfe=None, coll=None, + returnas=None, ): # ---------------- @@ -138,6 +139,7 @@ def load( coll=coll, pfe=pfe, fname=fname, + returnas=returnas, )