Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ci:
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
Expand All @@ -21,45 +21,45 @@ repos:
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 24.4.2
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 9.0.0a3
hooks:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
rev: 0.9.1
hooks:
- id: nbstripout
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: no-commit-to-branch
name: Prevent Commit to Main Branch
args: ["--branch", "main"]
stages: [pre-commit]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
rev: v2.4.2
hooks:
- id: codespell
additional_dependencies:
- tomli
# prettier - multi formatter for .json, .yml, and .md files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
rev: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
- "prettier@^3.2.4"
# docformatter - PEP 257 compliant docstring formatter
- repo: https://github.com/s-weigand/docformatter
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.8
hooks:
- id: docformatter
additional_dependencies: [tomli]
Expand Down
23 changes: 23 additions & 0 deletions news/pre-commit-update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* No News Added: updated the pre-commit workflow version

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
11 changes: 9 additions & 2 deletions src/diffpy/srxplanargui/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ class SrXguiHelp(HasTraits):
enabled_when="object.qsindex<object.qslen",
)
previous_action = Action(
name="Previous", action="_qsprevious", enabled_when="object.qsindex>0"
name="Previous",
action="_qsprevious",
enabled_when="object.qsindex>0",
)
cpreference_action = Action(
name="Copy to clipboard",
Expand Down Expand Up @@ -93,7 +95,12 @@ def _get_qsimage(self):
width=hwidth,
height=hheight,
resizable=True,
buttons=[cpreference_action, previous_action, next_action, OKButton],
buttons=[
cpreference_action,
previous_action,
next_action,
OKButton,
],
handler=HelpHandler(),
icon=ImageResource("icon.png"),
)
Expand Down
51 changes: 30 additions & 21 deletions src/diffpy/srxplanargui/imageplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
##############################################################################
"""Plot the 2d image."""

import os

import numpy as np
Expand Down Expand Up @@ -114,7 +115,8 @@ class ImagePlot(HasTraits):
),
)
brightpixelsize = DelegatesTo(
"srxconfig", desc="Size of testing area for detecting bright pixels"
"srxconfig",
desc="Size of testing area for detecting bright pixels",
)
darkpixelr = DelegatesTo(
"srxconfig",
Expand Down Expand Up @@ -532,15 +534,22 @@ def __init__(self, **kwargs):
VGroup(
HGroup(
Item("addpolygon_bb", enabled_when="not maskediting"),
Item("removepolygon_bb", enabled_when="not maskediting"),
Item(
"removepolygon_bb",
enabled_when="not maskediting",
),
spring,
Item("maskabove_bb", enabled_when="not maskediting"),
Item("maskaboveint", enabled_when="not maskediting"),
show_labels=False,
),
HGroup(
Item("addpoint_bb", enabled_when="not maskediting"),
Item("pointmaskradius", label="Size:", show_label=True),
Item(
"pointmaskradius",
label="Size:",
show_label=True,
),
spring,
Item("maskbelow_bb", enabled_when="not maskediting"),
Item("maskbelowint", enabled_when="not maskediting"),
Expand All @@ -549,7 +558,10 @@ def __init__(self, **kwargs):
HGroup(
Item("clearmask_bb", enabled_when="not maskediting"),
Item("invertmask_bb", enabled_when="not maskediting"),
Item("advancedmask_bb", enabled_when="not maskediting"),
Item(
"advancedmask_bb",
enabled_when="not maskediting",
),
spring,
Item("loadmaskfile_bb"),
Item("savemaskfile_bb"),
Expand Down Expand Up @@ -685,23 +697,20 @@ def normal_left_down(self, event):


class AdvHint(HasTraits):
advhinttext = str(
"""Notes: Advanced Masks are generated during the integration
and refreshed for each image.
You can preview the masks here or apply the current masks
to the static mask permanently.

Edge mask: mask the pixels around the image edge.
(left, right, top, bottom)

Dark pixel mask: mask the pixels too dark
compared to their local environment

Bright pixel mask: mask the pixels too bright
compared to their local environment
Average mask: Mask the pixels too bright or too dark
compared to the average intensity at the similar diffraction angle.
Correct calibration information is required."""
advhinttext = Str(
"Notes: Advanced Masks are generated during the integration\n"
"and refreshed for each image.\n"
"You can preview the masks here or apply the current masks\n"
"to the static mask permanently.\n\n"
"Edge mask: mask the pixels around the image edge.\n"
"(left, right, top, bottom)\n\n"
"Dark pixel mask: mask the pixels too dark\n"
"compared to their local environment\n\n"
"Bright pixel mask: mask the pixels too bright\n"
"compared to their local environment\n"
"Average mask: Mask the pixels too bright or too dark\n"
"compared to the average intensity at the similar diffraction angle.\n"
"Correct calibration information is required."
)

advhint_view = View(
Expand Down
4 changes: 3 additions & 1 deletion src/diffpy/srxplanargui/selectfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def _plotbb_fired(self):
if imagefile is not None:
if os.path.exists(imagefile):
imageplot = ImagePlot(
imagefile=imagefile, srx=self.srx, srxconfig=self.srxconfig
imagefile=imagefile,
srx=self.srx,
srxconfig=self.srxconfig,
)
# imageplot.createPlot()
imageplot.edit_traits()
Expand Down
19 changes: 14 additions & 5 deletions src/diffpy/srxplanargui/srxconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,21 @@ class SrXconfig(ConfigBaseTraits):

_optdatalist = _optdatalist

_defaultdata = {"configfile": [], "headertitle": "SrXgui configuration"}
_defaultdata = {
"configfile": [],
"headertitle": "SrXgui configuration",
}

rotation = Property(
depends_on="rotationd", fget=lambda self: np.radians(self.rotationd)
depends_on="rotationd",
fget=lambda self: np.radians(self.rotationd),
)
tilt = Property(
depends_on="tiltd", fget=lambda self: np.radians(self.tiltd)
)
tthstep = Property(
depends_on="tthstepd", fget=lambda self: np.radians(self.tthstepd)
depends_on="tthstepd",
fget=lambda self: np.radians(self.tthstepd),
)
tthmax = Property(
depends_on="tthmaxd", fget=lambda self: np.radians(self.tthmaxd)
Expand Down Expand Up @@ -181,7 +186,9 @@ def _refreshPSsize(self, obj, name, new):

directory_group = Group(
Item(
"opendirectory", label="Input dir.", help="directory of 2D images"
"opendirectory",
label="Input dir.",
help="directory of 2D images",
),
Item(
"savedirectory",
Expand Down Expand Up @@ -213,7 +220,9 @@ def _refreshPSsize(self, obj, name, new):
visible_when='configmode == "TEM"',
),
Item(
"distance", label="Distance", visible_when='configmode == "normal"'
"distance",
label="Distance",
visible_when='configmode == "normal"',
),
Item("rotationd", label="Rotation"),
Item("tiltd", label="Tilt rotation"),
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ def user_filesystem(tmp_path):
cwd_dir = base_dir / "cwd_dir"
cwd_dir.mkdir(parents=True, exist_ok=True)

home_config_data = {"username": "home_username", "email": "home@email.com"}
home_config_data = {
"username": "home_username",
"email": "home@email.com",
}
with open(home_dir / "diffpyconfig.json", "w") as f:
json.dump(home_config_data, f)

Expand Down
Loading