Closed hombit closed 4 months ago
Indeed! Thanks for reporting.
While we do the fix, you can use sum
that also calls union behind the scenes:
import astropy.units as u
from astropy.coordinates import Latitude, Longitude, Angle
from mocpy import MOC
moc = MOC.from_cone(lon=Longitude(0, u.deg), lat=Latitude(0, u.deg), radius=Angle(1, u.arcmin), max_depth=19)
sum([moc, moc, moc]) == moc
True
It's fixed in master if you can work from there. Otherwise, the next release should be in a few days. Thanks again for reporting the issue :slightly_smiling_face:
Thank you! .union
works so much faster than sum
Yes, sum
does the operation with python while union
does it on the rust side (except for STMOCs for now)
@fxpineau will be happy to read that the difference is noticeable :wink:
FYI, the algorithm is not the same. But, if I am correct, both are made on the Rust side.
sum
makes successive unions
while a kway-merge (with k=4) is performed in the case of union
with more than 2 parameters.
While
moc.union(moc1)
works well,moc.union(moc1, moc2, ...)
fails with aTypeError
:Tested with mocpy v0.15.0, astropy v6.0.0, numpy v1.24.4, python 3.11, macOS 14.5