Skip to content

Commit

Permalink
Add 'TimeMOC.to_depth61_ranges' method + test + update CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Mar 2, 2023
1 parent 6ad95d4 commit 751baee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `MOC.MAX_ORDER` and `TimeMOC.MAX_ORDER` to replace former `IntervalSet.HPX_MAX_ORDER` and `IntervalSet.TIME_MAX_ORDER`
* `MOC.to_depth29_ranges` (+test) to replace former `IntervalSet.nested`
* `TimeMOC.to_depth61_ranges`
* tests on `MOC.uniq_hpx`

### Bugfix
Expand Down
4 changes: 4 additions & 0 deletions python/mocpy/tests/test_tmoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def test_complement():
61, np.array([[0, 1], [2, 5], [8, 2 * 2**61]], dtype=np.uint64)
)

def test_to_depth61_ranges():
assert (TimeMOC.from_depth61_ranges(
61, np.array([[1, 2], [6, 8], [5, 6]], dtype=np.uint64)
).to_depth61_ranges == np.array([[1, 2], [5, 8]], dtype=np.uint64)).all()

def test_empty_tmoc():
times = Time([], format="jd", scale="tdb")
Expand Down
5 changes: 5 additions & 0 deletions python/mocpy/tmoc/tmoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def to_time_ranges(self):
"""Returns the time ranges this TimeMOC contains."""
return microseconds_to_times(mocpy.to_ranges(self._store_index))

@property
def to_depth61_ranges(self):
"""Return the list of ranges this TimeMOC contains, in microsec since JD=0."""
return mocpy.to_ranges(self._store_index)

def degrade_to_order(self, new_order):
"""
Degrades the MOC instance to a new, less precise, MOC.
Expand Down

0 comments on commit 751baee

Please sign in to comment.