Skip to content

Commit

Permalink
Sort lines dataframe with line id and kind stable
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed Jan 10, 2025
1 parent 06106d1 commit d1573cd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tardis/io/atom_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,11 @@ def prepare_lines(self):
self.selected_atomic_numbers, level="atomic_number"
)
]

self.lines = self.lines.sort_values(by="wavelength")
# see https://github.com/numpy/numpy/issues/27725#issuecomment-2465471648
# with kind="stable" the returned array will maintain the relative order of a values which compare as equal.
# this is important especially after numpy v2 release
# https://numpy.org/doc/stable/release/2.0.0-notes.html#minor-changes-in-behavior-of-sorting-functions
self.lines = self.lines.sort_values(by=["wavelength", "line_id"], kind="stable")

def prepare_line_level_indexes(self):
levels_index = pd.Series(
Expand Down

0 comments on commit d1573cd

Please sign in to comment.