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

silx.gui.plot.StackView: Removed setColormap autoscale argument #3805

Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down
35 changes: 4 additions & 31 deletions src/silx/gui/plot/StackView.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@


sv = StackViewMainWindow()
sv.setColormap("jet", autoscale=True)
sv.setColormap("viridis", vmin=-4, vmax=4)
sv.setStack(mystack)
sv.setLabels(["1st dim (0-99)", "2nd dim (0-199)",
"3rd dim (0-299)"])
Expand Down Expand Up @@ -191,9 +191,6 @@ def __init__(self, parent=None, resetzoom=True, backend=None,
imageLegend = '__StackView__image' + str(id(self))
self._stackItem.setName(imageLegend)

self.__autoscaleCmap = False
"""Flag to disable/enable colormap auto-scaling
based on the min/max values of the entire 3D volume"""
self.__dimensionsLabels = ["Dimension 0", "Dimension 1",
"Dimension 2"]
"""These labels are displayed on the X and Y axes.
Expand Down Expand Up @@ -539,9 +536,6 @@ def setStack(self, stack, perspective=None, reset=True, calibrations=None):
perspective_changed = True
self.setPerspective(perspective)

if self.__autoscaleCmap:
self.scaleColormapRangeToStack()

# init plot
self._stackItem.setStackData(self.__transposed_view, 0, copy=False)
self._stackItem.setColormap(self.getColormap())
Expand Down Expand Up @@ -792,7 +786,7 @@ def scaleColormapRangeToStack(self):
colormap.setVRange(vmin=vmin, vmax=vmax)

def setColormap(self, colormap=None, normalization=None,
autoscale=None, vmin=None, vmax=None, colors=None):
vmin=None, vmax=None, colors=None):
"""Set the colormap and update active image.

Parameters that are not provided are taken from the current colormap.
Expand All @@ -818,13 +812,8 @@ def setColormap(self, colormap=None, normalization=None,
Or a :class`.Colormap` object.
:type colormap: dict or str.
:param str normalization: Colormap mapping: 'linear' or 'log'.
:param bool autoscale: Whether to use autoscale or [vmin, vmax] range.
Default value of autoscale is False. This option is not compatible
with h5py datasets.
:param float vmin: The minimum value of the range to use if
'autoscale' is False.
:param float vmax: The maximum value of the range to use if
'autoscale' is False.
:param float vmin: The minimum value of the range to use.
:param float vmax: The maximum value of the range to use.
:param numpy.ndarray colors: Only used if name is None.
Custom colormap colors as Nx3 or Nx4 RGB or RGBA arrays
"""
Expand All @@ -834,7 +823,6 @@ def setColormap(self, colormap=None, normalization=None,
errmsg = "If colormap is provided as a Colormap object, all other parameters"
errmsg += " must not be specified when calling setColormap"
assert normalization is None, errmsg
assert autoscale is None, errmsg
assert vmin is None, errmsg
assert vmax is None, errmsg
assert colors is None, errmsg
Expand All @@ -860,15 +848,6 @@ def setColormap(self, colormap=None, normalization=None,
vmax=vmax,
colors=colors)

if autoscale is not None:
deprecated_warning(
type_='function',
name='setColormap',
reason='autoscale argument is replaced by a method',
replacement='scaleColormapRangeToStack',
since_version='0.14')
self.__autoscaleCmap = bool(autoscale)

cursorColor = cursorColorForColormap(_colormap.getName())
self._plot.setInteractiveMode('zoom', color=cursorColor)

Expand All @@ -879,12 +858,6 @@ def setColormap(self, colormap=None, normalization=None,
if isinstance(activeImage, items.ColormapMixIn):
activeImage.setColormap(self.getColormap())

if self.__autoscaleCmap:
# scaleColormapRangeToStack needs to be called **after**
# setDefaultColormap so getColormap returns the right colormap
self.scaleColormapRangeToStack()


@deprecated(replacement="getPlotWidget", since_version="0.13")
def getPlot(self):
return self.getPlotWidget()
Expand Down
6 changes: 3 additions & 3 deletions src/silx/gui/plot/test/testStackView.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# /*##########################################################################
#
# Copyright (c) 2016-2020 European Synchrotron Radiation Facility
# Copyright (c) 2016-2023 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -74,7 +74,7 @@ def testScaleColormapRangeToStack(self):

def testSetStack(self):
self.stackview.setStack(self.mystack)
self.stackview.setColormap("viridis", autoscale=True)
self.stackview.setColormap("viridis")
my_trans_stack, params = self.stackview.getStack()
self.assertEqual(my_trans_stack.shape, self.mystack.shape)
self.assertTrue(numpy.array_equal(self.mystack,
Expand Down Expand Up @@ -229,7 +229,7 @@ def tearDown(self):

def testSetStack(self):
self.stackview.setStack(self.mystack)
self.stackview.setColormap("viridis", autoscale=True)
self.stackview.setColormap("viridis")
my_trans_stack, params = self.stackview.getStack()
self.assertEqual(my_trans_stack.shape, self.mystack.shape)
self.assertTrue(numpy.array_equal(self.mystack,
Expand Down