Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 2, 2024
1 parent 5946a21 commit 0d080ee
Showing 1 changed file with 39 additions and 54 deletions.
93 changes: 39 additions & 54 deletions src/erlab/interactive/curvefittingtool.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,55 +447,43 @@ def __init__(self, data, n_bands: int = 1, parameters=None, *args, **kwargs):
self._options = QtWidgets.QWidget(self)
self._options_layout = QtWidgets.QVBoxLayout(self._options)
self._params_init = ParameterGroup(
**{
"n_bands": dict(
showlabel="# Bands",
qwtype="btspin",
integer=True,
value=n_bands,
minimum=1,
fixedWidth=60,
notrack=True,
valueChanged=self.refresh_n_peaks,
),
"lin_bkg": dict(
qwtype="fitparam",
showlabel="Linear Background",
name="lin_bkg",
spin_kw=dict(value=0.0, minimumWidth=200),
),
"const_bkg": dict(
qwtype="fitparam",
showlabel="Constant Background",
name="const_bkg",
spin_kw=dict(value=0.0, minimumWidth=200),
),
"resolution": dict(
qwtype="fitparam",
showlabel="Total Resolution",
name="resolution",
spin_kw=dict(
value=0.01, singleStep=0.0001, decimals=4, minimumWidth=200
),
),

# "Fix T": dict(qwtype="chkbox", checked=True),
# "Bin x": dict(qwtype="spin", value=1, minimum=1),
# "Bin y": dict(qwtype="spin", value=1, minimum=1),
"Method": dict(qwtype="combobox", items=LMFIT_METHODS),
# "# CPU": dict(
# qwtype="spin",
# value=os.cpu_count(),
# minimum=1,
# maximum=os.cpu_count(),
# ),
"go": dict(
qwtype="pushbtn",
showlabel=False,
text="Go",
clicked=self.do_fit,
n_bands=dict(
showlabel="# Bands",
qwtype="btspin",
integer=True,
value=n_bands,
minimum=1,
fixedWidth=60,
notrack=True,
valueChanged=self.refresh_n_peaks,
),

Check failure on line 459 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:450:21: C408 Unnecessary `dict` call (rewrite as a literal)
lin_bkg=dict(
qwtype="fitparam",
showlabel="Linear Background",
name="lin_bkg",
spin_kw=dict(value=0.0, minimumWidth=200),

Check failure on line 464 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:464:25: C408 Unnecessary `dict` call (rewrite as a literal)
),

Check failure on line 465 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:460:21: C408 Unnecessary `dict` call (rewrite as a literal)
const_bkg=dict(
qwtype="fitparam",
showlabel="Constant Background",
name="const_bkg",
spin_kw=dict(value=0.0, minimumWidth=200),

Check failure on line 470 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:470:25: C408 Unnecessary `dict` call (rewrite as a literal)
),

Check failure on line 471 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:466:23: C408 Unnecessary `dict` call (rewrite as a literal)
resolution=dict(
qwtype="fitparam",
showlabel="Total Resolution",
name="resolution",
spin_kw=dict(
value=0.01, singleStep=0.0001, decimals=4, minimumWidth=200
),

Check failure on line 478 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:476:25: C408 Unnecessary `dict` call (rewrite as a literal)
}
),

Check failure on line 479 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:472:24: C408 Unnecessary `dict` call (rewrite as a literal)
Method=dict(qwtype="combobox", items=LMFIT_METHODS),

Check failure on line 480 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:480:20: C408 Unnecessary `dict` call (rewrite as a literal)
go=dict(
qwtype="pushbtn",
showlabel=False,
text="Go",
clicked=self.do_fit,
),

Check failure on line 486 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:481:16: C408 Unnecessary `dict` call (rewrite as a literal)
)
#

Expand Down Expand Up @@ -557,7 +545,7 @@ def n_bands(self):
@property
def params_dict(self):
out = dict()

Check failure on line 547 in src/erlab/interactive/curvefittingtool.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (C408)

src/erlab/interactive/curvefittingtool.py:547:15: C408 Unnecessary `dict` call (rewrite as a literal)
for k in ("lin_bkg", "const_bkg","resolution"):
for k in ("lin_bkg", "const_bkg", "resolution"):
out = out | self._params_init.widgets[k].param_dict
for i in range(self.n_bands):
peak_widget = self._params_peak.widget(i)
Expand All @@ -575,7 +563,7 @@ def model(self):
peak_shapes=[
self._params_peak.widget(i).peak_shape for i in range(self.n_bands)
],
fd=False
fd=False,
)

def refresh_n_peaks(self):
Expand Down Expand Up @@ -631,7 +619,7 @@ def do_fit(self):
print(res.best_values)
self.fitplot.setData(x=self.xdata, y=res.best_fit)
self.set_params(res.best_values)

self.result = res

def set_params(self, params: dict):
Expand Down Expand Up @@ -668,9 +656,6 @@ def __post_init__(self, execute=None):
self.qapp.exec()





if __name__ == "__main__":
data = xr.open_dataarray(
"~/Library/CloudStorage/Dropbox-KAIST_12/Kimoon Han/ERLab/Projects/TiSe2 Chiral"
Expand Down

0 comments on commit 0d080ee

Please sign in to comment.