Skip to content

Commit

Permalink
[#159] clean-up 5
Browse files Browse the repository at this point in the history
  • Loading branch information
dvezinet committed Nov 14, 2024
1 parent f6563c8 commit 473a9b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
6 changes: 2 additions & 4 deletions datastock/_class04_plot_as_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from . import _generic_check
from . import _class01_compute
from . import _generic_utils_plot as _uplot
from . import _class04_plot_as_array_1d as _plot_as_array_1d
from . import _class04_plot_as_array_1d as _plot_as_array_1d
from . import _class04_plot_as_array_234d as _plot_as_array_234d


Expand Down Expand Up @@ -126,8 +126,7 @@ def plot_as_array(
# --------------------------------

if sameref:
from ._class import DataStock
cc = DataStock()
cc = coll.__class__()
lk = ['keyX', 'keyY', 'keyZ', 'keyU']
lk = [k0 for k0 in lk if dkeys[k0]['ref'] is not None]
for ii, k0 in enumerate(lk):
Expand Down Expand Up @@ -603,7 +602,6 @@ def _check(
else:
dvminmax2[k1]['min'] = dvminmax[kk]['min']


if dvminmax is None or dvminmax.get(kk, {}).get('max') is None:
dvminmax2[k1]['max'] = nanmax + margin
else:
Expand Down
25 changes: 17 additions & 8 deletions datastock/_saveload.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def load(

# cls
if cls is None:
from ._class import DataStock
cls = DataStock
from ._class04_Plots import Plots as Collection
cls = Collection

if not (type(cls) is type and hasattr(cls, 'from_dict')):
msg = (
Expand Down Expand Up @@ -168,6 +168,10 @@ def load(
# ----------
# reshape

# sparse types
lsparse = ['csc_', 'bsr_', 'coo_', 'csr_', 'dia_', 'dok_', 'lil_']

# loop
dout = {}
for k0, v0 in dflat.items():

Expand Down Expand Up @@ -201,7 +205,7 @@ def load(
dout[k0] = None
elif typ == 'ndarray':
dout[k0] = dflat[k0]
elif any([ss in typ for ss in ['csc_', 'bsr_', 'coo_', 'csr_', 'dia_', 'dok_', 'lil_']]):
elif any([ss in typ for ss in lsparse]):
assert typ in type(dflat[k0]).__name__
dout[k0] = dflat[k0]
elif 'Unit' in typ:
Expand Down Expand Up @@ -276,8 +280,10 @@ def get_files(

lc = [
isinstance(dpfe, (str, tuple)),
isinstance(dpfe, list) and all([isinstance(pp, (str, tuple)) for pp in dpfe]),
isinstance(dpfe, dict) and all([isinstance(pp, str) for pp in dpfe.keys()])
isinstance(dpfe, list)
and all([isinstance(pp, (str, tuple)) for pp in dpfe]),
isinstance(dpfe, dict)
and all([isinstance(pp, str) for pp in dpfe.keys()])
]

if not any(lc):
Expand All @@ -288,7 +294,7 @@ def get_files(
"\t\tkeys = valid path str\n"
"\t\tvalues =\n"
"\t\t\t- str: valid file names in the associated path\n"
"\t\t\t- str: pattern to be found in the files names in that path\n"
"\t\t\t- str: pattern to be found in the files names in path\n"
"\t\t\t- list of str: list of the above (file names or patterns)\n"
)
raise Exception(msg)
Expand Down Expand Up @@ -406,7 +412,10 @@ def _get_files_from_path(

lc = [
any([os.path.isfile(pfe) for pfe in lpfe if isinstance(pfe, str)]),
any([os.path.isfile(os.path.join(path, pfe)) for pfe in lpfe if isinstance(pfe, str)]),
any([
os.path.isfile(os.path.join(path, pfe))
for pfe in lpfe if isinstance(pfe, str)
]),
]

# ---------------------
Expand Down Expand Up @@ -469,4 +478,4 @@ def _get_files_from_path(
else:
warnings.warn(msg)

return out
return out

0 comments on commit 473a9b0

Please sign in to comment.