Skip to content

Commit

Permalink
Run all ruff fixes (including unsafe, manually checked)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndevenish committed Jun 6, 2024
1 parent 1f5e462 commit 49fdb25
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/dxtbx/format/Format.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def __init__(self, image_file, **kwargs):
# Don't allow abstract instantion
# - except for Format, which is used as a placeholder in many
# places (e.g. still, check_format=False) so needs to be allowed.
if self.is_abstract() and not type(self) is Format:
if self.is_abstract() and type(self) is not Format:
raise TypeError(
f"Cannot instantiate: Format class '{type(self).__name__}' is marked abstract"
)
Expand Down
4 changes: 2 additions & 2 deletions src/dxtbx/format/FormatXTC.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ def filter_event(self, evt):
codes = self._evr.eventCodes(evt)

if self.params.filter.required_present_codes and not all(
[c in codes for c in self.params.filter.required_present_codes]
c in codes for c in self.params.filter.required_present_codes
):
return False
if self.params.filter.required_absent_codes and any(
[c in codes for c in self.params.filter.required_absent_codes]
c in codes for c in self.params.filter.required_absent_codes
):
return False
return True
Expand Down
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatXTCEpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def understand(image_file):
params = FormatXTC.params_from_phil(epix_locator_scope, image_file)
except Exception:
return False
return any(["epix" in src.lower() for src in params.detector_address])
return any("epix" in src.lower() for src in params.detector_address)

def get_raw_data(self, index=None):
if index is None:
Expand Down
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatXTCJungfrau.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def understand(image_file):
params = FormatXTC.params_from_phil(jungfrau_locator_scope, image_file)
except Exception:
return False
return any(["jungfrau" in src.lower() for src in params.detector_address])
return any("jungfrau" in src.lower() for src in params.detector_address)

def get_raw_data(self, index=None):
from serialtbx.detector.util import jungfrau
Expand Down
6 changes: 3 additions & 3 deletions src/dxtbx/format/FormatXTCMultipleDetectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

class FormatXTCMultipleDetectors(FormatXTCRayonix, FormatXTCCspad, FormatXTCJungfrau):
def __init__(self, image_file, **kwargs):
if any(["rayonix" in src.lower() for src in self.params.detector_address]):
if any("rayonix" in src.lower() for src in self.params.detector_address):
FormatXTCRayonix.__init__(self, image_file, **kwargs)
if any(["cspad" in src.lower() for src in self.params.detector_address]):
if any("cspad" in src.lower() for src in self.params.detector_address):
FormatXTCCspad.__init__(self, image_file, **kwargs)
if any(["jungfrau" in src.lower() for src in self.params.detector_address]):
if any("jungfrau" in src.lower() for src in self.params.detector_address):
FormatXTCJungfrau.__init__(self, image_file, **kwargs)
FormatXTC.__init__(
self, image_file, locator_scope=multiple_locator_scope, **kwargs
Expand Down
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatXTCRayonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def understand(image_file):
params = FormatXTC.params_from_phil(rayonix_locator_scope, image_file)
except Exception:
return False
return any(["rayonix" in src.lower() for src in params.detector_address])
return any("rayonix" in src.lower() for src in params.detector_address)

def get_raw_data(self, index=None):
if index is None:
Expand Down
8 changes: 4 additions & 4 deletions src/dxtbx/format/nxmx_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ def recursive_setup_basis_dict(key, parent_name="", panel_id=0):
det["description"] = "Detector converted from DIALS models"
det["depends_on"] = "/entry/instrument/detector/transformations/AXIS_RAIL"
det["gain_setting"] = "auto"
assert len(set([p.get_material() for p in detector])) == 1
assert len(set([p.get_thickness() for p in detector])) == 1
assert len({p.get_material() for p in detector}) == 1
assert len({p.get_thickness() for p in detector}) == 1
det["sensor_material"] = detector[0].get_material()
self._create_scalar(
det, "sensor_thickness", "f", detector[0].get_thickness() * 1000
Expand Down Expand Up @@ -395,7 +395,7 @@ def recursive_setup_basis_dict(key, parent_name="", panel_id=0):
transformations.attrs["NX_class"] = "NXtransformations"

if self.params.trusted_range is None:
assert len(set([p.get_trusted_range() for p in detector])) == 1
assert len({p.get_trusted_range() for p in detector}) == 1
trusted_min, trusted_max = detector[0].get_trusted_range()
else:
trusted_min, trusted_max = self.params.trusted_range
Expand Down Expand Up @@ -666,7 +666,7 @@ def append_frame(self, index=None, data=None):
data = (data,)

if len(data) > 1:
assert len(set([d.focus() for d in data])) == 1
assert len({d.focus() for d in data}) == 1
shape = len(data), data[0].focus()[0], data[0].focus()[1]
else:
shape = data[0].focus()[0], data[0].focus()[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_flumpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ def test_flex_looping_vecs():

# Don't be dumb when casting
flex_nonvec = flex.double((9, 3))
assert not flumpy.vec_from_numpy(flumpy.to_numpy(flex_nonvec)) is flex_nonvec
assert flumpy.vec_from_numpy(flumpy.to_numpy(flex_nonvec)) is not flex_nonvec

# mat3
fo = flex.mat3_double(5)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_regression_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def recurse(parentformat, filename, level=0):
multiple_formats = False
for subformat in dag.get(parentformat, []):
format_class = dxtbx.format.Registry.get_format_class_for(subformat)
if not get_url_scheme(filename) in format_class.schemes:
if get_url_scheme(filename) not in format_class.schemes:
print("Not matching ", filename, "to", format_class)
continue
understood = format_class.understand(filename)
Expand Down

0 comments on commit 49fdb25

Please sign in to comment.