pyUSID icon indicating copy to clipboard operation
pyUSID copied to clipboard

reshape to ndims fails

Open ramav87 opened this issue 2 years ago • 0 comments

Reshape to ndims fails when there is only a single point:

Position dimensions: ['X' 'Y']
Position sort order: [0]
Spectroscopic Dimensions: ['DC_Offset' 'Field' 'Cycle']
Spectroscopic sort order: [1 0 2]

Position dimensions (sort applied): ['X']
Position dimensionality (sort applied): [1]
Spectroscopic dimensions (sort applied): ['Field' 'DC_Offset' 'Cycle']
Spectroscopic dimensionality (sort applied): [2, 32, 10]
Will attempt to reshape main dataset from:
(1, 640) to [1, 10, 32, 2]

After reshaping, labels are ['X' 'Cycle' 'DC_Offset' 'Field']
Data shape is (1, 10, 32, 2)

Going to put dimensions back in the same order as in the file:
Axes will permuted in this order: [array(0, dtype=int64) array([], dtype=int64) array(2, dtype=int64)
 array(3, dtype=int64) array(1, dtype=int64)]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_13144/3910722362.py in <module>
      2 sho_spec_labels = h5_sho_fit.spec_dim_labels
      3 
----> 4 (Nd_mat, success, nd_labels) = usid.hdf_utils.reshape_to_n_dims(h5_sho_fit, get_labels=True, verbose=True)
      5 print('Reshape Success: ' + str(success))
      6 

~\Anaconda3\lib\site-packages\pyUSID\io\hdf_utils\model.py in reshape_to_n_dims(h5_main, h5_pos, h5_spec, get_labels, verbose, sort_dims, lazy)
    272     if verbose:
    273         print('Axes will permuted in this order:', swap_axes)
--> 274         print('New labels ordering:', all_labels[swap_axes])
    275 
    276     ds_Nd = ds_Nd.transpose(tuple(swap_axes))

IndexError: arrays used as indices must be of integer (or boolean) type

ramav87 avatar Nov 01 '22 16:11 ramav87