Skip to content

Commit fcf1690

Browse files
authored
Merge pull request #760 from lincc-frameworks/obs_table_head
Add a head function for ObsTable
2 parents ca5d165 + 60f8aab commit fcf1690

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/lightcurvelynx/obstable/obs_table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ def copy(self):
226226
**new_survey_values,
227227
)
228228

229+
def head(self, n=5):
230+
"""Return the first n rows of the observation table."""
231+
return self._table.head(n)
232+
229233
def uses_footprint(self):
230234
"""Return whether the ObsTable uses a detector footprint for filtering."""
231235
return self._detector_footprint is not None

tests/lightcurvelynx/obstable/test_obs_table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def test_create_obs_table():
6161
# Without a filters column we cannot access the filters.
6262
assert len(ops_data.filters) == 0
6363

64+
# Check the head function.
65+
assert len(ops_data.head(3)) == 3
66+
assert len(ops_data.head(10)) == 5
67+
6468
# We can create an ObsTable directly from the dictionary as well.
6569
ops_data2 = ObsTable(pdf)
6670
assert len(ops_data2) == 5

0 commit comments

Comments
 (0)