Skip to content

Commit 1f5d726

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 40b16b8 commit 1f5d726

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

baseline/indexer/index_module.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <nanobind/eigen/dense.h>
22
#include <nanobind/nanobind.h>
33
#include <nanobind/stl/array.h>
4+
#include <nanobind/stl/string.h>
45
#include <nanobind/stl/tuple.h>
56
#include <nanobind/stl/vector.h>
6-
#include <nanobind/stl/string.h>
77

88
#include <dx2/crystal.hpp>
99
#include <dx2/detector.hpp>
@@ -222,7 +222,9 @@ NB_MODULE(index, m) {
222222
.def_prop_ro("delpsi", [](const IndexingResult &r) { return r.delpsi; })
223223
.def_prop_ro("rmsds", [](const IndexingResult &r) { return r.rmsds; });
224224
m.def("make_panel", &make_panel, "Create a configured Panel object");
225-
m.def("calculate_mu_for_material_at_wavelength", &calculate_mu_for_material_at_wavelength, "Calculate the absorption coefficient from material and wavelength");
225+
m.def("calculate_mu_for_material_at_wavelength",
226+
&calculate_mu_for_material_at_wavelength,
227+
"Calculate the absorption coefficient from material and wavelength");
226228
m.def("ssx_xyz_to_rlp",
227229
&ssx_xyz_to_rlp,
228230
nb::arg("xyzobs_px"),

src/ffs/service.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
from datetime import datetime
1313
from enum import Enum
1414
from pathlib import Path
15-
from typing import Iterator, Optional, Union, Literal
16-
import pydantic
15+
from typing import Iterator, Literal, Optional, Union
1716

1817
import gemmi
1918
import numpy as np
19+
import pydantic
2020
import workflows.recipe
21-
from pydantic import BaseModel, ValidationError, Field, PrivateAttr
21+
from pydantic import BaseModel, Field, PrivateAttr, ValidationError
2222
from rich.logging import RichHandler
2323
from workflows.services.common_service import CommonService
2424

@@ -62,16 +62,19 @@ def check_unit_cell(cls, v):
6262
raise ValueError(f"Invalid unit_cell {orig_v}")
6363
return v
6464

65+
6566
class Material(str, Enum):
6667
Si = "Si"
6768
CdTe = "CdTe"
6869

70+
6971
class DetectorParameters(BaseModel):
7072
"""
7173
Define a set of detector metadata that derived classes
7274
need to provide.
7375
This class is not to be instantiated directly.
7476
"""
77+
7578
detector_type: str
7679
thickness: float
7780
material: Material
@@ -86,7 +89,8 @@ def __init_subclass__(cls, **kwargs):
8689
# enforce setting of defaults for all fields in subclasses.
8790
super().__init_subclass__(**kwargs)
8891
missing_defaults = [
89-
name for name, field in cls.__fields__.items()
92+
name
93+
for name, field in cls.__fields__.items()
9094
if field.default is None and field.default_factory is None
9195
]
9296
if missing_defaults:
@@ -96,25 +100,28 @@ def __init_subclass__(cls, **kwargs):
96100

97101
def calculate_mu(self, wavelength: float) -> float:
98102
if wavelength not in self._mu_cache:
99-
self._mu_cache[wavelength] = ffs.index.calculate_mu_for_material_at_wavelength(
100-
self.material, wavelength
103+
self._mu_cache[wavelength] = (
104+
ffs.index.calculate_mu_for_material_at_wavelength(
105+
self.material, wavelength
106+
)
101107
)
102108
return self._mu_cache[wavelength]
103109

104110

105111
class Eiger16M(DetectorParameters):
106112
detector_type: Literal["Eiger16M"]
107113
thickness: float = 0.45
108-
material : Material = Material.Si
114+
material: Material = Material.Si
109115
pixel_size_x: float = 0.075
110116
pixel_size_y: float = 0.075
111117
image_size_x: int = 4148
112118
image_size_y: int = 4362
113119

120+
114121
class Eiger4M(DetectorParameters):
115122
detector_type: Literal["Eiger4M"]
116123
thickness: float = 0.45
117-
material : Material = Material.Si
124+
material: Material = Material.Si
118125
pixel_size_x: float = 0.075
119126
pixel_size_y: float = 0.075
120127
image_size_x: int = 2068
@@ -124,7 +131,7 @@ class Eiger4M(DetectorParameters):
124131
class Eiger9MCdTe(DetectorParameters):
125132
detector_type: Literal["Eiger9MCdTe"]
126133
thickness: float = 0.75
127-
material : Material = Material.CdTe
134+
material: Material = Material.CdTe
128135
pixel_size_x: float = 0.075
129136
pixel_size_y: float = 0.075
130137
image_size_x: int = 3108
@@ -135,7 +142,9 @@ class DetectorGeometry(BaseModel):
135142
distance: float
136143
beam_center_x: float
137144
beam_center_y: float
138-
detector: Union[Eiger9MCdTe, Eiger16M, Eiger4M] = Field(..., discriminator="detector_type")
145+
detector: Union[Eiger9MCdTe, Eiger16M, Eiger4M] = Field(
146+
..., discriminator="detector_type"
147+
)
139148

140149
def to_json(self):
141150
d = self.dict()
@@ -298,7 +307,7 @@ def gpu_per_image_analysis(
298307
distance=parameters.detector_distance,
299308
beam_center_x=parameters.xBeam,
300309
beam_center_y=parameters.yBeam,
301-
detector={"detector_type" : parameters.detector},
310+
detector={"detector_type": parameters.detector},
302311
)
303312
self.log.debug("{detector_geometry.to_json()=}")
304313
except ValidationError as e:

0 commit comments

Comments
 (0)