Ensure the SensorConfig.material is actually a material when possible.#2852
Conversation
| from math import exp | ||
| from collections import namedtuple | ||
| import numpy | ||
| from typing import ClassVar |
There was a problem hiding this comment.
If you import anyways typing, you could consider import of Union and Optional
There was a problem hiding this comment.
Makes sense ... I dislike Union and it is no more recommended since 3.10.
| @dataclass | ||
| class SensorConfig: | ||
| "class for configuration of a sensor" | ||
| material: SensorMaterial|str |
There was a problem hiding this comment.
This would become:
material: Union[SensorMaterial, str]
There was a problem hiding this comment.
| replaces in a simpler way Union since 3.10
| @@ -169,6 +169,12 @@ | |||
There was a problem hiding this comment.
thickness: Optional[float] = None
|
|
||
|
|
||
| @dataclass | ||
| class SensorConfig: |
There was a problem hiding this comment.
Would it make sense to use here actually the frozen decorator? @kif
There was a problem hiding this comment.
Daclasses in pyFAI are slotted ... so not really extendible. That said, frozen dataclasses could make sense.
On the other hand, for frozen object, I would rather use NamedTuple rather than dataclasses that provide non-mutability with better performances.
close #2851