Describe the bug
Numpy has, for no apparent reason, decided to change the copy keyword behavior in np.array and np.asarray, as described here: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword. The recommended fix (changing all instances to np.asarray) does not work for us, as we need to use the ndmin keyword.
Instead, we will follow the example of scipy (scipy/scipy#20172).
Fix steps:
- Add new file to EXOSIMS/util/ (something like _numpy_compat.py). Contents of the file are the same as the scipy fix:
import numpy as np
if np.lib.NumpyVersion(np.__version__) >= "2.0.0":
copy_if_needed = None
elif np.lib.NumpyVersion(np.__version__) < "1.28.0":
copy_if_needed = False
else:
# 2.0.0 dev versions, handle cases where copy may or may not exist
try:
np.array([1]).__array__(copy=None) # type: ignore[call-overload]
copy_if_needed = None
except TypeError:
copy_if_needed = False
- For every EXOSIMS file that includes an
np.array(..., ndmin=..., copy=False), at the top of the file, add import:
from EXOSIMS.util. _numpy_compat import copy_if_needed
Change the np.array call to: `np.array(..., ndmin=..., copy=copy_if_needed)
EXOSIMS/SurveySimulation/linearJScheduler_det_only.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler_orbitChar.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/cbytScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/randomWalkScheduler.py: # sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/randomWalkScheduler2.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler_DDPC.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/occulterJScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/util/InverseTransformSampler.py: fX = np.array(fX, copy=False, ndmin=1)
EXOSIMS/TargetList/EclipticTargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/TargetList/EclipticTargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/OpticalSystem/Nemati.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/OpticalSystem/Nemati.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Completeness.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/SurveySimulation.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/PlanetPopulation.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/Prototypes/PlanetPopulation.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: MV = np.array(MV, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Observatory.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Observatory.py: y = np.array(y, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smin = np.array(smin, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smax = np.array(smax, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: dMag = np.array(dMag, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: z = np.array(z, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smin = np.array(smin, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smax = np.array(smax, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: max_dMag = np.array(max_dMag, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: R = np.array(R, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: self.ps = np.array(ps, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: self.Rb = np.array(Rb, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: Rp = np.array(Rp.to("earthRad").value, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: self.ps = np.array(ps, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: self.Rb = np.array(Rb, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: Rp = np.array(Rp.to("earthRad").value, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/BackgroundSources/GalaxiesFaintStars.py: mag = np.array(intDepths, ndmin=1, copy=False)
Describe the bug
Numpy has, for no apparent reason, decided to change the copy keyword behavior in np.array and np.asarray, as described here: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword. The recommended fix (changing all instances to np.asarray) does not work for us, as we need to use the ndmin keyword.
Instead, we will follow the example of scipy (scipy/scipy#20172).
Fix steps:
np.array(..., ndmin=..., copy=False), at the top of the file, add import:Change the np.array call to: `np.array(..., ndmin=..., copy=copy_if_needed)
EXOSIMS/SurveySimulation/linearJScheduler_det_only.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler_orbitChar.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/cbytScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/randomWalkScheduler.py: # sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/randomWalkScheduler2.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler_DDPC.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/occulterJScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/SurveySimulation/linearJScheduler.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/util/InverseTransformSampler.py: fX = np.array(fX, copy=False, ndmin=1)
EXOSIMS/TargetList/EclipticTargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/TargetList/EclipticTargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/OpticalSystem/Nemati.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/OpticalSystem/Nemati.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/TargetList.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/OpticalSystem.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Completeness.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/SurveySimulation.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/PlanetPopulation.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/Prototypes/PlanetPopulation.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: MV = np.array(MV, ndmin=1, copy=False)
EXOSIMS/Prototypes/ZodiacalLight.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Observatory.py: sInds = np.array(sInds, ndmin=1, copy=False)
EXOSIMS/Prototypes/Observatory.py: y = np.array(y, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smin = np.array(smin, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smax = np.array(smax, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: dMag = np.array(dMag, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: z = np.array(z, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smin = np.array(smin, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: smax = np.array(smax, ndmin=1, copy=False)
EXOSIMS/Completeness/GarrettCompleteness.py: max_dMag = np.array(max_dMag, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/KeplerLike1.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: R = np.array(R, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: Rp = np.array(Rp, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/SAG13.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: self.ps = np.array(ps, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: self.Rb = np.array(Rb, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadiusDulzPlavchan.py: Rp = np.array(Rp.to("earthRad").value, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: self.ps = np.array(ps, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: self.Rb = np.array(Rb, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/AlbedoByRadius.py: Rp = np.array(Rp.to("earthRad").value, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: e = np.array(e, ndmin=1, copy=False)
EXOSIMS/PlanetPopulation/DulzPlavchan.py: a = np.array(a, ndmin=1, copy=False)
EXOSIMS/BackgroundSources/GalaxiesFaintStars.py: mag = np.array(intDepths, ndmin=1, copy=False)