Skip to content

Commit 1872c7c

Browse files
lukeshinglesclaude
andcommitted
Address PR review comments
Log the phixs output file under its real name, phixsdata_v2.txt, rather than the phixsdata2.txt that no stage of the run writes. Drop the ionization_energy_ev = 0.0 initialiser in read_ion_data(): all four handler branches set it and an unknown handler raises, so the default could only ever mask a branch that forgot to. In test_add_handler_if_not_set, check the input list once at the end instead of repeating the same comparison after each call. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent ad02cb4 commit 1872c7c

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

artisatomic/iondata.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ def read_ion_data(
8787
"""
8888
ion_stage, handler = ion_stage_entry
8989

90-
ionization_energy_ev = 0.0
90+
# no default for ionization_energy_ev: every handler branch below sets it, and an unknown
91+
# handler raises, so a branch that forgets should fail rather than write a 0 eV threshold
9192
transition_count_of_level_name: dict[str, int] = {}
9293
upsilondict: dict[tuple[int, int], float] = {}
9394
hillier_photoion_targetconfigs: list[list[tuple[str, float]] | None] | None = None

artisatomic/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def write_phixs_data(
292292
]
293293
skipped_no_threshold = len(levelids_with_targets) - len(levelids_to_write)
294294

295-
log_and_print(flog, f"Writing {len(levelids_to_write)} phixs tables to 'phixsdata2.txt'")
295+
log_and_print(flog, f"Writing {len(levelids_to_write)} phixs tables to 'phixsdata_v2.txt'")
296296
flog.write(
297297
f"Downsampling cross sections assuming T={args.optimaltemperature} Kelvin, "
298298
f"nphixspoints={args.nphixspoints}, phixsnuincrement={args.phixsnuincrement}\n"

artisatomic/test_artisatomic.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,20 +529,21 @@ def test_add_handler_if_not_set():
529529
ion_handlers: list[tuple[int, list[tuple[int, str]]]] = [(26, [(1, "cmfgen"), (2, "cmfgen")])]
530530
unchanged = [(26, [(1, "cmfgen"), (2, "cmfgen")])]
531531

532-
# adding an ion for a new element must not modify the input list
532+
# add an ion for a new element
533533
result = add_handler_if_not_set(ion_handlers, 58, 1, "dream")
534-
assert ion_handlers == unchanged
535534
assert result == [(26, [(1, "cmfgen"), (2, "cmfgen")]), (58, [(1, "dream")])]
536535

537536
# add an ion to an existing element
538537
result = add_handler_if_not_set(ion_handlers, 26, 3, "dream")
539-
assert ion_handlers == unchanged
540538
assert result == [(26, [(1, "cmfgen"), (2, "cmfgen"), (3, "dream")])]
541539

542540
# an already-present ion stage keeps the handler it was given, whatever the new one says
543541
result = add_handler_if_not_set(ion_handlers, 26, 2, "dream")
544542
assert result == unchanged
545543

544+
# the calls return a new list each time, so none of them touched the one they were given
545+
assert ion_handlers == unchanged
546+
546547
# ion stages can be given as tuples or lists (e.g. straight from json.load())
547548
ion_handlers_json = t.cast("list[tuple[int, list[tuple[int, str]]]]", [(26, [[1, "cmfgen"]])])
548549
result = add_handler_if_not_set(ion_handlers_json, 26, 1, "dream")

0 commit comments

Comments
 (0)