Skip to content

Commit

Permalink
Merge d7ce1e7 into ecd011c
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHls authored Oct 12, 2023
2 parents ecd011c + d7ce1e7 commit 5e17989
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tardis/plasma/properties/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,26 @@ def calculate(self, atomic_data):
level_idxs2line_idx = pd.Series(
np.arange(len(index)), index=index, name="lines_idx"
)

# Check for duplicate indices
if level_idxs2line_idx.index.duplicated().any():
logger.warn(
"Duplicate indices in level_idxs2line_idx. "
"Dropping duplicates. "
"This is an issue with the atomic data & carsus. "
"Once fixed upstream, this warning will be removed. "
"This will raise an error in the future instead. "
"See https://github.com/tardis-sn/carsus/issues/384"
)
# This is necessary since pd.DataFrame.drop_duplicates()
# does not remove duplicates if the data is different
# and only the index is duplicated. See the example given
# in the pandas documentation:
# https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.drop_duplicates.html
level_idxs2line_idx = level_idxs2line_idx[
~level_idxs2line_idx.index.duplicated()
]

return level_idxs2line_idx


Expand Down

0 comments on commit 5e17989

Please sign in to comment.