Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with show2D and 3D DataContainers #1539

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

* x.x.x
- Fix show2D bug for 3D DataContainers

* 23.1.0
- Fix bug in IndicatorBox proximal_conjugate
- Allow CCPi Regulariser functions for non CIL object
Expand Down
4 changes: 2 additions & 2 deletions Wrappers/Python/cil/framework/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -2771,9 +2771,9 @@ def as_array(self):
return self.array


def get_slice(self,**kw):
def get_slice(self, **kw):
'''
Returns a new DataContainer containing a single slice of in the requested direction. \
Returns a new DataContainer containing a single slice in the requested direction. \
Pass keyword arguments <dimension label>=index
'''
new_array = None
Expand Down
14 changes: 10 additions & 4 deletions Wrappers/Python/cil/utilities/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class show2D(show_base):

Plots 1 or more 2D plots in an (n x num_cols) matrix.
Can plot multiple slices from one 3D dataset, or compare multiple datasets
Inputs can be single arguments or list of arguments that will be sequentally applied to subplots
Inputs can be single arguments or list of arguments that will be sequentially applied to subplots
If no slice_list is passed a 3D dataset will display the centre slice of the outer dimension, a 4D dataset will show the centre slices of the two outer dimension.


Expand All @@ -392,7 +392,7 @@ class show2D(show_base):
The title for each figure
slice_list: tuple, int, list of tuples, list of ints, optional
The slices to show. A list of integers will show slices for the outer dimension. For 3D datacontainers single slice: (direction, index). For 4D datacontainers two slices: [(direction0, index),(direction1, index)].
fix_range: boolian, tuple, list of tuples
fix_range: boolean, tuple, list of tuples
Sets the display range of the data. `True` sets all plots to the global (min, max).
axis_labels: tuple, list of tuples, optional
The axis labels for each figure e.g. ('x','y')
Expand Down Expand Up @@ -497,7 +497,10 @@ def __show2D(self,datacontainers, title=None, slice_list=None, fix_range=False,
cut_axis[1] = data.dimension_labels[cut_axis[1]]

temp_dict = {cut_axis[0]:cut_slices[0], cut_axis[1]:cut_slices[1]}
plot_data = data.get_slice(**temp_dict, force=True)
if type(data) == DataContainer:
plot_data = data.get_slice(**temp_dict)
lauramurgatroyd marked this conversation as resolved.
Show resolved Hide resolved
else:
plot_data = data.get_slice(**temp_dict, force=True)
elif hasattr(data,'as_array'):
plot_data = data.as_array().take(indices=cut_slices[1], axis=cut_axis[1])
plot_data = plot_data.take(indices=cut_slices[0], axis=cut_axis[0])
Expand Down Expand Up @@ -535,7 +538,10 @@ def __show2D(self,datacontainers, title=None, slice_list=None, fix_range=False,
if type(cut_axis) is int:
cut_axis = data.dimension_labels[cut_axis]
temp_dict = {cut_axis:cut_slice}
plot_data = data.get_slice(**temp_dict, force=True)
if type(data) == DataContainer:
plot_data = data.get_slice(**temp_dict)
else:
plot_data = data.get_slice(**temp_dict, force=True)
elif hasattr(data,'as_array'):
plot_data = data.as_array().take(indices=cut_slice, axis=cut_axis)
else:
Expand Down