Skip to content

Commit

Permalink
chore: rename methods (intersection is implied)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManonMarchand committed May 27, 2024
1 parent 2604fc0 commit 81f5383
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* `MOC.sum_in_multiordermap_intersection` takes an astropy table with a `UNIQ` column and
* `MOC.sum_in_multiordermap` takes an astropy table with a `UNIQ` column and
a column name to sum. It returns the sum of the column in the intersection between the
MOC and the Multi-order-map. `MOC.probability_in_multiordermap_intersection` has a similar
MOC and the Multi-order-map. `MOC.probability_in_multiordermap` has a similar
behavior but also converts a probability-density into a probability.
* `STMOC.new_empty()` allows to create a new empty Space-Time MOC.

Expand Down
8 changes: 4 additions & 4 deletions python/mocpy/moc/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def from_multiordermap_fits_file(
)
return cls(index)

def probability_in_multiordermap_intersection(self, multiordermap):
def probability_in_multiordermap(self, multiordermap):
"""Calculate the probability in the intersection between the multiordermap and the MOC.
``PROBDENSITY`` values are multiplied by the area of their associated HEALPix
Expand Down Expand Up @@ -752,7 +752,7 @@ def probability_in_multiordermap_intersection(self, multiordermap):
>>> probdensity = rng.random(20) / 100
>>> multi_order_map = Table([uniq, probdensity], names=("UNIQ", "PROBDENSITY"))
>>> # The probability to be in the intersection with the all sky is
>>> round(all_sky.probability_in_multiordermap_intersection(multi_order_map), 4)
>>> round(all_sky.probability_in_multiordermap(multi_order_map), 4)
0.0004
"""
Expand Down Expand Up @@ -783,7 +783,7 @@ def probability_in_multiordermap_intersection(self, multiordermap):
f" is expected. Got '{type(multiordermap)}'",
)

def sum_in_multiordermap_intersection(self, multiordermap: Table, column: str):
def sum_in_multiordermap(self, multiordermap: Table, column: str):
"""Calculate the sum of a column from a multiordermap in the intersection with the MOC.
Parameters
Expand Down Expand Up @@ -811,7 +811,7 @@ def sum_in_multiordermap_intersection(self, multiordermap: Table, column: str):
>>> rng = np.random.default_rng(0)
>>> column = rng.random(200)
>>> multi_order_map = Table([uniq, column], names=("UNIQ", "column"))
>>> round(all_sky.sum_in_multiordermap_intersection(multi_order_map, "column"), 4)
>>> round(all_sky.sum_in_multiordermap(multi_order_map, "column"), 4)
107.9259
"""
Expand Down
12 changes: 6 additions & 6 deletions python/mocpy/tests/test_moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,18 +741,18 @@ def test_from_valued_healpix_cells_bayestar_and_split():
assert moc.max_order == 11


def test_probability_in_multiordermap_intersection():
def test_probability_in_multiordermap():
# from path
moc = MOC.from_str("0/4")
fits_mom_filename = "./resources/bayestar.multiorder.fits"
proba = moc.probability_in_multiordermap_intersection(fits_mom_filename)
proba = moc.probability_in_multiordermap(fits_mom_filename)
assert np.isclose(proba, 0.20877154164727782)

# has no mask
mom = QTable()
mom["UNIQ"] = [4 + x for x in range(20)]
mom["PROBDENSITY"] = [x / 10 for x in range(20)]
proba = moc.probability_in_multiordermap_intersection(mom)
proba = moc.probability_in_multiordermap(mom)
assert np.isclose(proba, 0.41887902047863906)

# is not a valid mom or path
Expand All @@ -761,16 +761,16 @@ def test_probability_in_multiordermap_intersection():
match="An argument of type 'str', 'pathlib.Path', or "
"'astropy.table.Table' is expected. Got '<class 'int'>'",
):
moc.probability_in_multiordermap_intersection(1)
moc.probability_in_multiordermap(1)


def test_sum_in_multiordermap_intersection():
def test_sum_in_multiordermap():
all_sky = MOC.from_str("0/0-11")
mom = QTable()
range_20 = range(20)
mom["UNIQ"] = [4 * 4**3 + x for x in range_20]
mom["TO_SUM"] = range_20
assert all_sky.sum_in_multiordermap_intersection(mom, "TO_SUM") == sum(range_20)
assert all_sky.sum_in_multiordermap(mom, "TO_SUM") == sum(range_20)


def test_from_stcs():
Expand Down

0 comments on commit 81f5383

Please sign in to comment.