Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/pymodaq_data/numpy_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,25 @@ def _allclose(dwa_a: 'DataWithAxes', dwa_b: 'DataWithAxes', *args,
*args, **kwargs)) for ind in range(len(dwa_a))])

return dwa


# *************** other numpy function ****************

@implements('flipud')
def _flipud(dwa: 'DataWithAxes', *args, **kwargs):
dwa_func = dwa.deepcopy_with_new_data([np.flipud(data_array) for data_array in dwa])
return dwa_func


@implements('fliplr')
def _fliplr(dwa: 'DataWithAxes', *args, **kwargs):
dwa_func = dwa.deepcopy_with_new_data([np.fliplr(data_array) for data_array in dwa])
return dwa_func


@implements('transpose')
def _transpose(dwa: 'DataWithAxes', *args, **kwargs):
dwa_func = dwa.deepcopy_with_new_data([np.transpose(data_array) for data_array in dwa])
return dwa_func


15 changes: 15 additions & 0 deletions tests/data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,4 +1578,19 @@ def test_all_close(self):

assert not np.allclose(dwa_a, dwa_b * 0.1)

def test_flip_transpose_rotate(self):
dwa = data_mod.DataRaw('raw', units='', data=[DATA2D])

dwa_transform = np.flipud(dwa)
for ind in range(len(dwa)):
assert np.allclose(np.flipud(dwa[ind]), dwa_transform[ind])

dwa_transform = np.fliplr(dwa)
for ind in range(len(dwa)):
assert np.allclose(np.fliplr(dwa[ind]), dwa_transform[ind])

dwa_transform = np.transpose(dwa)
for ind in range(len(dwa)):
assert np.allclose(np.transpose(dwa[ind]), dwa_transform[ind])


Loading