wright-group / WrightTools

Tools for loading, processing, and plotting multidimensional spectroscopy data.
http://wright.tools
MIT License
17 stars 9 forks source link

Data.smooth: `factors` arg refers to numpy indices, not axes indices #961

Open ddkohler opened 3 years ago

ddkohler commented 3 years ago

excerpt from smooth code: loops through the factors, but never checks how the factors list correspond to the numpy array indices. This can be seen by the transpose_order directly using axes_index to address the values numpy array

        # smooth ----------------------------------------------------------------------------------
        for channel in channels:
            values = channel[:]
            for axis_index in range(len(factors)):
                factor = factors[axis_index]
                # transpose so the axis of interest is last
                transpose_order = range(len(values.shape))
                # replace axis_index with zero
                transpose_order = [
                    len(values.shape) - 1 if i == axis_index else i for i in transpose_order
                ]
                transpose_order[len(values.shape) - 1] = axis_index
                values = values.transpose(transpose_order)
ksunden commented 3 years ago

I believe the behavior is actually as intended, but should be documented as such... smooth is something that inherently works on the underlying array axis level. perhaps it would be better as a method of dataset than of data...