minor fixes
This commit is contained in:
parent
41d90bb15f
commit
067857eda2
@ -8,6 +8,7 @@ from pyqtgraph import mkPen
|
|||||||
|
|
||||||
from nmreval.data.points import Points
|
from nmreval.data.points import Points
|
||||||
from nmreval.data.signals import Signal
|
from nmreval.data.signals import Signal
|
||||||
|
from nmreval.lib.logger import logger
|
||||||
from nmreval.utils.text import convert
|
from nmreval.utils.text import convert
|
||||||
from nmreval.data.bds import BDS
|
from nmreval.data.bds import BDS
|
||||||
from nmreval.data.dsc import DSC
|
from nmreval.data.dsc import DSC
|
||||||
@ -356,7 +357,7 @@ class ExperimentContainer(QtCore.QObject):
|
|||||||
elif mode in ['imag', 'all'] and self.plot_imag is not None:
|
elif mode in ['imag', 'all'] and self.plot_imag is not None:
|
||||||
self.plot_imag.set_symbol(symbol=symbol, size=size, color=color)
|
self.plot_imag.set_symbol(symbol=symbol, size=size, color=color)
|
||||||
else:
|
else:
|
||||||
print('Updating symbol failed for ' + str(self.id))
|
logger.warning(f'Updating symbol failed for {self.id}')
|
||||||
|
|
||||||
def setLine(self, *, width=None, style=None, color=None, mode='real'):
|
def setLine(self, *, width=None, style=None, color=None, mode='real'):
|
||||||
if mode in ['real', 'all']:
|
if mode in ['real', 'all']:
|
||||||
@ -368,7 +369,7 @@ class ExperimentContainer(QtCore.QObject):
|
|||||||
elif mode in ['imag', 'all'] and self.plot_imag is not None:
|
elif mode in ['imag', 'all'] and self.plot_imag is not None:
|
||||||
self.plot_imag.set_line(width=width, style=style, color=color)
|
self.plot_imag.set_line(width=width, style=style, color=color)
|
||||||
else:
|
else:
|
||||||
print('Updating line failed for ' + str(self.id))
|
logger.warning(f'Updating line failed for {self.id}')
|
||||||
|
|
||||||
def update_property(self, key1: str, key2: str, value: Any):
|
def update_property(self, key1: str, key2: str, value: Any):
|
||||||
keykey = key2.split()
|
keykey = key2.split()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from nmreval.lib.logger import logger
|
||||||
from nmreval.math import apodization
|
from nmreval.math import apodization
|
||||||
from nmreval.lib.importer import find_models
|
from nmreval.lib.importer import find_models
|
||||||
from nmreval.utils.text import convert
|
from nmreval.utils.text import convert
|
||||||
@ -67,7 +68,7 @@ class EditSignalWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
self.do_something.emit(sender, (ph0, ph1, pvt))
|
self.do_something.emit(sender, (ph0, ph1, pvt))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print('You should never reach this by accident.')
|
logger.warning(f'You should never reach this by accident, invalid sender {sender!r}')
|
||||||
|
|
||||||
@QtCore.pyqtSlot(int, name='on_apodcombobox_currentIndexChanged')
|
@QtCore.pyqtSlot(int, name='on_apodcombobox_currentIndexChanged')
|
||||||
def change_apodization(self, index):
|
def change_apodization(self, index):
|
||||||
|
@ -175,7 +175,7 @@ class QFitParameterWidget(QtWidgets.QWidget, Ui_FormFit):
|
|||||||
# disable single parameter if it is set global, enable if global is unset
|
# disable single parameter if it is set global, enable if global is unset
|
||||||
widget = self.sender()
|
widget = self.sender()
|
||||||
idx = self.global_parameter.index(widget)
|
idx = self.global_parameter.index(widget)
|
||||||
enable = (widget.global_checkbox.checkState() == QtCore.Qt.Unchecked) and (widget.is_linked is None)
|
enable = (widget.global_checkbox.checkState() == QtCore.Qt.Unchecked)
|
||||||
self.data_parameter[idx].setEnabled(enable)
|
self.data_parameter[idx].setEnabled(enable)
|
||||||
|
|
||||||
def select_next_preview(self, direction):
|
def select_next_preview(self, direction):
|
||||||
|
@ -138,9 +138,7 @@ class DrawingsWidget(QtWidgets.QWidget, Ui_Form):
|
|||||||
graph_id = self.graph_comboBox.currentData()
|
graph_id = self.graph_comboBox.currentData()
|
||||||
current_lines = self.lines[graph_id]
|
current_lines = self.lines[graph_id]
|
||||||
|
|
||||||
print(remove_rows)
|
|
||||||
for i in reversed(remove_rows):
|
for i in reversed(remove_rows):
|
||||||
print(i)
|
|
||||||
self.tableWidget.removeRow(i)
|
self.tableWidget.removeRow(i)
|
||||||
self.line_deleted.emit(current_lines[i], graph_id)
|
self.line_deleted.emit(current_lines[i], graph_id)
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ class MdiAreaTile(QtWidgets.QMdiArea):
|
|||||||
pos = QtCore.QPoint(0, 0)
|
pos = QtCore.QPoint(0, 0)
|
||||||
|
|
||||||
for win in window_list:
|
for win in window_list:
|
||||||
print(win.minimumSize())
|
|
||||||
win.setGeometry(rect)
|
win.setGeometry(rect)
|
||||||
win.move(pos)
|
win.move(pos)
|
||||||
|
|
||||||
|
@ -1,110 +0,0 @@
|
|||||||
import os.path
|
|
||||||
import json
|
|
||||||
import urllib.request
|
|
||||||
import webbrowser
|
|
||||||
import random
|
|
||||||
|
|
||||||
from ..Qt import QtGui, QtCore, QtWidgets
|
|
||||||
from .._py.pokemon import Ui_Dialog
|
|
||||||
|
|
||||||
random.seed()
|
|
||||||
|
|
||||||
|
|
||||||
class QPokemon(QtWidgets.QDialog, Ui_Dialog):
|
|
||||||
def __init__(self, number=None, parent=None):
|
|
||||||
super().__init__(parent=parent)
|
|
||||||
self.setupUi(self)
|
|
||||||
self._js = json.load(open(os.path.join(path_to_module, 'utils', 'pokemon.json'), 'r'), encoding='UTF-8')
|
|
||||||
self._id = 0
|
|
||||||
|
|
||||||
if number is not None and number in range(1, len(self._js)+1):
|
|
||||||
poke_nr = f'{number:03d}'
|
|
||||||
self._id = number
|
|
||||||
else:
|
|
||||||
poke_nr = f'{random.randint(1, len(self._js)):03d}'
|
|
||||||
self._id = int(poke_nr)
|
|
||||||
|
|
||||||
self._pokemon = None
|
|
||||||
self.show_pokemon(poke_nr)
|
|
||||||
self.label_15.linkActivated.connect(lambda x: webbrowser.open(x))
|
|
||||||
|
|
||||||
self.buttonBox.clicked.connect(self.randomize)
|
|
||||||
self.next_button.clicked.connect(self.show_next)
|
|
||||||
self.prev_button.clicked.connect(self.show_prev)
|
|
||||||
|
|
||||||
def show_pokemon(self, nr):
|
|
||||||
self._pokemon = self._js[nr]
|
|
||||||
self.setWindowTitle('Pokémon: ' + self._pokemon['Deutsch'])
|
|
||||||
|
|
||||||
for i in range(self.tabWidget.count(), -1, -1):
|
|
||||||
print('i', self.tabWidget.count(), i)
|
|
||||||
try:
|
|
||||||
self.tabWidget.widget(i).deleteLater()
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
for n, img in self._pokemon['Bilder']:
|
|
||||||
w = QtWidgets.QWidget()
|
|
||||||
vl = QtWidgets.QVBoxLayout()
|
|
||||||
l = QtWidgets.QLabel(self)
|
|
||||||
l.setAlignment(QtCore.Qt.AlignHCenter)
|
|
||||||
pixmap = QtGui.QPixmap()
|
|
||||||
|
|
||||||
try:
|
|
||||||
pixmap.loadFromData(urllib.request.urlopen(img, timeout=0.5).read())
|
|
||||||
except IOError:
|
|
||||||
l.setText(n)
|
|
||||||
else:
|
|
||||||
sc_pixmap = pixmap.scaled(256, 256, QtCore.Qt.KeepAspectRatio)
|
|
||||||
l.setPixmap(sc_pixmap)
|
|
||||||
|
|
||||||
vl.addWidget(l)
|
|
||||||
w.setLayout(vl)
|
|
||||||
self.tabWidget.addTab(w, n)
|
|
||||||
|
|
||||||
if len(self._pokemon['Bilder']) <= 1:
|
|
||||||
self.tabWidget.tabBar().setVisible(False)
|
|
||||||
else:
|
|
||||||
self.tabWidget.tabBar().setVisible(True)
|
|
||||||
self.tabWidget.adjustSize()
|
|
||||||
|
|
||||||
self.name.clear()
|
|
||||||
keys = ['National-Dex', 'Kategorie', 'Typ', 'Größe', 'Gewicht', 'Farbe', 'Link']
|
|
||||||
label_list = [self.pokedex_nr, self.category, self.poketype, self.weight, self.height, self.color, self.info]
|
|
||||||
for (k, label) in zip(keys, label_list):
|
|
||||||
v = self._pokemon[k]
|
|
||||||
if isinstance(v, list):
|
|
||||||
v = os.path.join('', *v)
|
|
||||||
|
|
||||||
if k == 'Link':
|
|
||||||
v = '<a href={}>{}</a>'.format(v, v)
|
|
||||||
|
|
||||||
label.setText(v)
|
|
||||||
|
|
||||||
for k in ['Deutsch', 'Japanisch', 'Englisch', 'Französisch']:
|
|
||||||
v = self._pokemon[k]
|
|
||||||
self.name.addItem(k + ': ' + v)
|
|
||||||
|
|
||||||
self.adjustSize()
|
|
||||||
|
|
||||||
def randomize(self, idd):
|
|
||||||
if idd.text() == 'Retry':
|
|
||||||
new_number = f'{random.randint(1, len(self._js)):03d}'
|
|
||||||
self._id = int(new_number)
|
|
||||||
self.show_pokemon(new_number)
|
|
||||||
else:
|
|
||||||
self.close()
|
|
||||||
|
|
||||||
def show_next(self):
|
|
||||||
new_number = self._id + 1
|
|
||||||
if new_number > len(self._js):
|
|
||||||
new_number = 1
|
|
||||||
self._id = new_number
|
|
||||||
self.show_pokemon(f'{new_number:03d}')
|
|
||||||
|
|
||||||
def show_prev(self):
|
|
||||||
new_number = self._id - 1
|
|
||||||
if new_number == 0:
|
|
||||||
new_number = len(self._js)
|
|
||||||
self._id = new_number
|
|
||||||
self.show_pokemon(f'{new_number:03d}')
|
|
@ -445,7 +445,6 @@ class UpperManagement(QtCore.QObject):
|
|||||||
models[model_id] = m
|
models[model_id] = m
|
||||||
|
|
||||||
m_complex = model_p['complex']
|
m_complex = model_p['complex']
|
||||||
print(model_p)
|
|
||||||
|
|
||||||
# sets are not in active order but in order they first appeared in fit dialog
|
# sets are not in active order but in order they first appeared in fit dialog
|
||||||
# iterate over order of set id in active order and access parameter inside loop
|
# iterate over order of set id in active order and access parameter inside loop
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from io import StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -223,22 +224,25 @@ class FitResult(Points):
|
|||||||
return self.nobs-self.nvar
|
return self.nobs-self.nvar
|
||||||
|
|
||||||
def pprint(self, statistics=True, correlations=True):
|
def pprint(self, statistics=True, correlations=True):
|
||||||
print('Fit result:')
|
s = StringIO()
|
||||||
print(' model :', self.name)
|
s.write('Fit result:\n')
|
||||||
print(' #data :', self.nobs)
|
s.write(f' model : {self.name}\n')
|
||||||
print(' #var :', self.nvar)
|
s.write(f' #data : {self.nobs}\n')
|
||||||
print('\nParameter')
|
s.write(f' #var : {self.nvar}\n')
|
||||||
print(self.parameter_string())
|
s.write('\nParameter\n')
|
||||||
|
s.write(self.parameter_string())
|
||||||
|
|
||||||
if statistics:
|
if statistics:
|
||||||
print('Statistics')
|
s.write('Statistics\n')
|
||||||
for k, v in self.statistics.items():
|
for k, v in self.statistics.items():
|
||||||
print(f' {k} : {v:.4f}')
|
s.write(f' {k} : {v:.4f}')
|
||||||
|
|
||||||
if correlations and self.correlation is not None:
|
if correlations and self.correlation is not None:
|
||||||
print('\nCorrelation (partial corr.)')
|
s.write('\nCorrelation (partial corr.)\n')
|
||||||
print(self._correlation_string())
|
s.write(self._correlation_string())
|
||||||
print()
|
s.write('\n')
|
||||||
|
|
||||||
|
print(s.getvalue())
|
||||||
|
|
||||||
def parameter_string(self):
|
def parameter_string(self):
|
||||||
ret_val = ''
|
ret_val = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user