anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: silx-kit/silx
Issue: [profile] won't show the profile window

Under windows PC.
When I launch the silx view and display some dataset using the `Image` and `Image stack` views :
- if I am on full screen mode the profile window won't appear (and won't be launched, I can't see them)
But if I am not on the full screen mode then It work ??? !!!
- if not on full screen mode work perfectly.

Don't know where the issue is (profile window, viewer or somewhere in the middle).


Changed files:
silx/gui/plot/Profile.py

diff --git a/silx/gui/plot/Profile.py b/silx/gui/plot/Profile.py
index ff856951c..3b17f488f 100644
--- a/silx/gui/plot/Profile.py
+++ b/silx/gui/plot/Profile.py
@@ -653,23 +653,23 @@ class ProfileToolBar(qt.QToolBar):
             winGeom = self.window().frameGeometry()
             qapp = qt.QApplication.instance()
             screenGeom = qapp.desktop().availableGeometry(self)
-
             spaceOnLeftSide = winGeom.left()
             spaceOnRightSide = screenGeom.width() - winGeom.right()
 
             profileWindowWidth = profileMainWindow.frameGeometry().width()
-            if (profileWindowWidth < spaceOnRightSide or
-                    spaceOnRightSide > spaceOnLeftSide):
+            if (profileWindowWidth < spaceOnRightSide):
                 # Place profile on the right
                 profileMainWindow.move(winGeom.right(), winGeom.top())
-            else:
-                # Not enough place on the right, place profile on the left
+            elif(profileWindowWidth < spaceOnLeftSide):
+                # Place profile on the left
                 profileMainWindow.move(
-                        max(0, winGeom.left() - profileWindowWidth), winGeom.top())
+                    max(0, winGeom.left() - profileWindowWidth), winGeom.top())
 
             profileMainWindow.show()
+            profileMainWindow.raise_()
         else:
             self.getProfilePlot().show()
+            self.getProfilePlot().raise_()
 
     def hideProfileWindow(self):
         """Hide profile window.
Repository: silx-kit/silx
Issue: [plot3d] Display issue with silx view

On macOS with python3.5 and Qt 5.9 with six view, the 3D view has the previous widget in the background. This is visible with transparent isosurface

Changed files:
silx/gui/plot/backends/BackendOpenGL.py, silx/gui/plot3d/scene/window.py

diff --git a/silx/gui/plot/backends/BackendOpenGL.py b/silx/gui/plot/backends/BackendOpenGL.py
index f482d3e52..31db02cd3 100644
--- a/silx/gui/plot/backends/BackendOpenGL.py
+++ b/silx/gui/plot/backends/BackendOpenGL.py
@@ -300,6 +300,7 @@ _texFragShd = """
 
     void main(void) {
         gl_FragColor = texture2D(tex, coords);
+        gl_FragColor.a = 1.0;
     }
     """
 
@@ -437,7 +438,7 @@ class BackendOpenGL(BackendBase.BackendBase, glu.OpenGLWidget):
 
     @staticmethod
     def _setBlendFuncGL():
-        # glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
+        # gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
         gl.glBlendFuncSeparate(gl.GL_SRC_ALPHA,
                                gl.GL_ONE_MINUS_SRC_ALPHA,
                                gl.GL_ONE,
diff --git a/silx/gui/plot3d/scene/window.py b/silx/gui/plot3d/scene/window.py
index 64bd39c34..3c63c7a2d 100644
--- a/silx/gui/plot3d/scene/window.py
+++ b/silx/gui/plot3d/scene/window.py
@@ -244,6 +244,7 @@ class Window(event.Notifier):
 
         void main(void) {
             gl_FragColor = texture2D(texture, textureCoord);
+            gl_FragColor.a = 1.0;
         }
         """)
Repository: silx-kit/silx
Issue: [plot] Issue with profile drawing mode

To reproduce:
- Display an image with `sx.imshow`
- Select a profile tool
- Open mask tools
- Select rectangle mask drawing tool and draw a mask, the profile tool is still active...

Changed files:
silx/gui/plot/Profile.py

diff --git a/silx/gui/plot/Profile.py b/silx/gui/plot/Profile.py
index 99cd5676f..7787bedda 100644
--- a/silx/gui/plot/Profile.py
+++ b/silx/gui/plot/Profile.py
@@ -494,6 +494,12 @@ class ProfileToolBar(qt.QToolBar):
         """
         if source is not self:
             self.clearProfile()
+
+            # Uncheck all drawing profile modes
+            self.hLineAction.setChecked(False)
+            self.vLineAction.setChecked(False)
+            self.lineAction.setChecked(False)
+
             if self.getProfileMainWindow() is not None:
                 self.getProfileMainWindow().hide()
Repository: silx-kit/silx
Issue: [silx view] About page error

Trying to open the "About" page, I get the following error. I use Python 3.5.3 and PyQt 5.7:

```
ERROR:silx.gui.qt._qt:<class 'AttributeError'> 'QVBoxLayout' object has no attribute 'setMargin'   File "/home/retegan/.local/lib/python3.5/site-packages/silx/app/view.py", line 170, in about
    qtutils.About.about(self, "Silx viewer")
  File "/home/retegan/.local/lib/python3.5/site-packages/silx/app/qtutils.py", line 242, in about
    dialog = About(parent)
  File "/home/retegan/.local/lib/python3.5/site-packages/silx/app/qtutils.py", line 93, in __init__
    self.__createLayout()
  File "/home/retegan/.local/lib/python3.5/site-packages/silx/app/qtutils.py", line 100, in __createLayout
    layout.setMargin(0)
```


Changed files:
silx/app/qtutils.py

diff --git a/silx/app/qtutils.py b/silx/app/qtutils.py
index 1bf63b4f9..4c29c841d 100644
--- a/silx/app/qtutils.py
+++ b/silx/app/qtutils.py
@@ -1,6 +1,6 @@
 # coding: utf-8
 # /*##########################################################################
-# Copyright (C) 2016 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2017 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
@@ -25,7 +25,7 @@
 
 __authors__ = ["V. Valls"]
 __license__ = "MIT"
-__date__ = "18/08/2017"
+__date__ = "22/09/2017"
 
 import sys
 
@@ -97,7 +97,6 @@ class About(qt.QDialog):
 
     def __createLayout(self):
         layout = qt.QVBoxLayout(self)
-        layout.setMargin(0)
         layout.setContentsMargins(24, 15, 24, 20)
         layout.setSpacing(8)
Repository: silx-kit/silx
Issue: [convert] when converting a file series, the dtype is not preserved

Converting a series of EDF frames in uint16 (unsigned short) creates a 3D volume in float32. That creates an output file twice the size of the input dataset. 

Changed files:
silx/io/convert.py

diff --git a/silx/io/convert.py b/silx/io/convert.py
index e46f76dce..e9cbd2d43 100644
--- a/silx/io/convert.py
+++ b/silx/io/convert.py
@@ -223,6 +223,7 @@ class Hdf5Writer(object):
                     # write frame by frame to save memory usage low
                     ds = self._h5f.create_dataset(h5_name,
                                                   shape=obj.shape,
+                                                  dtype=obj.dtype,
                                                   **self.create_dataset_args)
                     for i, frame in enumerate(obj):
                         ds[i] = frame
Repository: silx-kit/silx
Issue: [PrintPreview] bug when cancelling printer selection dialog

```
Traceback (most recent call last):
  File "/users/knobel/git/silx/build/lib.linux-x86_64-2.7/silx/gui/plot/PrintPreviewToolButton.py", line 181, in _plotToPrintPreview
    svgRenderer, viewBox = self._getSvgRendererAndViewbox()
  File "/users/knobel/git/silx/build/lib.linux-x86_64-2.7/silx/gui/plot/PrintPreviewToolButton.py", line 211, in _getSvgRendererAndViewbox
    viewbox = self._getViewBox()
  File "/users/knobel/git/silx/build/lib.linux-x86_64-2.7/silx/gui/plot/PrintPreviewToolButton.py", line 231, in _getViewBox
    dpix = printer.logicalDpiX()
AttributeError: 'NoneType' object has no attribute 'logicalDpiX'
```

To reproduce this, run `python bootstrap.py examples/printPreview.py`, click on the action then `print`. Click `Cancel` in the dialog asking you to select a printer. 


Changed files:
silx/gui/widgets/PrintPreview.py, silx/gui/plot/PrintPreviewToolButton.py

diff --git a/silx/gui/plot/PrintPreviewToolButton.py b/silx/gui/plot/PrintPreviewToolButton.py
index c5479b858..b48505df9 100644
--- a/silx/gui/plot/PrintPreviewToolButton.py
+++ b/silx/gui/plot/PrintPreviewToolButton.py
@@ -1,7 +1,7 @@
 # coding: utf-8
 # /*##########################################################################
 #
-# Copyright (c) 2017 European Synchrotron Radiation Facility
+# Copyright (c) 2017-2018 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
@@ -175,7 +175,8 @@ class PrintPreviewToolButton(qt.QToolButton):
     def _plotToPrintPreview(self):
         """Grab the plot widget and send it to the print preview dialog.
         Make sure the print preview dialog is shown and raised."""
-        self.printPreviewDialog.ensurePrinterIsSet()
+        if not self.printPreviewDialog.ensurePrinterIsSet():
+            return
 
         if qt.HAS_SVG:
             svgRenderer, viewBox = self._getSvgRendererAndViewbox()
diff --git a/silx/gui/widgets/PrintPreview.py b/silx/gui/widgets/PrintPreview.py
index 78d1bd72c..94a8ed4d4 100644
--- a/silx/gui/widgets/PrintPreview.py
+++ b/silx/gui/widgets/PrintPreview.py
@@ -411,6 +411,9 @@ class PrintPreviewDialog(qt.QDialog):
         """If the printer is not already set, try to interactively
         setup the printer using a QPrintDialog.
         In case of failure, hide widget and log a warning.
+
+        :return: True if printer was set. False if it failed or if the
+            selection dialog was canceled.
         """
         if self.printer is None:
             self.setup()
@@ -418,6 +421,7 @@ class PrintPreviewDialog(qt.QDialog):
             self.hide()
             _logger.warning("Printer setup failed or was cancelled, " +
                             "but printer is required.")
+        return self.printer is not None
 
     def setOutputFileName(self, name):
         """Set output filename.
Repository: silx-kit/silx
Issue: [plot gl] scatter plot with colormap are not properly displayed


To reproduce:
from silx import sx
w = sx.Plot2D(backend='gl')
w.show()
x, y, v = numpy.random.random(1000*3).reshape(3, 1000)
w.addScatter(x, y, v)
w.resetZoom()

This seems to come from an issue with color type handling

Changed files:
silx/gui/plot/backends/glutils/GLPlotCurve.py, silx/gui/_glutils/VertexBuffer.py

diff --git a/silx/gui/_glutils/VertexBuffer.py b/silx/gui/_glutils/VertexBuffer.py
index fab28c628..689b543c7 100644
--- a/silx/gui/_glutils/VertexBuffer.py
+++ b/silx/gui/_glutils/VertexBuffer.py
@@ -179,7 +179,8 @@ class VertexBufferAttrib(object):
                  size,
                  dimension=1,
                  offset=0,
-                 stride=0):
+                 stride=0,
+                 normalisation=False):
         self.vbo = vbo
         assert type_ in self._GL_TYPES
         self.type_ = type_
@@ -188,6 +189,7 @@ class VertexBufferAttrib(object):
         self.dimension = dimension
         self.offset = offset
         self.stride = stride
+        self.normalisation = bool(normalisation)
 
     @property
     def itemsize(self):
@@ -198,11 +200,12 @@ class VertexBufferAttrib(object):
 
     def setVertexAttrib(self, attribute):
         """Call glVertexAttribPointer with objects information"""
+        normalisation = gl.GL_TRUE if self.normalisation else gl.GL_FALSE
         with self.vbo:
             gl.glVertexAttribPointer(attribute,
                                      self.dimension,
                                      self.type_,
-                                     gl.GL_FALSE,
+                                     normalisation,
                                      self.stride,
                                      c_void_p(self.offset))
 
@@ -212,7 +215,8 @@ class VertexBufferAttrib(object):
                                   self.size,
                                   self.dimension,
                                   self.offset,
-                                  self.stride)
+                                  self.stride,
+                                  self.normalisation)
 
 
 def vertexBuffer(arrays, prefix=None, suffix=None, usage=None):
diff --git a/silx/gui/plot/backends/glutils/GLPlotCurve.py b/silx/gui/plot/backends/glutils/GLPlotCurve.py
index eb88c37a8..4f0805435 100644
--- a/silx/gui/plot/backends/glutils/GLPlotCurve.py
+++ b/silx/gui/plot/backends/glutils/GLPlotCurve.py
@@ -1184,6 +1184,8 @@ class GLPlotCurve2D(object):
             self.yVboData.size -= 2
             self.yVboData.offset += yAttrib.itemsize
 
+            if cAttrib is not None and colorData.dtype.kind == 'u':
+                cAttrib.normalisation = True  # Normalise uint to [0, 1]
             self.colorVboData = cAttrib
             self.useColorVboData = cAttrib is not None
             self.distVboData = dAttrib
Repository: silx-kit/silx
Issue: [plot] ImageData object has no attribute getRbgaImageData

I was trying to save the plot as a PNG image.
It have to be investigated, but it is part of the silx release 0.5.

```
Traceback (most recent call last):
  File "/home/valls/.local/lib/python2.7/site-packages/silx/gui/plot/PlotActions.py", line 830, in _actionTriggered
    return self._saveImage(filename, nameFilter)
  File "/home/valls/.local/lib/python2.7/site-packages/silx/gui/plot/PlotActions.py", line 762, in _saveImage
    rgbaImage = image.getRbgaImageData(copy=False)
AttributeError: 'ImageData' object has no attribute 'getRbgaImageData'
```

Changed files:
silx/gui/plot/PlotActions.py

diff --git a/silx/gui/plot/PlotActions.py b/silx/gui/plot/PlotActions.py
index 5fec51d0b..42abd68af 100644
--- a/silx/gui/plot/PlotActions.py
+++ b/silx/gui/plot/PlotActions.py
@@ -759,7 +759,7 @@ class SaveAction(PlotAction):
         elif nameFilter in (self.IMAGE_FILTER_RGB_PNG,
                             self.IMAGE_FILTER_RGB_TIFF):
             # Get displayed image
-            rgbaImage = image.getRbgaImageData(copy=False)
+            rgbaImage = image.getRgbaImageData(copy=False)
             # Convert RGB QImage
             qimage = convertArrayToQImage(rgbaImage[:, :, :3])
Repository: silx-kit/silx
Issue: [plot] addHistogram do not update an existing histogram

```
In [5]: plot = silx.gui.plot.Plot1D()

In [6]: plot.setVisible(True)

In [7]: plot.addHistogram(edges=[1,2,3], histogram=[1,2,3])
Out[7]: 'Unnamed histogram'

In [8]: plot.addHistogram(edges=[1,2,3], histogram=[1,5,3])
Out[8]: 'Unnamed histogram'
```
After the last command the histogram stays displayed with 1, 2, 3.
It is not the same behaviour as `addCurve`.

```
In [13]: plot.addCurve([1,2,3], [1,2,3])
Out[13]: 'Unnamed curve 1.1'

In [14]: plot.addCurve([1,2,3], [1,5,3])
Out[14]: 'Unnamed curve 1.1'
```

Changed files:
silx/gui/plot/items/histogram.py

diff --git a/silx/gui/plot/items/histogram.py b/silx/gui/plot/items/histogram.py
index c3821bc25..b8cd4adf6 100644
--- a/silx/gui/plot/items/histogram.py
+++ b/silx/gui/plot/items/histogram.py
@@ -286,3 +286,5 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn,
 
             self._histogram = histogram
             self._edges = edges
+
+        self._updated()
Repository: silx-kit/silx
Issue: [plot] Resetzoom not always working on right Y axis

There is an issue with reset zoom for curves on Y right axis which seems to appear when curves are moved from left to right axis

Code to reproduce:
```
from silx import sx
w = sx.plot()
w.addCurve((1, 2), (1, 10), legend='b')
w.addCurve((1, 2), (1, 2), legend='a')
for curve in w.getAllCurves():
    curve.setYAxis('right')
w.resetZoom()
```


Changed files:
silx/gui/plot/items/curve.py

diff --git a/silx/gui/plot/items/curve.py b/silx/gui/plot/items/curve.py
index 50ad86d7f..b67ffac7f 100644
--- a/silx/gui/plot/items/curve.py
+++ b/silx/gui/plot/items/curve.py
@@ -1,7 +1,7 @@
 # coding: utf-8
 # /*##########################################################################
 #
-# Copyright (c) 2017 European Synchrotron Radiation Facility
+# Copyright (c) 2017-2018 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
@@ -70,6 +70,15 @@ class Curve(Points, ColorMixIn, YAxisMixIn, FillMixIn, LabelsMixIn, LineMixIn):
         self._highlightColor = self._DEFAULT_HIGHLIGHT_COLOR
         self._highlighted = False
 
+        self.sigItemChanged.connect(self.__itemChanged)
+
+    def __itemChanged(self, event):
+        if event == ItemChangedType.YAXIS:
+            # TODO hackish data range implementation
+            plot = self.getPlot()
+            if plot is not None:
+                plot._invalidateDataRange()
+
     def _addBackendRenderer(self, backend):
         """Update backend renderer"""
         # Filter-out values <= 0
Repository: silx-kit/silx
Issue: [plot gl] Save snapshot as PNG with OpenGL backend issue with PyQt4 on Debian 8

Get image from internal off-screen framebuffer rather than screen framebuffer as in plot3d.

Changed files:
silx/gui/plot/backends/BackendOpenGL.py

diff --git a/silx/gui/plot/backends/BackendOpenGL.py b/silx/gui/plot/backends/BackendOpenGL.py
index 39616958d..3c5d30071 100644
--- a/silx/gui/plot/backends/BackendOpenGL.py
+++ b/silx/gui/plot/backends/BackendOpenGL.py
@@ -1341,11 +1341,23 @@ class BackendOpenGL(BackendBase.BackendBase, glu.OpenGLWidget):
                 (self._plotFrame.size[1], self._plotFrame.size[0], 3),
                 dtype=numpy.uint8, order='C')
 
-            gl.glBindFramebuffer(gl.GL_FRAMEBUFFER,
-                                 self.defaultFramebufferObject())
+            context = self.context()
+            framebufferTexture = self._plotFBOs.get(context)
+            if framebufferTexture is None:
+                # Fallback, supports direct rendering mode: _paintDirectGL
+                # might have issues as it can read on-screen framebuffer
+                fboName = self.defaultFramebufferObject()
+                width, height = self._plotFrame.size
+            else:
+                fboName = framebufferTexture.name
+                height, width = framebufferTexture.shape
+
+            previousFramebuffer = gl.glGetInteger(gl.GL_FRAMEBUFFER_BINDING)
+            gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, fboName)
             gl.glPixelStorei(gl.GL_PACK_ALIGNMENT, 1)
-            gl.glReadPixels(0, 0, self._plotFrame.size[0], self._plotFrame.size[1],
+            gl.glReadPixels(0, 0, width, height,
                             gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data)
+            gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, previousFramebuffer)
 
             # glReadPixels gives bottom to top,
             # while images are stored as top to bottom
Repository: silx-kit/silx
Issue: sift module not installed

On debian 8 with python2, sift module is not installed due to evaluation of the wrong path in silx/opencl/setup.py.
Using the absolute path of `__file__` should solve the issue.

Changed files:
silx/opencl/setup.py

diff --git a/silx/opencl/setup.py b/silx/opencl/setup.py
index 816399143..a2ae244ea 100644
--- a/silx/opencl/setup.py
+++ b/silx/opencl/setup.py
@@ -1,6 +1,6 @@
 # coding: utf-8
 #
-# Copyright (C) 2016 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2017 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
@@ -29,13 +29,14 @@ __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
 __authors__ = ["J. Kieffer"]
 __date__ = "16/08/2017"
 
-import os
+import os.path
 from numpy.distutils.misc_util import Configuration
 
 
 def configuration(parent_package='', top_path=None):
     config = Configuration('opencl', parent_package, top_path)
-    if os.path.exists('sift'):
+    path = os.path.dirname(os.path.abspath(__file__))
+    if os.path.exists(os.path.join(path, 'sift')):
         config.add_subpackage('sift')
     config.add_subpackage('test')
     return config
Repository: silx-kit/silx
Issue: [fit] Critical error message calculating covariance

Bug introduced between commit 95ed949... and d37843...

Changed files:
silx/math/fit/leastsq.py

diff --git a/silx/math/fit/leastsq.py b/silx/math/fit/leastsq.py
index 2da5e6345..874c23aed 100644
--- a/silx/math/fit/leastsq.py
+++ b/silx/math/fit/leastsq.py
@@ -1,7 +1,7 @@
 # coding: utf-8
 # /*##########################################################################
 #
-# Copyright (c) 2004-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2004-2017 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
@@ -34,7 +34,7 @@ This module is a refactored version of PyMca Gefit.py module.
 """
 __authors__ = ["V.A. Sole"]
 __license__ = "MIT"
-__date__ = "15/09/2016"
+__date__ = "24/01/2017"
 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
 
 import numpy
@@ -332,7 +332,7 @@ def leastsq(model, xdata, ydata, p0, sigma=None,
                 constrained_fit = True
     if constrained_fit:
         if full_output is None:
-            _logger.warning("Recommended to set full_output to True when using constraints")
+            _logger.info("Recommended to set full_output to True when using constraints")
 
     # Levenberg-Marquardt algorithm
     fittedpar = parameters.__copy__()
@@ -460,13 +460,12 @@ def leastsq(model, xdata, ydata, p0, sigma=None,
             if constraints[idx][0] in [CFIXED, CIGNORED]:
                 flag_special[idx] = constraints[idx][0]
             else:
-                pass
                 new_constraints[idx][0] = CFREE
                 new_constraints[idx][1] = 0
                 new_constraints[idx][2] = 0
         chisq, alpha, beta, internal_output = chisq_alpha_beta(
                                                  model, fittedpar,
-                                                 x, y, weight, constraints=None,
+                                                 x, y, weight, constraints=new_constraints,
                                                  model_deriv=model_deriv,
                                                  epsfcn=epsfcn,
                                                  left_derivative=left_derivative,
Repository: silx-kit/silx
Issue: CompareImages: Error when using colormap fixed scale on ROI

The composite item does not store the data the way it is expected by the `ColormapDialog`.

As result it fails when we use the fixed scale tool from the `ColormapDialog`

We could fix that by
- Creating a dedicated API for that use case in `Item`
- Disabling the tool for the `CompareImages`
- Skipping unknown items from the `ColormapDialog`

```
Traceback (most recent call last):
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/dialog/ColormapDialog.py", line 1836, in __roiFinalized
    self.setColormapRangeFromDataBounds((ox, ox+width, oy, oy+height))
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/dialog/ColormapDialog.py", line 1458, in setColormapRangeFromDataBounds
    subset = data[ystart:ystop, xstart:xstop]
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
```

Changed files:
src/silx/gui/dialog/ColormapDialog.py

diff --git a/src/silx/gui/dialog/ColormapDialog.py b/src/silx/gui/dialog/ColormapDialog.py
index 76881a066..7d2e55d7f 100644
--- a/src/silx/gui/dialog/ColormapDialog.py
+++ b/src/silx/gui/dialog/ColormapDialog.py
@@ -1432,7 +1432,7 @@ class ColormapDialog(qt.QDialog):
             (xmin, xmax, ymin, ymax) Rectangular region in data space
         """
         if bounds is None:
-            return None  # no-op
+            return  # no-op
 
         colormap = self.getColormap()
         if colormap is None:
@@ -1440,13 +1440,15 @@ class ColormapDialog(qt.QDialog):
 
         item = self._getItem()
         if not isinstance(item, items.ColormapMixIn):
-            return None  # no-op
+            return  # no-op
 
         data = item.getColormappedData(copy=False)
-
         xmin, xmax, ymin, ymax = bounds
 
         if isinstance(item, items.ImageBase):
+            if data.ndim != 2:
+                return  # no-op
+
             ox, oy = item.getOrigin()
             sx, sy = item.getScale()
Repository: silx-kit/silx
Issue: Setup uses cython even if WITH_CYTHON is False

Currently, if setup.py is called with the environment variable WITH_CYTHON set to
- True : setup doesn't use cython, the pre-generated C files are used.
- False : setup uses cython

Judging by the code (the other lines all set WITH_CYTHON to False when not using cython) this should probably be the opposite.


Changed files:
setup.py

diff --git a/setup.py b/setup.py
index d859e4f71..66537a23f 100644
--- a/setup.py
+++ b/setup.py
@@ -268,7 +268,9 @@ def check_cython():
     """
 
     if "WITH_CYTHON" in os.environ:
-        return os.environ["WITH_CYTHON"] == "False"
+        if os.environ["WITH_CYTHON"] in ["False", "0", 0]:
+            os.environ["WITH_CYTHON"] = "False"
+            return False
 
     if "--no-cython" in sys.argv:
         sys.argv.remove("--no-cython")
Repository: silx-kit/silx
Issue: [GUI] pyside6 broken on recent python

Reported in https://github.com/silx-kit/pyFAI/issues/1852

Changed files:
src/silx/gui/qt/_pyside_dynamic.py

diff --git a/src/silx/gui/qt/_pyside_dynamic.py b/src/silx/gui/qt/_pyside_dynamic.py
index 80520acf9..625ca1159 100644
--- a/src/silx/gui/qt/_pyside_dynamic.py
+++ b/src/silx/gui/qt/_pyside_dynamic.py
@@ -151,7 +151,7 @@ class UiLoader(QUiLoader):
 
         custom_widget_classes = {}
 
-        for custom_widget in custom_widgets.getchildren():
+        for custom_widget in custom_widgets:
 
             cw_class = custom_widget.find('class').text
             cw_header = custom_widget.find('header').text
Repository: silx-kit/silx
Issue: Issue with DataUrl as string if provides `slice` with start and stop

the following url is find invalid: `url = DataUrl(path='silx:///data/visitor/ls2914/id19/set40_tomo_black_drum_LPJ21_6p5mu_unload/set40_tomo_black_drum_LPJ21_6p5mu_unload_0001/set40_tomo_black_drum_LPJ21_6p5mu_unload_0001_0000.nx?path=/entry0000/instrument/detector/data&slice=2000:2021')`

Changed files:
silx/io/test/test_url.py, silx/io/url.py

diff --git a/silx/io/test/test_url.py b/silx/io/test/test_url.py
index e68c67a7b..114f6a706 100644
--- a/silx/io/test/test_url.py
+++ b/silx/io/test/test_url.py
@@ -152,6 +152,16 @@ class TestDataUrl(unittest.TestCase):
         expected = [True, True, None, "/a.h5", "/b", (5, 1)]
         self.assertUrl(url, expected)
 
+    def test_slice2(self):
+        url = DataUrl("/a.h5?path=/b&slice=2:5")
+        expected = [True, True, None, "/a.h5", "/b", (slice(2, 5),)]
+        self.assertUrl(url, expected)
+
+    def test_slice3(self):
+        url = DataUrl("/a.h5?path=/b&slice=::2")
+        expected = [True, True, None, "/a.h5", "/b", (slice(None, None, 2),)]
+        self.assertUrl(url, expected)
+
     def test_slice_ellipsis(self):
         url = DataUrl("/a.h5?path=/b&slice=...")
         expected = [True, True, None, "/a.h5", "/b", (Ellipsis, )]
diff --git a/silx/io/url.py b/silx/io/url.py
index 7607ae539..044977ccf 100644
--- a/silx/io/url.py
+++ b/silx/io/url.py
@@ -178,8 +178,20 @@ class DataUrl(object):
         def str_to_slice(string):
             if string == "...":
                 return Ellipsis
-            elif string == ":":
-                return slice(None)
+            elif ':' in string:
+                if string == ":":
+                    return slice(None)
+                else:
+                    def get_value(my_str):
+                        if my_str in ('', None):
+                            return None
+                        else:
+                            return int(my_str)
+                    sss = string.split(':')
+                    start = get_value(sss[0])
+                    stop = get_value(sss[1] if len(sss) > 1 else None)
+                    step = get_value(sss[2] if len(sss) > 2 else None)
+                    return slice(start, stop, step)
             else:
                 return int(string)
 
@@ -201,7 +213,10 @@ class DataUrl(object):
         :param str path: Path representing the URL.
         """
         self.__path = path
-        path = path.replace("::", "?", 1)
+        # only replace if ? not here already. Otherwise can mess sith
+        # data_slice if == ::2 for example
+        if '?' not in path:
+            path = path.replace("::", "?", 1)
         url = parse.urlparse(path)
 
         is_valid = True
Repository: silx-kit/silx
Issue: [ROIs] Buggy behavior introduced in current master

The color of the default full region markers is buggy. When the markers are not movable the color should be black and the middle marker should not appear. 

Changed files:
silx/gui/plot/CurvesROIWidget.py

diff --git a/silx/gui/plot/CurvesROIWidget.py b/silx/gui/plot/CurvesROIWidget.py
index 52b8ef489..c87dd1db8 100644
--- a/silx/gui/plot/CurvesROIWidget.py
+++ b/silx/gui/plot/CurvesROIWidget.py
@@ -160,7 +160,6 @@ class CurvesROIWidget(qt.QWidget):
         self.loadButton.clicked.connect(self._load)
         self.saveButton.clicked.connect(self._save)
 
-        self._middleROIMarkerFlag = False
         self._isConnected = False  # True if connected to plot signals
         self._isInit = False
 
@@ -471,7 +470,6 @@ class ROITable(TableWidget):
     def __init__(self, parent=None, plot=None, rois=None):
         super(ROITable, self).__init__(parent)
         self._showAllMarkers = False
-        self._middleROIMarkerFlag = False
         self._userIsEditingRoi = False
         """bool used to avoid conflict when editing the ROI object"""
         self._isConnected = False
@@ -923,7 +921,7 @@ class ROITable(TableWidget):
 
         :param bool flag: True to activate middle ROI marker
         """
-        self._middleROIMarkerFlag = flag
+        self._markersHandler._middleROIMarkerFlag = flag
 
     def _handleROIMarkerEvent(self, ddict):
         """Handle plot signals related to marker events."""
@@ -1321,6 +1319,9 @@ class _RoiMarkerManager(object):
         if roiID in self._roiMarkerHandlers:
             visible = ((self._activeRoi and self._activeRoi.getID() == roiID)
                        or self._showAllMarkers is True)
+            _roi = self._roiMarkerHandlers[roiID]._roi()
+            if _roi and not _roi.isICR():
+                self._roiMarkerHandlers[roiID].showMiddleMarker(self._middleROIMarkerFlag)
             self._roiMarkerHandlers[roiID].setVisible(visible)
             self._roiMarkerHandlers[roiID].updateMarkers()
 
@@ -1369,11 +1370,15 @@ class _RoiMarkerHandler(object):
 
         self._roi = weakref.ref(roi)
         self._plot = weakref.ref(plot)
-        self.draggable = False if roi.isICR() else True
-        self._color = 'blue' if roi.isICR() else 'black'
-        self._displayMidMarker = True
+        self._draggable = False if roi.isICR() else True
+        self._color = 'black' if roi.isICR() else 'blue'
+        self._displayMidMarker = False
         self._visible = True
 
+    @property
+    def draggable(self):
+        return self._draggable
+
     @property
     def plot(self):
         return self._plot()
@@ -1394,6 +1399,9 @@ class _RoiMarkerHandler(object):
             self.updateMarkers()
 
     def showMiddleMarker(self, visible):
+        if self.draggable is False and visible is True:
+            _logger.warning("ROI is not draggable. Won't display middle marker")
+            return
         self._displayMidMarker = visible
         self.getMarker('middle').setVisible(self._displayMidMarker)
Repository: silx-kit/silx
Issue: [fabioh5] numpy attribute error

In line 879 of fabio.h5 it tries to convert from a scalar to a float using numpy.float128.

A test is needed to know if numpy.float128 is supported (not on my machine) and if not default to numpy.float64.

Changed files:
silx/io/fabioh5.py

diff --git a/silx/io/fabioh5.py b/silx/io/fabioh5.py
index 0126db351..7cc679178 100644
--- a/silx/io/fabioh5.py
+++ b/silx/io/fabioh5.py
@@ -876,7 +876,10 @@ class FabioReader(object):
                     # A float64 is accurate with about 16 digits
                     return numpy.float64(value)
                 else:
-                    return numpy.float128(value)
+                    if hasattr(numpy, "float128"):
+                        return numpy.float128(value)
+                    else:
+                        return numpy.float64(value)
             except ValueError:
                 return numpy.string_(value)
Repository: silx-kit/silx
Issue: Some ArcROI handlers use a none symbol instead of hidding the handler

Noticed with the ArcRoi.

In translation mode, if you hover the start of end handler (which are not visible) the mouse cursor change to a hand pointer.

The ROI also have to be the active one.

Changed files:
src/silx/gui/plot/items/_arc_roi.py

diff --git a/src/silx/gui/plot/items/_arc_roi.py b/src/silx/gui/plot/items/_arc_roi.py
index 8639998be..100bf85bc 100644
--- a/src/silx/gui/plot/items/_arc_roi.py
+++ b/src/silx/gui/plot/items/_arc_roi.py
@@ -265,22 +265,28 @@ class ArcROI(HandleBasedROI, items.LineMixIn, InteractionModeMixIn):
         :param RoiInteractionMode modeId:
         """
         if modeId is self.ThreePointMode:
+            self._handleStart.setVisible(True)
+            self._handleEnd.setVisible(True)
+            self._handleWeight.setVisible(True)
             self._handleStart.setSymbol("s")
             self._handleMid.setSymbol("s")
             self._handleEnd.setSymbol("s")
             self._handleWeight.setSymbol("d")
             self._handleMove.setSymbol("+")
         elif modeId is self.PolarMode:
+            self._handleStart.setVisible(True)
+            self._handleEnd.setVisible(True)
+            self._handleWeight.setVisible(True)
             self._handleStart.setSymbol("o")
             self._handleMid.setSymbol("o")
             self._handleEnd.setSymbol("o")
             self._handleWeight.setSymbol("d")
             self._handleMove.setSymbol("+")
         elif modeId is self.MoveMode:
-            self._handleStart.setSymbol("")
+            self._handleStart.setVisible(False)
+            self._handleEnd.setVisible(False)
+            self._handleWeight.setVisible(False)
             self._handleMid.setSymbol("+")
-            self._handleEnd.setSymbol("")
-            self._handleWeight.setSymbol("")
             self._handleMove.setSymbol("+")
         else:
             assert False
Repository: silx-kit/silx
Issue: Issue with FlowLayout

Tested with PyQt5.14.2 and PySide2 5.13.2

```
In [1]: from silx import sx                                                     
In [2]: from silx.gui.plot.StatsWidget import BasicLineStatsWidget              
In [3]: w = BasicLineStatsWidget(); w.show()                                    
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: invalid result from FlowLayout.expandingDirections(), int cannot be converted to PyQt5.QtCore.Orientations in this context
```

Changed files:
silx/gui/widgets/FlowLayout.py

diff --git a/silx/gui/widgets/FlowLayout.py b/silx/gui/widgets/FlowLayout.py
index 14c8ab2e0..3c4c9ddce 100644
--- a/silx/gui/widgets/FlowLayout.py
+++ b/silx/gui/widgets/FlowLayout.py
@@ -71,7 +71,7 @@ class FlowLayout(qt.QLayout):
             return None
 
     def expandingDirections(self):
-        return 0
+        return qt.Qt.Orientations()
 
     def hasHeightForWidth(self):
         return True
Repository: silx-kit/silx
Issue: ColorBar  issue when closing IPython

To reproduce:

```
In [1]: from silx import sx                                                     
In [2]: w = sx.imshow()                                                         
In [3]:                                                                         
Do you really want to exit ([y]/n)? 
Traceback (most recent call last):
  File "silx/gui/plot/ColorBar.py", line 152, in hideEvent
    self._disconnectPlot()
  File "silx/gui/plot/ColorBar.py", line 118, in _disconnectPlot
    plot.sigActiveImageChanged.disconnect(
RuntimeError: wrapped C/C++ object of type Plot2D has been deleted
```

Tested with PyQt5.14.2 and PySide2 5.13.2

Changed files:
silx/gui/plot/ColorBar.py

diff --git a/silx/gui/plot/ColorBar.py b/silx/gui/plot/ColorBar.py
index eff76897a..d8698256f 100644
--- a/silx/gui/plot/ColorBar.py
+++ b/silx/gui/plot/ColorBar.py
@@ -1,7 +1,7 @@
 # coding: utf-8
 # /*##########################################################################
 #
-# Copyright (c) 2016-2020 European Synchrotron Radiation Facility
+# Copyright (c) 2016-2021 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
@@ -36,6 +36,7 @@ import numpy
 
 from ._utils import ticklayout
 from .. import qt
+from ..qt import inspect as qt_inspect
 from silx.gui import colors
 
 _logger = logging.getLogger(__name__)
@@ -112,14 +113,15 @@ class ColorBarWidget(qt.QWidget):
 
     def _disconnectPlot(self):
         """Disconnect from Plot signals"""
-        plot = self.getPlot()
-        if plot is not None and self._isConnected:
+        if self._isConnected:
             self._isConnected = False
-            plot.sigActiveImageChanged.disconnect(
-                self._activeImageChanged)
-            plot.sigActiveScatterChanged.disconnect(
-                self._activeScatterChanged)
-            plot.sigPlotSignal.disconnect(self._defaultColormapChanged)
+            plot = self.getPlot()
+            if plot is not None and qt_inspect.isValid(plot):
+                plot.sigActiveImageChanged.disconnect(
+                    self._activeImageChanged)
+                plot.sigActiveScatterChanged.disconnect(
+                    self._activeScatterChanged)
+                plot.sigPlotSignal.disconnect(self._defaultColormapChanged)
 
     def _connectPlot(self):
         """Connect to Plot signals"""
Repository: silx-kit/silx
Issue: [icons] ValueError: Not an icon name: arrow_keys

When opening a PlotWindow then clicking on the Options button to try to display the legend, I get the following error message : 

```
File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/plot/PlotWindow.py", line 358, in _controlButtonClicked
    controlMenu.addAction(self.panWithArrowKeysAction)
  File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/plot/PlotWindow.py", line 317, in panWithArrowKeysAction
    self._panWithArrowKeysAction = PanWithArrowKeysAction(self)
  File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/plot/PlotActions.py", line 945, in __init__
    checkable=True, parent=parent)
  File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/plot/PlotActions.py", line 103, in __init__
    icon = icons.getQIcon(icon)
  File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/icons.py", line 168, in getQIcon
    qfile = getQFile(name)
  File "/users/knobel/.local/lib/python2.7/site-packages/silx/gui/icons.py", line 217, in getQFile
    raise ValueError('Not an icon name: %s' % name)
ValueError: Not an icon name: arrow_keys

```


Changed files:
silx/gui/plot/PlotActions.py

diff --git a/silx/gui/plot/PlotActions.py b/silx/gui/plot/PlotActions.py
index db0ff906a..b742b9e96 100644
--- a/silx/gui/plot/PlotActions.py
+++ b/silx/gui/plot/PlotActions.py
@@ -937,7 +937,7 @@ class PanWithArrowKeysAction(_PlotAction):
     def __init__(self, plot, parent=None):
 
         super(PanWithArrowKeysAction, self).__init__(
-            plot, icon='arrow_keys', text='Pan with arrow keys',
+            plot, icon='arrow-keys', text='Pan with arrow keys',
             tooltip='Enable pan with arrow keys when checked',
             triggered=self._actionTriggered,
             checkable=True, parent=parent)