Exemplo n.º 1
0
    def __init__(self, data, format="%.3f", xlabels=None, ylabels=None,
                 readonly=False, parent=None):
        QAbstractTableModel.__init__(self)

        self.dialog = parent
        self.changes = {}
        self.xlabels = xlabels
        self.ylabels = ylabels
        self.readonly = readonly
        self.test_array = np.array([0], dtype=data.dtype)

        # for complex numbers, shading will be based on absolute value
        # but for all other types it will be the real part
        if data.dtype in (np.complex64, np.complex128):
            self.color_func = np.abs
        else:
            self.color_func = np.real
        
        # Backgroundcolor settings
        huerange = [.66, .99] # Hue
        self.sat = .7 # Saturation
        self.val = 1. # Value
        self.alp = .6 # Alpha-channel

        self._data = data
        self._format = format
        
        self.total_rows = self._data.shape[0]
        self.total_cols = self._data.shape[1]
        size = self.total_rows * self.total_cols
        
        try:
            self.vmin = np.nanmin(self.color_func(data))
            self.vmax = np.nanmax(self.color_func(data))
            if self.vmax == self.vmin:
                self.vmin -= 1
            self.hue0 = huerange[0]
            self.dhue = huerange[1]-huerange[0]
            self.bgcolor_enabled = True
        except TypeError:
            self.vmin = None
            self.vmax = None
            self.hue0 = None
            self.dhue = None
            self.bgcolor_enabled = False
        
        # Use paging when the total size, number of rows or number of
        # columns is too large
        if size > LARGE_SIZE:
            self.rows_loaded = self.ROWS_TO_LOAD
            self.cols_loaded = self.COLS_TO_LOAD
        else:
            if self.total_rows > LARGE_NROWS:
                self.rows_loaded = self.ROWS_TO_LOAD
            else:
                self.rows_loaded = self.total_rows
            if self.total_cols > LARGE_COLS:
                self.cols_loaded = self.COLS_TO_LOAD
            else:
                self.cols_loaded = self.total_cols
Exemplo n.º 2
0
    def __init__(self, parent, text_color=None, text_color_highlight=None):
        QAbstractTableModel.__init__(self)
        self._parent = parent

        self.servers = []
        self.server_map = {}
        # self.scores = []
        self.rich_text = []
        self.normal_text = []
        self.letters = ''
        self.label = QLabel()
        self.widths = []

        # Needed to compensate for the HTMLDelegate color selection unawarness
        palette = parent.palette()
        if text_color is None:
            self.text_color = palette.text().color().name()
        else:
            self.text_color = text_color

        if text_color_highlight is None:
            self.text_color_highlight = \
                palette.highlightedText().color().name()
        else:
            self.text_color_highlight = text_color_highlight
Exemplo n.º 3
0
 def __init__(self, parent, data):
     QAbstractTableModel.__init__(self, parent)
     if data is None:
         data = {}
     self._data = None
     self.breakpoints = None
     self.set_data(data)    
Exemplo n.º 4
0
        def __init__(self, datum):
            QAbstractTableModel.__init__(self)
            self._datum = datum

            conditions = datum.conditions.findvalues(DetectorSpectrometer)
            if conditions:
                self._calibration = next(iter(conditions)).calibration
            else:
                self._calibration = None
Exemplo n.º 5
0
    def __init__(self, parent):
        QAbstractTableModel.__init__(self)
        self._parent = parent

        self.shortcuts = []
        self.scores = []
        self.rich_text = []
        self.normal_text = []
        self.letters = ''
        self.label = QLabel()
        self.widths = []

        # Needed to compensate for the HTMLDelegate color selection unawarness
        palette = parent.palette()
        self.text_color = palette.text().color().name()
        self.text_color_highlight = palette.highlightedText().color().name()
Exemplo n.º 6
0
    def __init__(self, dataFrame, format="%.3g", parent=None):
        QAbstractTableModel.__init__(self)
        self.dialog = parent
        self.df = dataFrame
        self.df_index = dataFrame.index.tolist()
        self.df_header = dataFrame.columns.tolist()
        self._format = format
        self.complex_intran = None
        
        self.total_rows = self.df.shape[0]
        self.total_cols = self.df.shape[1]
        size = self.total_rows * self.total_cols

        huerange = [.66, .99]  # Hue
        self.sat = .7  # Saturation
        self.val = 1.  # Value
        self.alp = .6  # Alpha-channel
        self.hue0 = huerange[0]
        self.dhue = huerange[1]-huerange[0]
        self.max_min_col = None
        if size < LARGE_SIZE:
            self.max_min_col_update()
            self.colum_avg_enabled = True
            self.bgcolor_enabled = True
            self.colum_avg(1)
        else:
            self.colum_avg_enabled = False
            self.bgcolor_enabled = False
            self.colum_avg(0)

        # Use paging when the total size, number of rows or number of
        # columns is too large
        if size > LARGE_SIZE:
            self.rows_loaded = self.ROWS_TO_LOAD
            self.cols_loaded = self.COLS_TO_LOAD
        else:
            if self.total_rows > LARGE_NROWS:
                self.rows_loaded = self.ROWS_TO_LOAD
            else:
                self.rows_loaded = self.total_rows
            if self.total_cols > LARGE_COLS:
                self.cols_loaded = self.COLS_TO_LOAD
            else:
                self.cols_loaded = self.total_cols
Exemplo n.º 7
0
    def __init__(self, dataFrame, format=DEFAULT_FORMAT, parent=None):
        QAbstractTableModel.__init__(self)
        self.dialog = parent
        self.df = dataFrame
        self.df_index = dataFrame.index.tolist()
        self.df_header = dataFrame.columns.tolist()
        self._format = format
        self.complex_intran = None
        
        self.total_rows = self.df.shape[0]
        self.total_cols = self.df.shape[1]
        size = self.total_rows * self.total_cols

        self.max_min_col = None
        if size < LARGE_SIZE:
            self.max_min_col_update()
            self.colum_avg_enabled = True
            self.bgcolor_enabled = True
            self.colum_avg(1)
        else:
            self.colum_avg_enabled = False
            self.bgcolor_enabled = False
            self.colum_avg(0)

        # Use paging when the total size, number of rows or number of
        # columns is too large
        if size > LARGE_SIZE:
            self.rows_loaded = self.ROWS_TO_LOAD
            self.cols_loaded = self.COLS_TO_LOAD
        else:
            if self.total_rows > LARGE_NROWS:
                self.rows_loaded = self.ROWS_TO_LOAD
            else:
                self.rows_loaded = self.total_rows
            if self.total_cols > LARGE_COLS:
                self.cols_loaded = self.COLS_TO_LOAD
            else:
                self.cols_loaded = self.total_cols
Exemplo n.º 8
0
 def __init__(self):
     QAbstractTableModel.__init__(self)
     self.composition = OrderedDict()
Exemplo n.º 9
0
 def __init__(self, data=[], parent=None):
     QAbstractTableModel.__init__(self, parent)
     self._data = data
Exemplo n.º 10
0
 def __init__(self, data=[], parent=None):
     QAbstractTableModel.__init__(self, parent)
     self._data = data
Exemplo n.º 11
0
    def __init__(self, linelist, parent=None, *args):

        QAbstractTableModel.__init__(self, parent, *args)

        self._linelist = linelist

        #TODO move entire table contents to an array of QVector
        # instances that will store the columns. This should
        # speed up the sorting (as far as some indications in
        # the net suggest:
        # http://www.qtforum.org/article/30638/qsortfilterproxymodel-qtreeview-sort-performance.html).
        # Bummer... this is C++ only; PyQt never went to the trouble
        # of converting QVector to python.
        #
        # get rid entirely of astropy table and store its contents in
        # a 2-D list of lists. By using python lists instead of an
        # astropy table, and storing the QVariant instances instead
        # of the raw content, we can speed up sorting by a factor > 10X.

        # we have to do this here because some lists may
        # have no lines at all.
        self._nrows = 0
        self._ncols = 0

        self._row_cells = []

        for row in self._linelist:
            cells = []
            for rindex in range(len(row)):
                cell = row[rindex]

                # handling of a color object can be tricky. Color names
                # returned by QColor.colorNames() are inconsistent with
                # color names in Qt.GlobalColor. We just go to the basics
                # and compare color equality (or closeness) using a distance
                # criterion in r,g,b coordinates.
                # Although costly, this would be a CPU burden only when
                # sorting columns with color information. For now, only
                # the Plotted Lines line list has such information, and
                # the number of actually plotted lines tends to be small
                # anyway.
                if isinstance(cell, QColor):
                    r = cell.red()
                    g = cell.green()
                    b = cell.blue()
                    min_dist = 100000
                    result = cell
                    for color_name, orig_color in ID_COLORS.items():
                        orig_rgb = QColor(orig_color)
                        dist = abs(orig_rgb.red() - r) + abs(orig_rgb.green() - g) + abs(orig_rgb.blue() - b)
                        if dist < min_dist:
                            min_dist = dist
                            result = orig_color

                    key = [k for k,value in ID_COLORS.items() if value == result][0]

                    cells.append(QVariant(key))

                else:
                    cells.append(QVariant(str(cell)))

            self._row_cells.append(cells)

            self._nrows = len(self._row_cells)
            self._ncols = len(self._row_cells[0])
Exemplo n.º 12
0
 def __init__(self, datum):
     QAbstractTableModel.__init__(self)
     self._datum = datum
Exemplo n.º 13
0
    def __init__(self, table, parent=None, *args):

        QAbstractTableModel.__init__(self, parent, *args)

        self._table = table
Exemplo n.º 14
0
    def __init__(self, linelist, parent=None, *args):

        QAbstractTableModel.__init__(self, parent, *args)

        self._linelist = linelist

        #TODO move entire table contents to an array of QVector
        # instances that will store the columns. This should
        # speed up the sorting (as far as some indications in
        # the net suggest:
        # http://www.qtforum.org/article/30638/qsortfilterproxymodel-qtreeview-sort-performance.html).
        # Bummer... this is C++ only; PyQt never went to the trouble
        # of converting QVector to python.
        #
        # get rid entirely of astropy table and store its contents in
        # a 2-D list of lists. By using python lists instead of an
        # astropy table, and storing the QVariant instances instead
        # of the raw content, we can speed up sorting by a factor > 10X.

        # we have to do this here because some lists may
        # have no lines at all.
        self._nrows = 0
        self._ncols = 0

        self._row_cells = []

        for row in self._linelist:
            cells = []
            for rindex in range(len(row)):
                cell = row[rindex]

                # handling of a color object can be tricky. Color names
                # returned by QColor.colorNames() are inconsistent with
                # color names in Qt.GlobalColor. We just go to the basics
                # and compare color equality (or closeness) using a distance
                # criterion in r,g,b coordinates.
                # Although costly, this would be a CPU burden only when
                # sorting columns with color information. For now, only
                # the Plotted Lines line list has such information, and
                # the number of actually plotted lines tends to be small
                # anyway.
                if isinstance(cell, QColor):
                    r = cell.red()
                    g = cell.green()
                    b = cell.blue()
                    min_dist = 100000
                    result = cell
                    for color_name, orig_color in ID_COLORS.items():
                        orig_rgb = QColor(orig_color)
                        dist = abs(orig_rgb.red() - r) + abs(orig_rgb.green() - g) + abs(orig_rgb.blue() - b)
                        if dist < min_dist:
                            min_dist = dist
                            result = orig_color

                    key = [k for k,value in ID_COLORS.items() if value == result][0]

                    cells.append(QVariant(key))

                else:
                    cells.append(QVariant(str(cell)))

            self._row_cells.append(cells)

            self._nrows = len(self._row_cells)
            self._ncols = len(self._row_cells[0])
Exemplo n.º 15
0
    def __init__(self,
                 data,
                 format="%.6g",
                 xlabels=None,
                 ylabels=None,
                 readonly=False,
                 parent=None):
        QAbstractTableModel.__init__(self)

        self.dialog = parent
        self.changes = {}
        self.xlabels = xlabels
        self.ylabels = ylabels
        self.readonly = readonly
        self.test_array = np.array([0], dtype=data.dtype)

        # for complex numbers, shading will be based on absolute value
        # but for all other types it will be the real part
        if data.dtype in (np.complex64, np.complex128):
            self.color_func = np.abs
        else:
            self.color_func = np.real

        # Backgroundcolor settings
        huerange = [.66, .99]  # Hue
        self.sat = .7  # Saturation
        self.val = 1.  # Value
        self.alp = .6  # Alpha-channel

        self._data = data
        self._format = format

        self.total_rows = self._data.shape[0]
        self.total_cols = self._data.shape[1]
        size = self.total_rows * self.total_cols

        try:
            self.vmin = np.nanmin(self.color_func(data))
            self.vmax = np.nanmax(self.color_func(data))
            if self.vmax == self.vmin:
                self.vmin -= 1
            self.hue0 = huerange[0]
            self.dhue = huerange[1] - huerange[0]
            self.bgcolor_enabled = True
        except (AttributeError, TypeError, ValueError):
            self.vmin = None
            self.vmax = None
            self.hue0 = None
            self.dhue = None
            self.bgcolor_enabled = False

        # Array with infinite values cannot display background colors and
        # crashes. See: spyder-ide/spyder#8093
        self.has_inf = False
        if data.dtype.kind in ['f', 'c']:
            self.has_inf = np.any(np.isinf(data))

        # Deactivate coloring for object arrays or arrays with inf values
        if self._data.dtype.name == 'object' or self.has_inf:
            self.bgcolor_enabled = False

        # Use paging when the total size, number of rows or number of
        # columns is too large
        if size > LARGE_SIZE:
            self.rows_loaded = self.ROWS_TO_LOAD
            self.cols_loaded = self.COLS_TO_LOAD
        else:
            if self.total_rows > LARGE_NROWS:
                self.rows_loaded = self.ROWS_TO_LOAD
            else:
                self.rows_loaded = self.total_rows
            if self.total_cols > LARGE_COLS:
                self.cols_loaded = self.COLS_TO_LOAD
            else:
                self.cols_loaded = self.total_cols
Exemplo n.º 16
0
 def __init__(self, parent, dependencies):
     QAbstractTableModel.__init__(self, parent)
     self.dependencies = None
     self.set_data(dependencies)
Exemplo n.º 17
0
    def __init__(self,
                 data,
                 format="%.3f",
                 xlabels=None,
                 ylabels=None,
                 readonly=False,
                 parent=None):
        QAbstractTableModel.__init__(self)

        self.dialog = parent
        self.changes = {}
        self.xlabels = xlabels
        self.ylabels = ylabels
        self.readonly = readonly
        self.test_array = np.array([0], dtype=data.dtype)

        # for complex numbers, shading will be based on absolute value
        # but for all other types it will be the real part
        if data.dtype in (np.complex64, np.complex128):
            self.color_func = np.abs
        else:
            self.color_func = np.real

        # Backgroundcolor settings
        huerange = [.66, .99]  # Hue
        self.sat = .7  # Saturation
        self.val = 1.  # Value
        self.alp = .6  # Alpha-channel

        self._data = data
        self._format = format

        self.total_rows = self._data.shape[0]
        self.total_cols = self._data.shape[1]
        size = self.total_rows * self.total_cols

        try:
            self.vmin = np.nanmin(self.color_func(data))
            self.vmax = np.nanmax(self.color_func(data))
            if self.vmax == self.vmin:
                self.vmin -= 1
            self.hue0 = huerange[0]
            self.dhue = huerange[1] - huerange[0]
            self.bgcolor_enabled = True
        except (TypeError, ValueError):
            self.vmin = None
            self.vmax = None
            self.hue0 = None
            self.dhue = None
            self.bgcolor_enabled = False

        # Use paging when the total size, number of rows or number of
        # columns is too large
        if size > LARGE_SIZE:
            self.rows_loaded = self.ROWS_TO_LOAD
            self.cols_loaded = self.COLS_TO_LOAD
        else:
            if self.total_rows > LARGE_NROWS:
                self.rows_loaded = self.ROWS_TO_LOAD
            else:
                self.rows_loaded = self.total_rows
            if self.total_cols > LARGE_COLS:
                self.cols_loaded = self.COLS_TO_LOAD
            else:
                self.cols_loaded = self.total_cols
Exemplo n.º 18
0
 def __init__(self, parent, dependencies):
     QAbstractTableModel.__init__(self, parent)
     self.dependencies = None
     self.set_data(dependencies)
Exemplo n.º 19
0
 def __init__(self):
     QAbstractTableModel.__init__(self)
     self.positions = []
Exemplo n.º 20
0
 def __init__(self):
     QAbstractTableModel.__init__(self)
     self.layers = []