From 8d53b89819c5b00b37a50ddd16527ffeab7f82f1 Mon Sep 17 00:00:00 2001 From: Andrew Fullard Date: Tue, 10 Sep 2024 11:16:00 -0400 Subject: [PATCH] Fixes CMFGEN tests --- carsus/io/cmfgen/base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/carsus/io/cmfgen/base.py b/carsus/io/cmfgen/base.py index 243f4f22a..043a22613 100644 --- a/carsus/io/cmfgen/base.py +++ b/carsus/io/cmfgen/base.py @@ -659,9 +659,11 @@ def cross_sections_squeeze( lower_level_label = target.attrs["Configuration name"] cross_section_type = target.attrs["Type of cross-section"] - # Remove the "[J]" term from J-splitted levels labels - ion_levels["label"] = ion_levels["label"].str.rstrip("]") - ion_levels["label"] = ion_levels["label"].str.split("[", expand=True) + if ion_levels["label"].str.contains(r"\[").any(): + # Remove the "[J]" term from J-splitted levels labels + ion_levels["label"] = ion_levels["label"].str.rstrip("]") + # Drop the [J] term completely to avoid shape mismatch. Something to perhaps store in the future + ion_levels["label"] = ion_levels["label"].str.split("[", expand=True)[0] try: match = ion_levels.set_index("label").loc[[lower_level_label]]