Skip to content

Commit

Permalink
Update ruff and bumpversion configs
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Jun 17, 2024
1 parent d6c48a2 commit 9b3bdc4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 89 deletions.
17 changes: 0 additions & 17 deletions .bumpversion.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ doi: "10.5281/zenodo.1090388"
license: "BSD-3-Clause"
message: "If you use this software, please cite it using these metadata."
title: Instamatic
version: "2.0.1"
version: "2.0.2"
...
70 changes: 27 additions & 43 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
# https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
[project]
name = "instamatic"
version = "2.0.1"
version = "2.0.2"
description = "Python program for automated electron diffraction data collection"
readme = "README.md"
requires-python = ">=3.7"
Expand Down Expand Up @@ -125,19 +125,14 @@ target-version = 'py37'
line-length = 96

[tool.ruff.lint]
# Enable Pyflakes `E` and `F` codes by default.
select = [
'F', # Pyflakes
'E', # pycodestyle (error)
'W', # pycodestyle (warning)
'I', # isort
'UP', # pyupgrade
'A', # flake8-builtins
'COM', # flake8-commas
'C4', # flake8-comprehensions
'TID', # flake8-tidy-imports
'NPY201', # numpy deprecation
"F", # Pyflakes
"E", # pycodestyle (error)
"W", # pycodestyle (warning)
"I", # isort
"NPY201", # numpy deprecations
]

ignore = [
'F401',
'F403',
Expand All @@ -148,38 +143,27 @@ ignore = [
'A003',
]

[tool.ruff.lint.isort]
known-first-party = ['instamatic']

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ['A', 'B', 'C', 'D', 'E', 'F', 'I', 'UP', 'BLE', 'COM', 'C4', 'TID',]
unfixable = []
[tool.ruff.format]
quote-style = "single"
indent-style = "space"

exclude = [
'.bzr',
'.direnv',
'.eggs',
'.git',
'.hg',
'.mypy_cache',
'.nox',
'.pants.d',
'.ruff_cache',
'.svn',
'.tox',
'.venv',
'__pypackages__',
'_build',
'buck-out',
'build',
'dist',
'node_modules',
'venv',
'.venv',
'scripts',
]
per-file-ignores = {}
[tool.bumpversion]
current_version = "2.0.2"

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = '^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$'
[[tool.bumpversion.files]]
filename = "src/instamatic/__init__.py"
search = "__version__ = '{current_version}'"
replace = "__version__ = '{new_version}'"

[tool.ruff.lint.isort]
known-first-party = ['instamatic']
[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "CITATION.cff"
search = "version: {current_version}"
replace = "version: {new_version}"
2 changes: 1 addition & 1 deletion src/instamatic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # #
"""

__version__ = '2.0.1'
__version__ = '2.0.2'
__title__ = 'instamatic'
__long_title__ = f'{__title__} v{__version__}'
__author__ = 'Stef Smeets'
Expand Down
6 changes: 3 additions & 3 deletions src/instamatic/camera/camera_timepix.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def read_pixels_cfg(self, filename):
sys.exit()

def process_real_dac(self, chipnr=None, index=None, key=None, value=None):
"""int *chipnr."""
"""Int *chipnr."""
'int *index'
'std::string *key'
'std::string *value'
Expand Down Expand Up @@ -237,7 +237,7 @@ def enable_timer(self, enable, us):
After the Relaxd shutter opens (either explicitly by software or by an
external trigger), it closes again after the set time.
bool enable
bool enable
int us = 10 # microseconds
"""
enable = c_bool(enable)
Expand All @@ -258,7 +258,7 @@ def set_acq_pars(self, pars):
self.lib.EMCameraObj_setAcqPars(self.obj, byref(pars))

def is_busy(self, busy):
"""bool *busy."""
"""Bool *busy."""
busy = c_bool(busy)
self.lib.EMCameraObj_isBusy(self.obj, byref(busy))

Expand Down
28 changes: 10 additions & 18 deletions src/instamatic/experiments/autocred/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ def img_var(self, img, apert_pos):
return np.var(img)

def check_img_outsidebeam_byscale(self, img1_scale, img2_scale):
"""`img1` is the original image for reference, `img2` is the new image."""
"""`img1` is the original image for reference, `img2` is the new
image."""
if img2_scale / img1_scale < 0.5 or img2_scale / img1_scale > 2:
return 1
else:
Expand Down Expand Up @@ -595,15 +596,6 @@ def auto_cred_collection(self, path, pathtiff, pathsmv, pathred, transform_imgsh

img0, h = self.defocus_and_image(difffocus=self.diff_defocus, exp_t=self.exposure_time_image)

"""if trackmethod == "p":
shift = self.tracking_by_particlerecog(img0)
delta_beamshiftcoord = np.matmul(self.calib_beamshift.transform, shift)
self.logger.debug("Beam shift coordinates: {}".format(delta_beamshiftcoord))
bs_x0, bs_y0 = self.setandupdate_bs(bs_x0, bs_y0, delta_beamshiftcoord)
img0, h = self.defocus_and_image(difffocus = self.diff_defocus, exp_t = self.exposure_time_image)"""

img0_p = preprocess(img0.astype(float))
scorefromCNN = predict(img0_p)
# self.print_and_log(logger = self.logger, msg = "Score for the DP: {}".format(scorefromCNN))
Expand Down Expand Up @@ -645,8 +637,8 @@ def auto_cred_collection(self, path, pathtiff, pathsmv, pathred, transform_imgsh
numb_robustTrack = 0
"""Turn on and off for crystal movement guess here."""
self.guess_crystmove = False

"""set acquisition time to be around 0.52 s in order to fix the image interval times."""
"""Set acquisition time to be around 0.52 s in order to fix the image
interval times."""
acquisition_time = self.expt + 0.02

self.ctrl.cam.block()
Expand All @@ -665,8 +657,8 @@ def auto_cred_collection(self, path, pathtiff, pathsmv, pathred, transform_imgsh
numb_robustTrack += 1
else:
self.image_interval = self.nom_ii

"""If variance changed over 20%, do a robust check to ensure crystal is back"""
"""If variance changed over 20%, do a robust check to
ensure crystal is back."""

if imgvar / img0var < 0.5 or imgvar / img0var > 2 or imgscale / imgscale0 > 1.15 or imgscale / imgscale0 < 0.85:
self.image_interval = self.robust_ii
Expand All @@ -683,8 +675,8 @@ def auto_cred_collection(self, path, pathtiff, pathsmv, pathred, transform_imgsh

if i % self.image_interval == 0: # aim to make this more dynamically adapted...
t_start = time.perf_counter()

"""Guessing the next particle position by simply apply the same beamshift change as previous"""
"""Guessing the next particle position by simply apply the
same beamshift change as previous."""
if self.guess_crystmove and i >= self.nom_ii:
bs_x0, bs_y0 = self.setandupdate_bs(bs_x0, bs_y0, delta_beamshiftcoord)

Expand All @@ -701,8 +693,8 @@ def auto_cred_collection(self, path, pathtiff, pathsmv, pathred, transform_imgsh
imgvar = self.img_var(img_cropped, crystal_pos)

self.logger.debug(f'Image variance: {imgvar}')

"""If variance changed over 50%, then the crystal is outside the beam and stop data collection"""
"""If variance changed over 50%, then the crystal is
outside the beam and stop data collection."""
if imgvar / img0var < 0.2 or imgvar / img0var > 5:
self.print_and_del('Collection stopping because crystal out of the beam...')
self.stopEvent.set()
Expand Down
10 changes: 4 additions & 6 deletions src/instamatic/server/vm_ubuntu_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ def start_vm_process(vmname=VM_ID, vmachine_pwd=VM_PWD, time_delay=VM_DELAY1, mo
machine = vbox.find_machine(vmname)
progress = machine.launch_vm_process(session, mode, '')
progress.wait_for_completion()

"""wait for certain sec to ensure a normal vm startup"""
"""Wait for certain sec to ensure a normal vm startup."""
time.sleep(time_delay)

"""assume vm is password protected"""
"""Assume vm is password protected."""
session.console.keyboard.put_keys(vmachine_pwd)
session.console.keyboard.put_keys(['ENTER'])
print('password delivered!')
Expand Down Expand Up @@ -117,8 +115,8 @@ def vm_ubuntu_start_xds_AtFolder(session, conn, shelxt, unitcell, spgr, composit

session.console.keyboard.put_keys('xds')
session.console.keyboard.put_keys(['ENTER'])

"""Not sure if I should put some delay here, but just to avoid neglected communication"""
"""Not sure if I should put some delay here, but just to avoid
neglected communication."""
time.sleep(120)

if shelxt:
Expand Down

0 comments on commit 9b3bdc4

Please sign in to comment.