Changes in / [0f29fad:3bd0cd7] in sasview
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
run.py
r328f2ef rdb05c44 155 155 # so logging can be done during initialization process too 156 156 root = abspath(dirname(realpath(sys.argv[0]))) 157 158 addpath(joinpath(root, 'src')) 159 addpath(joinpath(root, joinpath('..', 'sasmodels'))) # dependency (for loading custom_config.py during log setup) 160 161 from sas.logger_config import SetupLogger 157 addpath(joinpath(root, 'src','sas')) 158 from logger_config import SetupLogger 162 159 logger = SetupLogger(__name__).config_development() 163 160 -
src/sas/logger_config.py
r799963c re4335ae 7 7 8 8 import pkg_resources 9 10 from sas import get_custom_config11 9 12 10 ''' … … 41 39 logging.captureWarnings(True) 42 40 43 self._disable_debug_from_config()44 45 41 return logger 46 47 def _disable_debug_from_config(self):48 '''disable DEBUG logs as per user configuration (DEBUG logs disabled by default)'''49 disable_debug = True50 custom_config = get_custom_config()51 52 if hasattr(custom_config, "FILTER_DEBUG_LOGS"):53 if type(custom_config.FILTER_DEBUG_LOGS) is bool:54 disable_debug = custom_config.FILTER_DEBUG_LOGS55 else:56 logging.warning("FILTER_DEBUG_LOGS has invalid value in custom_config.py")57 58 if disable_debug:59 # logging.info("Note: DEBUG logs are disabled.")60 logging.disable(logging.DEBUG)61 42 62 43 def _read_config_file(self): -
src/sas/qtgui/MainWindow/DataExplorer.py
r4bf58293 rc7f259d 4 4 import time 5 5 import logging 6 import re7 6 8 7 from PyQt5 import QtCore … … 37 36 # The controller which is responsible for managing signal slots connections 38 37 # for the gui and providing an interface to the data model. 39 40 # This matches the ID of a plot created using FittingLogic._create1DPlot, e.g.41 # "5 [P(Q)] modelname"42 # or43 # "4 modelname".44 # Useful for determining whether the plot in question is for an intermediate result, such as P(Q) or S(Q) in the45 # case of a product model; the identifier for this is held in square brackets, as in the example above.46 theory_plot_ID_pattern = re.compile(r"^([0-9]+)\s+(\[(.*)\]\s+)?(.*)$")47 38 48 39 def __init__(self, parent=None, guimanager=None, manager=None): … … 534 525 self.active_plots[plot_id].replacePlot(plot_id, plot) 535 526 else: 536 # Don't plot intermediate results, e.g. P(Q), S(Q)537 match = self.theory_plot_ID_pattern.match(plot_id)538 # 2nd match group contains the identifier for the intermediate result, if present (e.g. "[P(Q)]")539 if match and match.groups()[1] != None:540 continue541 527 # 'sophisticated' test to generate standalone plot for residuals 542 528 if 'esiduals' in plot.title: … … 1254 1240 #if current_tab_name in self.theory_model.item(current_index).text(): 1255 1241 if current_tab_name == self.theory_model.item(current_index).text(): 1242 return 1256 1243 self.theory_model.removeRow(current_index) 1257 1244 break -
src/sas/qtgui/MainWindow/DataManager.py
r4e255d1 r0261bc1 24 24 import json 25 25 import time 26 from io import BytesIO26 from io import StringIO 27 27 import numpy as np 28 28 … … 368 368 # ndarray 369 369 if isinstance(o, np.ndarray): 370 buffer = BytesIO()370 buffer = StringIO() 371 371 np.save(buffer, o) 372 372 buffer.seek(0) … … 435 435 # ndarray 436 436 if cls == np.ndarray: 437 buffer = BytesIO()437 buffer = StringIO() 438 438 buffer.write(data['data'].encode('latin-1')) 439 439 buffer.seek(0) -
src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
rb4d05bd r87dfca4 132 132 self._data.ymax = ymax 133 133 134 def _create1DPlot(self, tab_id, x, y, model, data, component=None): 135 """ 136 For internal use: create a new 1D data instance based on fitting results. 137 'component' is a string indicating the model component, e.g. "P(Q)" 138 """ 134 def new1DPlot(self, return_data, tab_id): 135 """ 136 Create a new 1D data instance based on fitting results 137 """ 138 # Unpack return data from Calc1D 139 x, y, page_id, state, weight,\ 140 fid, toggle_mode_on, \ 141 elapsed, index, model,\ 142 data, update_chisqr, source = return_data 143 139 144 # Create the new plot 140 145 new_plot = Data1D(x=x, y=y) … … 145 150 146 151 new_plot.group_id = data.group_id 147 new_plot.id = str(tab_id) + " " + ("[" + component + "] " if component else "") + model.id 148 149 # use data.filename for data, use model.id for theory 150 id_str = data.filename if data.filename else model.id 151 new_plot.name = model.name + ((" " + component) if component else "") + " [" + id_str + "]" 152 new_plot.id = str(tab_id) + " " + model.id 153 154 if data.filename: 155 new_plot.name = model.name + " [" + data.filename + "]" # data file 156 else: 157 new_plot.name = model.name + " [" + model.id + "]" # theory 152 158 153 159 new_plot.title = new_plot.name … … 156 162 157 163 return new_plot 158 159 def new1DPlot(self, return_data, tab_id):160 """161 Create a new 1D data instance based on fitting results162 """163 # Unpack return data from Calc1D164 x, y, page_id, state, weight,\165 fid, toggle_mode_on, \166 elapsed, index, model, \167 data, update_chisqr, source, \168 unsmeared_output, unsmeared_data, unsmeared_error, \169 pq_values, sq_values = return_data170 171 return self._create1DPlot(tab_id, x, y, model, data)172 164 173 165 def new2DPlot(self, return_data): … … 213 205 return new_plot 214 206 215 def new1DProductPlots(self, return_data, tab_id):216 """217 If return_data contains separated P(Q) and/or S(Q) data, create 1D plots for each and return as the tuple218 (pq_plot, sq_plot). If either are unavailable, the corresponding plot is None.219 """220 # Unpack return data from Calc1D221 x, y, page_id, state, weight, \222 fid, toggle_mode_on, \223 elapsed, index, model, \224 data, update_chisqr, source, \225 unsmeared_output, unsmeared_data, unsmeared_error, \226 pq_values, sq_values = return_data227 228 pq_plot = None229 sq_plot = None230 231 if pq_values is not None:232 pq_plot = self._create1DPlot(tab_id, x, pq_values, model, data, component="P(Q)")233 if sq_values is not None:234 sq_plot = self._create1DPlot(tab_id, x, sq_values, model, data, component="S(Q)")235 236 return pq_plot, sq_plot237 238 207 def computeDataRange(self): 239 208 """ -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
rb4d05bd r10fee37 2113 2113 self.updateModelIndex(fitted_data) 2114 2114 else: 2115 if not fitted_data.name: 2116 name = self.nameForFittedData(self.kernel_module.id) 2117 else: 2118 name = fitted_data.name 2115 name = self.nameForFittedData(self.kernel_module.id) 2119 2116 fitted_data.title = name 2117 fitted_data.name = name 2120 2118 fitted_data.filename = name 2121 2119 fitted_data.symbol = "Line" … … 2231 2229 self.model_data = fitted_data 2232 2230 2233 # Create plots for intermediate product data2234 pq_data, sq_data = self.logic.new1DProductPlots(return_data, self.tab_id)2235 if pq_data is not None:2236 pq_data.symbol = "Line"2237 self.createNewIndex(pq_data)2238 if sq_data is not None:2239 sq_data.symbol = "Line"2240 self.createNewIndex(sq_data)2241 2242 2231 def complete2D(self, return_data): 2243 2232 """ -
src/sas/qtgui/Perspectives/Fitting/ModelThread.py
r3ae9179 rd4dac80 222 222 s_model = self.model.s_model 223 223 p_model = self.model.p_model 224 elif hasattr(self.model, "calc_composition_models"): 225 results = self.model.calc_composition_models(self.data.x[index]) 226 if results is not None: 227 pq_values, sq_values = results 228 229 if pq_values is None or sq_values is None: 230 if p_model is not None and s_model is not None: 231 sq_values = numpy.zeros((len(self.data.x))) 232 pq_values = numpy.zeros((len(self.data.x))) 233 sq_values[index] = s_model.evalDistribution(self.data.x[index]) 234 pq_values[index] = p_model.evalDistribution(self.data.x[index]) 224 elif hasattr(self.model, "get_composition_models"): 225 p_model, s_model = self.model.get_composition_models() 226 227 if p_model is not None and s_model is not None: 228 sq_values = numpy.zeros((len(self.data.x))) 229 pq_values = numpy.zeros((len(self.data.x))) 230 sq_values[index] = s_model.evalDistribution(self.data.x[index]) 231 pq_values[index] = p_model.evalDistribution(self.data.x[index]) 235 232 236 233 elapsed = time.time() - self.starttime … … 246 243 self.data, 247 244 self.update_chisqr, 248 self.source, 249 unsmeared_output, unsmeared_data, unsmeared_error, 250 pq_values, sq_values) 245 self.source) 251 246 else: 252 247 self.complete(x=self.data.x[index], y=output[index], -
src/sas/qtgui/Perspectives/Fitting/UnitTesting/FittingLogicTest.py
re752ab8 r80468f6 100 100 data.id = "poop" 101 101 return_data = (data.x,data.y, 7, None, None, 102 0, True, 0.0, 1, data, 103 data, False, None, 104 None, None, None, 105 None, None) 102 0, True, 0.0, 1, data, 103 data, False, None) 106 104 107 105 new_plot = self.logic.new1DPlot(return_data=return_data, tab_id=0) -
src/sas/qtgui/Utilities/GuiUtils.py
r3933ee9 r685e0e3 312 312 return clone 313 313 314 315 def getMonospaceFont():316 """Convenience function; returns a monospace font to be used in any shells, code editors, etc."""317 318 # Note: Consolas is only available on Windows; the style hint is used on other operating systems319 font = QtGui.QFont("Consolas", 10)320 font.setStyleHint(QtGui.QFont.Monospace, QtGui.QFont.PreferQuality)321 return font322 314 323 315 def createModelItemWithPlot(update_data, name=""): -
src/sas/qtgui/Utilities/IPythonWidget.py
r3933ee9 rfbfc488 4 4 5 5 from PyQt5 import QtSvg 6 7 from sas.qtgui.Utilities import GuiUtils8 6 9 7 def new_load_qt(api_options): … … 37 35 app = guisupport.get_app_qt4() 38 36 39 font = GuiUtils.getMonospaceFont()40 self.font = font41 42 37 # Create an in-process kernel 43 38 kernel_manager = QtInProcessKernelManager() -
src/sas/qtgui/Utilities/ModelEditor.py
r3933ee9 r26970b3 3 3 4 4 from sas.qtgui.Utilities.UI.ModelEditor import Ui_ModelEditor 5 from sas.qtgui.Utilities import GuiUtils6 5 7 6 class ModelEditor(QtWidgets.QDialog, Ui_ModelEditor): … … 31 30 self.highlight = PythonHighlighter(self.txtEditor.document()) 32 31 33 self.txtEditor.setFont(GuiUtils.getMonospaceFont())34 35 32 def addSignals(self): 36 33 """ -
src/sas/qtgui/Utilities/PluginDefinition.py
r3933ee9 r060413c 4 4 5 5 from sas.qtgui.Utilities.UI.PluginDefinitionUI import Ui_PluginDefinition 6 from sas.qtgui.Utilities import GuiUtils7 6 8 7 # txtName … … 65 64 """ 66 65 self.txtFunction.insertPlainText(text) 67 self.txtFunction.setFont(GuiUtils.getMonospaceFont())68 66 69 67 # Validators -
src/sas/sasview/custom_config.py
r799963c refe730d 16 16 DEFAULT_PERSPECTIVE = "Fitting" 17 17 SAS_OPENCL = "None" 18 19 # Logging options20 FILTER_DEBUG_LOGS = True
Note: See TracChangeset
for help on using the changeset viewer.