Skip to content

Commit

Permalink
Add extra test to check halfpoint
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Havlin <chris.havlin@gmail.com>
  • Loading branch information
cphyc and chrishavlin committed Oct 3, 2024
1 parent 70a5714 commit fe4642d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions yt/data_objects/tests/test_time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,8 @@ def test_get_by_key(FakeDataset, fake_datasets):

with pytest.raises(ValueError):
ts.get_by_redshift(1000, tolerance=0.1)

zmid = (ts[0].current_redshift + ts[1].current_redshift) / 2

assert sfile_list[1] == ts.get_by_redshift(zmid, prefer="smaller").filename
assert sfile_list[0] == ts.get_by_redshift(zmid, prefer="larger").filename
1 change: 1 addition & 0 deletions yt/data_objects/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ def _get_by_attribute(
iM = (iR + iL) // 2
dsM = self[iM]
vM = getattr(dsM, attribute)

if sign * value < sign * vM:
iR = iM
dsR = dsM
Expand Down

0 comments on commit fe4642d

Please sign in to comment.