fix: round kev energy
CI / lint (pull_request) Successful in 22s
CI / test (3.11) (pull_request) Successful in 22s
CI / test (3.12) (pull_request) Successful in 22s
CI / test (3.13) (pull_request) Successful in 24s
CI / lint (push) Canceled after 9s
CI / test (3.11) (push) Canceled after 0s
CI / test (3.12) (push) Canceled after 0s
CI / test (3.13) (push) Canceled after 0s
Build and Publish / release (push) Successful in 11s

This commit was merged in pull request #21.
This commit is contained in:
2026-08-20 14:46:27 +02:00
parent 47bfe56cad
commit b2992471ce
+6 -2
View File
@@ -1,11 +1,15 @@
import math
from typing import Annotated
from pydantic import BaseModel, Field
from pydantic import AfterValidator, BaseModel, Field
def round_dp(ndigits: int, /) -> AfterValidator:
return AfterValidator(lambda v: round(v, ndigits))
class DiffractionGeometry(BaseModel):
energy_keV: Annotated[float, Field(gt=1.0, lt=100.0)]
energy_keV: Annotated[float, Field(gt=1.0, lt=100.0), round_dp(3)]
dtz_mm: Annotated[float, Field(gt=10.0, lt=5000.0)]
pixel_size_mm: Annotated[float, Field(ge=0.05, le=0.5)]
beam_center_pxl: tuple[float, float]