Commit 5f6d3f87 authored by Dimitar Tasev's avatar Dimitar Tasev
Browse files

Remove todos, unused file, bad comments, re #24007

parent aee9a567
......@@ -297,10 +297,9 @@ PyObject *row(ITableWorkspace &self, int row) {
}
/**
* Access a cell and return a corresponding Python type
* Return the C++ types for all columns
* @param self A reference to the TableWorkspace python object that we were
* called on
* @param row An integer giving the row
*/
PyObject *columnTypes(ITableWorkspace &self) {
int numCols = static_cast<int>(self.columnCount());
......
......@@ -76,12 +76,6 @@ class StatisticsOfTableWorkspace(PythonAlgorithm):
('Maximum', collections.OrderedDict()),
('Mean', collections.OrderedDict()),
])
# PYTHON_ROOT = "c:/users/qbr77747/apps/miniconda3"
# import os
# import sys
# sys.path.append(os.path.join(PYTHON_ROOT, "lib/site-packages"))
# import pydevd
# pydevd.settrace('localhost', port=44444, stdoutToServer=True, stderrToServer=True)
for index in indices_list:
column_name = column_names[index]
......
THIRD_PARTY_DIR=C:\Users\qbr77747\dev\2m\source\external\src\ThirdParty
QT4_BIN=${THIRD_PARTY_DIR}\lib\qt4\bin;${THIRD_PARTY_DIR}\lib\qt4\lib
QT5_BIN=${THIRD_PARTY_DIR}\lib\qt5\bin;${THIRD_PARTY_DIR}\lib\qt5\lib
QT_QPA_PLATFORM_PLUGIN_PATH=${THIRD_PARTY_DIR}\lib\qt5\plugins
PYTHONHOME=${THIRD_PARTY_DIR}\lib\python2.7
MISC_BIN=${THIRD_PARTY_DIR}\bin;${THIRD_PARTY_DIR}\bin\mingw
PATH=${MISC_BIN};${PYTHONHOME};${QT5_BIN};${QT4_BIN};${PATH}
\ No newline at end of file
......@@ -22,9 +22,6 @@ from mantidqt.widgets.tableworkspacedisplay.presenter import TableWorkspaceDispl
import matplotlib.pyplot as plt # noqa: F402
app = QApplication([])
DEEE_WS_MON = Load("SavedTableWorkspace.nxs")
# DEEE_WS_MON = Load("TOPAZ_3007.peaks.nxs")
# DEEE_WS_MON = Load("SmallPeakWS10_vals.nxs")
# DEEE_WS_MON = Load(r"C:\Users\qbr77747\Documents\dasdas\37828_peak_table_nuclear.nxs")
window = TableWorkspaceDisplay(DEEE_WS_MON, plt)
ws = Load("SavedTableWorkspace.nxs")
window = TableWorkspaceDisplay(ws, plt)
app.exec_()
from mantidqt.widgets.tableworkspacedisplay.error_column import ErrorColumn
class MarkedColumns:
X_LABEL = "[X{}]"
Y_LABEL = "[Y{}]"
......@@ -9,8 +6,7 @@ class MarkedColumns:
def __init__(self):
self.as_x = []
self.as_y = []
self.as_y_err = [] # type: list[ErrorColumn]
# self.as_x_err = []
self.as_y_err = []
def _add(self, col_index, add_to, remove_from):
assert all(
......@@ -45,7 +41,6 @@ class MarkedColumns:
self._add(col_index, self.as_y, [self.as_x, self.as_y_err])
def add_y_err(self, err_column):
# TODO consider adding checks of err_column.error_for_column is already in X or YErr and then error
if err_column.error_for_column in self.as_x:
raise ValueError("Trying to add YErr for column marked as X.")
elif err_column.error_for_column in self.as_y_err:
......
......@@ -169,6 +169,7 @@ class TableWorkspaceDisplay(object):
selected_columns = self._get_selected_columns()
except ValueError:
return
stats = StatisticsOfTableWorkspace(self.model.ws, selected_columns)
TableWorkspaceDisplay(stats, parent=self.parent, name="Column Statistics of {}".format(self.name))
......@@ -241,12 +242,6 @@ class TableWorkspaceDisplay(object):
except ValueError:
return
# TODO check if the selected column for plotting is YERR and NOPE out if so
# better check: if the selected columns ARE NOT Y then nope out
# currently it silently ignores it -> maybe we want to do that so people can spam PLOT EVERYTHING
# if -> a column in the selection is X or YErr ABORT MISSION with a toast :cheer:
# it should be possible to reuse the check below as it is similar
# (is it really tho -> only part of it is similar)
x_cols = list(set(selected_columns).intersection(self.model.marked_columns.as_x))
num_x_cols = len(x_cols)
# if there is more than 1 column marked as X in the selection
......
# coding=utf-8
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
# This file is part of the mantid workbench.
#
#
from __future__ import (absolute_import, division, print_function)
from qtpy import QtGui
from qtpy.QtCore import QVariant, Qt, QAbstractTableModel
from mantid.py3compat import Enum
class TableWorkspaceTableViewModelType(Enum):
x = 'x'
y = 'y'
e = 'e'
class TableWorkspaceTableViewModel(QAbstractTableModel):
HORIZONTAL_HEADER_DISPLAY_STRING = u"{0}\n{1:0.1f}{2}"
HORIZONTAL_HEADER_TOOLTIP_STRING = u"index {0}\n{1} {2:0.1f}{3} (bin centre)"
HORIZONTAL_HEADER_DISPLAY_STRING_FOR_X_VALUES = "{0}"
HORIZONTAL_HEADER_TOOLTIP_STRING_FOR_X_VALUES = "index {0}"
VERTICAL_HEADER_DISPLAY_STRING = "{0} {1}"
VERTICAL_HEADER_TOOLTIP_STRING = "index {0}\nspectra no {1}"
HORIZONTAL_BINS_VARY_DISPLAY_STRING = "{0}\nbins vary"
HORIZONTAL_BINS_VARY_TOOLTIP_STRING = "index {0}\nbin centre value varies\nRebin to set common bins"
MASKED_MONITOR_ROW_STRING = "This is a masked monitor spectrum. "
MASKED_ROW_STRING = "This is a masked spectrum. "
MONITOR_ROW_STRING = "This is a monitor spectrum. "
MASKED_BIN_STRING = "This bin is masked. "
def __init__(self, ws, model_type):
"""
:param ws:
:param model_type: TableWorkspaceTableViewModelType
:type model_type: TableWorkspaceTableViewModelType
"""
assert model_type in [TableWorkspaceTableViewModelType.x, TableWorkspaceTableViewModelType.y,
TableWorkspaceTableViewModelType.e], "The Model type must be either X, Y or E."
super(TableWorkspaceTableViewModel, self).__init__()
self.ws = ws
self.ws_spectrum_info = self.ws.spectrumInfo()
self.row_count = self.ws.getNumberHistograms()
self.column_count = self.ws.blocksize()
self.masked_rows_cache = []
self.monitor_rows_cache = []
self.masked_bins_cache = {}
self.masked_color = QtGui.QColor(240, 240, 240)
self.monitor_color = QtGui.QColor(255, 253, 209)
self.type = model_type
if self.type == TableWorkspaceTableViewModelType.x:
self.relevant_data = self.ws.readX
elif self.type == TableWorkspaceTableViewModelType.y:
self.relevant_data = self.ws.readY
elif self.type == TableWorkspaceTableViewModelType.e:
self.relevant_data = self.ws.readE
else:
raise ValueError("Unknown model type {0}".format(self.type))
def _makeVerticalHeader(self, section, role):
axis_index = 1
# check that the vertical axis actually exists in the workspace
if self.ws.axes() > axis_index:
if role == Qt.DisplayRole:
return self.VERTICAL_HEADER_DISPLAY_STRING.format(section, self.ws.getAxis(axis_index).label(section))
else:
spectrum_number = self.ws.getSpectrum(section).getSpectrumNo()
return self.VERTICAL_HEADER_TOOLTIP_STRING.format(section, spectrum_number)
else:
raise NotImplementedError("What do we do here? Handle if the vertical axis does NOT exist")
def _makeHorizontalHeader(self, section, role):
"""
:param section: The workspace index or bin number
:param role: Qt.DisplayRole - is the label for the header
or Qt.TooltipRole - is the tooltip for the header when moused over
:return: The formatted header string
"""
# X values get simpler labels
if self.type == TableWorkspaceTableViewModelType.x:
if role == Qt.DisplayRole:
return self.HORIZONTAL_HEADER_DISPLAY_STRING_FOR_X_VALUES.format(section)
else:
# format for the tooltip
return self.HORIZONTAL_HEADER_TOOLTIP_STRING_FOR_X_VALUES.format(section)
if not self.ws.isCommonBins():
if role == Qt.DisplayRole:
return self.HORIZONTAL_BINS_VARY_DISPLAY_STRING.format(section)
else:
# format for the tooltip
return self.HORIZONTAL_BINS_VARY_TOOLTIP_STRING.format(section)
# for the Y and E values, create a label with the units
axis_index = 0
x_vec = self.ws.readX(0)
if self.ws.isHistogramData():
bin_centre_value = (x_vec[section] + x_vec[section + 1]) / 2.0
else:
bin_centre_value = x_vec[section]
unit = self.ws.getAxis(axis_index).getUnit()
if role == Qt.DisplayRole:
return self.HORIZONTAL_HEADER_DISPLAY_STRING.format(section, bin_centre_value, unit.symbol().utf8())
else:
# format for the tooltip
return self.HORIZONTAL_HEADER_TOOLTIP_STRING.format(section, unit.caption(), bin_centre_value,
unit.symbol().utf8())
def headerData(self, section, orientation, role=None):
if not (role == Qt.DisplayRole or role == Qt.ToolTipRole):
return QVariant()
if orientation == Qt.Vertical:
return self._makeVerticalHeader(section, role)
else:
return self._makeHorizontalHeader(section, role)
def rowCount(self, parent=None, *args, **kwargs):
return self.row_count
def columnCount(self, parent=None, *args, **kwargs):
return self.column_count
def data(self, index, role=None):
row = index.row()
if role == Qt.DisplayRole:
# DisplayRole determines the text of each cell
return str(self.relevant_data(row)[index.column()])
elif role == Qt.BackgroundRole:
# BackgroundRole determines the background of each cell
# Checks if the row is MASKED, if so makes it the specified color for masked
# The check for masked rows should be first as a monitor row can be masked as well - and we want it to be
# colored as a masked row, rather than as a monitor row.
# First do the check in the cache, and only if not present go through SpectrumInfo and cache it. This logic
# is repeated in the other checks below
if self.checkMaskedCache(row):
return self.masked_color
# Checks if the row is a MONITOR, if so makes it the specified color for monitors
elif self.checkMonitorCache(row):
return self.monitor_color
# Checks if the BIN is MASKED, if so makes it the specified color for masked
elif self.checkMaskedBinCache(row, index):
return self.masked_color
elif role == Qt.ToolTipRole:
tooltip = QVariant()
if self.checkMaskedCache(row):
if self.checkMonitorCache(row):
tooltip = self.MASKED_MONITOR_ROW_STRING
else:
tooltip = self.MASKED_ROW_STRING
elif self.checkMonitorCache(row):
tooltip = self.MONITOR_ROW_STRING
if self.checkMaskedBinCache(row, index):
tooltip += self.MASKED_BIN_STRING
elif self.checkMaskedBinCache(row, index):
tooltip = self.MASKED_BIN_STRING
return tooltip
else:
return QVariant()
def checkMaskedCache(self, row):
if row in self.masked_rows_cache:
return True
elif self.ws_spectrum_info.hasDetectors(row) and self.ws_spectrum_info.isMasked(row):
self.masked_rows_cache.append(row)
return True
def checkMonitorCache(self, row):
if row in self.monitor_rows_cache:
return True
elif self.ws_spectrum_info.hasDetectors(row) and self.ws_spectrum_info.isMonitor(row):
self.monitor_rows_cache.append(row)
return True
def checkMaskedBinCache(self, row, index):
if row in self.masked_bins_cache:
# retrieve the masked bins IDs from the cache
if index.column() in self.masked_bins_cache[row]:
return True
elif self.ws.hasMaskedBins(row):
masked_bins = self.ws.maskedBinsIndices(row)
if index.column() in masked_bins:
self.masked_bins_cache[row] = masked_bins
return True
......@@ -23,10 +23,5 @@
# class TableWorkspaceDisplayPresenterTest(unittest.TestCase):
# def assertNotCalled(self, mock):
# self.assertEqual(0, mock.call_count)
# if __name__ == '__main__':
# unittest.main()
......@@ -31,12 +31,6 @@ class TableWorkspaceDisplayView(QTableWidget):
self.GRAPH_ICON = mantidqt.icons.get_icon('fa.line-chart')
self.TBD = mantidqt.icons.get_icon('fa.question')
# change the default color of the rows - makes them light blue
# monitors and masked rows are colored in the table's custom model
# palette = self.palette()
# palette.setColor(QtGui.QPalette.Base, QtGui.QColor(128, 255, 255))
# self.setPalette(palette)
self.setWindowTitle("{} - Mantid".format(name))
self.setWindowFlags(Qt.Window)
......@@ -70,7 +64,6 @@ class TableWorkspaceDisplayView(QTableWidget):
horizontalHeader = table.horizontalHeader()
horizontalHeader.setContextMenuPolicy(Qt.CustomContextMenu)
horizontalHeader.customContextMenuRequested.connect(self.custom_context_menu)
# horizontalHeader.setSectionResizeMode(QHeaderView.Fixed)
verticalHeader = table.verticalHeader()
verticalHeader.setContextMenuPolicy(Qt.ActionsContextMenu)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment