cleanup of text reader
This commit is contained in:
parent
a4950839d0
commit
2ed390ccae
@ -1,7 +1,7 @@
|
||||
from nmreval.io.asciireader import AsciiReader
|
||||
|
||||
from gui_qt.Qt import QtGui, QtCore, QtWidgets
|
||||
from gui_qt._py.asciidialog import Ui_ascii_reader
|
||||
from ..Qt import QtGui, QtCore, QtWidgets
|
||||
from .._py.asciidialog import Ui_ascii_reader
|
||||
|
||||
|
||||
class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
|
||||
@ -208,14 +208,3 @@ class QAsciiReader(QtWidgets.QDialog, Ui_ascii_reader):
|
||||
def skip_next_dial(self, _: int):
|
||||
print('skippy das buschkänguru', _)
|
||||
self.skip = self.skippy_checkbox.isChecked()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QtWidgets.QApplication([])
|
||||
# w = QAsciiReader(fname='/autohome/dominik/nmreval/testdata/T_1_omega/250.dat')
|
||||
# w = QAsciiReader(fname='/autohome/dominik/nmreval/testdata/alter_fit_fitparameter.dat')
|
||||
w = QAsciiReader(fname='/autohome/dominik/nmreval/testdata/alter_fit_fitparameter2.dat')
|
||||
# w = QAsciiReader(fname='/autohome/dominik/nmreval/testdata/alter_fit_fit_200.dat')
|
||||
|
||||
w.show()
|
||||
app.exec()
|
||||
|
@ -70,10 +70,10 @@ class Points:
|
||||
|
||||
if x.shape != y.shape:
|
||||
# remove ugly 1-length dims
|
||||
x = np.squeeze(x)
|
||||
y = np.squeeze(y)
|
||||
if x.shape != y.shape:
|
||||
raise ValueError(f'x ({x.shape}) and y ({y.shape}) have different shapes')
|
||||
try:
|
||||
y = y.reshape(x.shape)
|
||||
except ValueError as e:
|
||||
raise ValueError(f'x ({x.shape}) and y ({y.shape}) have different shapes') from e
|
||||
|
||||
mask = np.ones_like(x, dtype=bool)
|
||||
|
||||
@ -86,7 +86,7 @@ class Points:
|
||||
y_err = np.atleast_1d(y_err)
|
||||
if y_err.shape != y.shape:
|
||||
raise ValueError(f'y_err ({y_err.shape}) and y ({y.shape}) have different shapes')
|
||||
|
||||
print(x, x.shape, x.ndim)
|
||||
return x, y, y_err, mask
|
||||
|
||||
@property
|
||||
|
@ -1,7 +1,6 @@
|
||||
import pathlib
|
||||
import re
|
||||
from collections import OrderedDict
|
||||
from itertools import islice, zip_longest
|
||||
from itertools import islice
|
||||
|
||||
import numpy as np
|
||||
|
||||
@ -30,36 +29,6 @@ class AsciiReader:
|
||||
self.make_preview(10)
|
||||
self.look_for_delay()
|
||||
|
||||
def load_file(self, comments='#'):
|
||||
i = 0
|
||||
with self.fname.open('r') as f:
|
||||
for line in f:
|
||||
line = line.rstrip('\n\t\r, ')
|
||||
|
||||
if line.startswith(comments):
|
||||
self.header.append(line.replace(comments, '').strip())
|
||||
|
||||
else:
|
||||
if line == '':
|
||||
continue
|
||||
line = re.split('[\s,;]', line)
|
||||
try:
|
||||
comment_start = line.index('#')
|
||||
self.line_comment.append(' '.join(line[comment_start:]))
|
||||
line = line[:comment_start]
|
||||
except ValueError:
|
||||
self.line_comment.append('')
|
||||
|
||||
self.width = max(self.width, len(line))
|
||||
self.data.append(line)
|
||||
|
||||
i += 1
|
||||
if i == self.maxcount:
|
||||
break
|
||||
|
||||
if all(l == '' for l in self.line_comment):
|
||||
self.line_comment = []
|
||||
|
||||
def read_header(self, comments='#'):
|
||||
with self.fname.open('r') as f:
|
||||
for line in f.readlines():
|
||||
|
Loading…
Reference in New Issue
Block a user