Skip to content

Commit

Permalink
fix some config problems
Browse files Browse the repository at this point in the history
  • Loading branch information
zain-sohail authored and rettigl committed Oct 7, 2024
1 parent 8ef5807 commit 02aea0a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
21 changes: 13 additions & 8 deletions sed/config/config_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import DirectoryPath
from pydantic import Field
from pydantic import field_validator
from pydantic import FilePath
from pydantic import HttpUrl
Expand Down Expand Up @@ -87,7 +86,7 @@ class subChannel(BaseModel):
class DataframeModel(BaseModel):
columns: ColumnsModel
units: Optional[dict[str, str]] = None
channels: dict[str, ChannelModel] = Field(default_factory=dict)
channels: Optional[dict[str, ChannelModel]] = None
# other settings
tof_binwidth: float
tof_binning: int
Expand Down Expand Up @@ -214,12 +213,18 @@ class Calibration(BaseModel):
calibration: Optional[Calibration] = None

class Offsets(BaseModel):
creation_date: datetime
constant: float
flip_delay_axis: bool
weight: float
preserve_mean: bool
reduction: str
creation_date: Optional[datetime] = None
constant: Optional[float] = None
flip_delay_axis: Optional[bool] = False

## This seems rather complicated way to define offsets,
# inconsistent in how args vs config are for add_offsets
class OffsetColumn(BaseModel):
weight: float
preserve_mean: bool
reduction: Optional[str] = None

columns: Optional[dict[str, OffsetColumn]] = None

offsets: Optional[Offsets] = None

Expand Down
2 changes: 1 addition & 1 deletion sed/loader/mpes/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def hdf5_to_dataframe(

electron_channels = []
column_names = []

print("Print values: ", channels)
for name, channel in channels.items():
if channel["format"] == "per_electron":
if channel["dataset_key"] in test_proc:
Expand Down
7 changes: 3 additions & 4 deletions tests/calibrator/test_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ def test_delay_parameters_from_delay_range_mm() -> None:
"offsets": {
"constant": 1,
"flip_delay_axis": True,
"bam": {
"weight": 0.001,
"preserve_mean": False,
"columns": {
"bam": {"weight": 0.001, "preserve_mean": False},
},
},
},
Expand Down Expand Up @@ -201,7 +200,7 @@ def test_add_offset_from_dict(df=test_dataframe) -> None:
"""test that the timing offset is corrected for correctly from config"""
cfg_ = cfg.copy()
offsets = cfg["delay"]["offsets"] # type:ignore
offsets["bam"].pop("weight")
offsets["columns"]["bam"].pop("weight")
offsets["flip_delay_axis"] = False
cfg_.pop("delay")
config = parse_config(
Expand Down

0 comments on commit 02aea0a

Please sign in to comment.