Skip to content

Bug: Energy scan requires hinting during loadRun #193

@PriyankaKetkarBNL

Description

@PriyankaKetkarBNL

Following up from updates made in PR #179. Scan ID 93983 is an energy scan (single image per energy) and loads fine with dims=["energy"] hinted but throws an error without hinting.

scan = loader.loadRun(run=93983).unstack('system')

Error:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
Cell In[10], line 1
----> 1 scan = loader.loadRun(run=93983).unstack('system')
      2 scan

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\PyHyperScattering\SST1RSoXSDB.py:740, in SST1RSoXSDB.loadRun(self, run, dims, coords, return_dataset, useMonitorShutterThinning)
    737     dims_to_join.append(val)
    738     dim_names_to_join.append(key)
--> 740 index = pd.MultiIndex.from_arrays(dims_to_join, names=dim_names_to_join)
    741 # handle the edge case of a partly-finished scan
    742 if len(index) != len(data["time"]):

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\pandas\core\indexes\multi.py:533, in MultiIndex.from_arrays(cls, arrays, sortorder, names)
    530     if len(arrays[i]) != len(arrays[i - 1]):
    531         raise ValueError("all arrays must be same length")
--> 533 codes, levels = factorize_from_iterables(arrays)
    534 if names is lib.no_default:
    535     names = [getattr(arr, "name", None) for arr in arrays]

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\pandas\core\arrays\categorical.py:3069, in factorize_from_iterables(iterables)
   3065 if len(iterables) == 0:
   3066     # For consistency, it should return two empty lists.
   3067     return [], []
-> 3069 codes, categories = zip(*(factorize_from_iterable(it) for it in iterables))
   3070 return list(codes), list(categories)

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\pandas\core\arrays\categorical.py:3069, in <genexpr>(.0)
   3065 if len(iterables) == 0:
   3066     # For consistency, it should return two empty lists.
   3067     return [], []
-> 3069 codes, categories = zip(*(factorize_from_iterable(it) for it in iterables))
   3070 return list(codes), list(categories)

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\pandas\core\arrays\categorical.py:3042, in factorize_from_iterable(values)
   3037     codes = values.codes
   3038 else:
   3039     # The value of ordered is irrelevant since we don't use cat as such,
   3040     # but only the resulting categories, the order of which is independent
   3041     # from ordered. Set ordered to False as default. See GH #15457
-> 3042     cat = Categorical(values, ordered=False)
   3043     categories = cat.categories
   3044     codes = cat.codes

File ~\Anaconda3\envs\20250331_1\Lib\site-packages\pandas\core\arrays\categorical.py:425, in Categorical.__init__(self, values, categories, ordered, dtype, fastpath, copy)
    422 elif isinstance(values, np.ndarray):
    423     if values.ndim > 1:
    424         # preempt sanitize_array from raising ValueError
--> 425         raise NotImplementedError(
    426             "> 1 ndim Categorical are not supported at this time"
    427         )
    428     values = sanitize_array(values, None)
    429 else:
    430     # i.e. must be a list

NotImplementedError: > 1 ndim Categorical are not supported at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions