From 1adb5288570982b5a2f0ddba3e87c73e207200d4 Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauld.mccarthy@gmail.com> Date: Wed, 28 Oct 2015 13:50:54 +0000 Subject: [PATCH] HistogramSeries fixed - props.enable/disableListener now throws errors if said listener is not registered. --- fsl/fsleyes/plotting/__init__.py | 8 +++++++- fsl/fsleyes/plotting/histogramseries.py | 16 +++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/fsl/fsleyes/plotting/__init__.py b/fsl/fsleyes/plotting/__init__.py index b991030c9..781013385 100644 --- a/fsl/fsleyes/plotting/__init__.py +++ b/fsl/fsleyes/plotting/__init__.py @@ -1,12 +1,17 @@ #!/usr/bin/env python # -# __init__.py - +# __init__.py - Classes used by PlotPanel. # # Author: Paul McCarthy <pauldmccarthy@gmail.com> # +"""The ``plotting`` package contains the :class:`.DataSeries` class, and +all of its sub-classes. These classes are used by :class:`.PlotPanel` views +for plotting data. +""" import dataseries import timeseries +import histogramseries DataSeries = dataseries.DataSeries TimeSeries = timeseries.TimeSeries @@ -17,3 +22,4 @@ FEATEVTimeSeries = timeseries.FEATEVTimeSeries FEATResidualTimeSeries = timeseries.FEATResidualTimeSeries FEATModelFitTimeSeries = timeseries.FEATModelFitTimeSeries MelodicTimeSeries = timeseries.MelodicTimeSeries +HistogramSeries = histogramseries.HistogramSeries diff --git a/fsl/fsleyes/plotting/histogramseries.py b/fsl/fsleyes/plotting/histogramseries.py index ad45a9a01..cf5f71d82 100644 --- a/fsl/fsleyes/plotting/histogramseries.py +++ b/fsl/fsleyes/plotting/histogramseries.py @@ -1,9 +1,12 @@ #!/usr/bin/env python # -# histogramseries.py - +# histogramseries.py - The HistogramSeries class. # # Author: Paul McCarthy <pauldmccarthy@gmail.com> # +"""This module provides the :class:`HistogramSeries` class, used by the +:class:`.HistogramPanel` for plotting histogram data. +""" import logging @@ -23,6 +26,7 @@ class HistogramSeries(dataseries.DataSeries): instance. """ + nbins = props.Int(minval=10, maxval=500, default=100, clamped=True) """Number of bins to use in the histogram. This value is overridden by the :attr:`HistogramPanel.autoBin` setting. @@ -110,7 +114,7 @@ class HistogramSeries(dataseries.DataSeries): if overlay.is4DImage(): self.setConstraint('volume', 'maxval', overlay.shape[3] - 1) - + # If we have a baseHS, we # can copy all its data if baseHs is not None: @@ -134,7 +138,7 @@ class HistogramSeries(dataseries.DataSeries): # it all for ourselves else: self.__initProperties() - + overlayList.addListener('overlays', self.__name, self.__overlayListChanged) @@ -317,9 +321,11 @@ class HistogramSeries(dataseries.DataSeries): if self.__hsPanel.autoBin: nbins = self.__autoBin(data, self.dataRange.x) - self.disableListener('nbins', self.__name) + if self.hasListener('nbins', self.__name): + self.disableListener('nbins', self.__name) self.nbins = nbins - self.enableListener('nbins', self.__name) + if self.hasListener('nbins', self.__name): + self.enableListener('nbins', self.__name) # Calculate bin edges bins = np.linspace(self.dataRange.xlo, -- GitLab