Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonbb committed Jan 19, 2024
1 parent 479cbdb commit 500a56c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tests/tape_tests/test_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,14 +1766,15 @@ def test_batch(data_fixture, request, use_map, on):
)
def test_sort_lightcurves(data_fixture, request):
"""
Test that ensemble.batch() sorts the data if requested
Test that we can have the ensemble sort its lightcurves by timestamp.
"""
parquet_ensemble = request.getfixturevalue(data_fixture)

# filter NaNs from the source table
parquet_ensemble = parquet_ensemble.prune(10).dropna(table="source")

# To check that multiple columns are being sorted by time, we'll duplicate the time column
# To check that all columns are rearranged when sorting the time column,
# we create a duplicate time column which should be sorted as well.
parquet_ensemble.source.assign(
dup_time=parquet_ensemble.source[parquet_ensemble._time_col]
).update_ensemble()
Expand All @@ -1786,7 +1787,8 @@ def my_mean(flux, time, dup_time):
# Check that the time column is sorted
if not np.all(time[:-1] <= time[1:]):
raise ValueError("The time column was not sorted in ascending order")
# Check that the other columns were sorted to preserve the dataframe's rows
# Check that the other columns were rearranged to preserve the dataframe's rows
# We can use the duplicate time column as an easy check.
if not np.array_equal(time, dup_time):
raise ValueError("The dataframe's time column was sorted but isn't aligned with other columns")
return np.mean(flux)
Expand Down

0 comments on commit 500a56c

Please sign in to comment.