Skip to content

Commit fe4642d

Browse files
cphycchrishavlin
andcommitted
Add extra test to check halfpoint
Co-authored-by: Chris Havlin <chris.havlin@gmail.com>
1 parent 70a5714 commit fe4642d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

yt/data_objects/tests/test_time_series.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,8 @@ def test_get_by_key(FakeDataset, fake_datasets):
148148

149149
with pytest.raises(ValueError):
150150
ts.get_by_redshift(1000, tolerance=0.1)
151+
152+
zmid = (ts[0].current_redshift + ts[1].current_redshift) / 2
153+
154+
assert sfile_list[1] == ts.get_by_redshift(zmid, prefer="smaller").filename
155+
assert sfile_list[0] == ts.get_by_redshift(zmid, prefer="larger").filename

yt/data_objects/time_series.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ def _get_by_attribute(
513513
iM = (iR + iL) // 2
514514
dsM = self[iM]
515515
vM = getattr(dsM, attribute)
516+
516517
if sign * value < sign * vM:
517518
iR = iM
518519
dsR = dsM

0 commit comments

Comments
 (0)