Skip to content

Commit

Permalink
Merge pull request #316 from kboone/numpy_deprecation
Browse files Browse the repository at this point in the history
Stop using deprecated numpy types
  • Loading branch information
kboone committed Sep 9, 2021
2 parents 57a70f3 + 6505ec8 commit 98f16f8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion misc/gen_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
zpsys = np.array(40 * ['ab'])

flux = model.bandflux(bands, times, zp=zp, zpsys=zpsys)
fluxerr = (0.05 * np.max(flux)) * np.ones(40, dtype=np.float)
fluxerr = (0.05 * np.max(flux)) * np.ones(40, dtype=float)
flux += fluxerr * np.random.randn(40)

data = Table(odict([('time', times), ('band', bands), ('flux', flux),
Expand Down
2 changes: 1 addition & 1 deletion sncosmo/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ def prior_transform(u):
d = {}
for i in range(npdim):
d[iparam_names[i]] = ppflist[i](u[i])
v = np.empty(ndim, dtype=np.float)
v = np.empty(ndim, dtype=float)
for i in range(ndim):
key = vparam_names[i]
if key in d:
Expand Down
10 changes: 5 additions & 5 deletions sncosmo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _bandflux(model, band, time_or_phase, zp, zpsys):
zpsys = np.atleast_1d(zpsys)

# initialize output arrays
bandflux = np.zeros(time_or_phase.shape, dtype=np.float)
bandflux = np.zeros(time_or_phase.shape, dtype=float)

# Loop over unique bands.
for b in set(band):
Expand Down Expand Up @@ -182,7 +182,7 @@ def _bandmag(model, band, magsys, time_or_phase):
magsys = magsys.ravel()
bandflux = bandflux.ravel()

result = np.empty(bandflux.shape, dtype=np.float)
result = np.empty(bandflux.shape, dtype=float)
for i, (b, ms, f) in enumerate(zip(band, magsys, bandflux)):
ms = get_magsystem(ms)
zpf = ms.zpbandflux(b)
Expand Down Expand Up @@ -1323,7 +1323,7 @@ def __init__(self, source, effects=None,
# Set parameter names, initial values (inital values set to zero)
self._param_names = ['z', 't0']
self.param_names_latex = ['z', 't_0']
self._parameters = np.zeros(2, dtype=np.float)
self._parameters = np.zeros(2, dtype=float)

# Set source and add source parameter names
self._source = get_source(source, copy=True)
Expand Down Expand Up @@ -1437,7 +1437,7 @@ def _sync_parameter_arrays(self):

# allocate new array (zeros so that new 'free' effects redshifts
# initialize to 0)
self._parameters = np.zeros(l, dtype=np.float)
self._parameters = np.zeros(l, dtype=float)

# copy old parameters: we do this to make sure we copy
# non-default values of any parameters that the model alone
Expand Down Expand Up @@ -1628,7 +1628,7 @@ def bandoverlap(self, band, z=None):
ndim = (band.ndim, z.ndim)
band = band.ravel()
z = z.ravel()
overlap = np.empty((len(band), len(z)), dtype=np.bool)
overlap = np.empty((len(band), len(z)), dtype=bool)
shift = (1. + z)/(1+self._parameters[0])
for i, b in enumerate(band):
b = get_bandpass(b)
Expand Down
4 changes: 2 additions & 2 deletions sncosmo/photdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, data):
# if the original array already contains all bandpass objects,
# but constructing a new array is simpler.)
band_orig = data[mapping['band']]
self.band = np.empty(len(band_orig), dtype=np.object)
self.band = np.empty(len(band_orig), dtype=object)
for i in range(len(band_orig)):
self.band[i] = get_bandpass(band_orig[i])

Expand Down Expand Up @@ -145,7 +145,7 @@ def _normalization_factor(self, zp, zpsys):
the given zeropoint and zeropoint system."""

normmagsys = get_magsystem(zpsys)
factor = np.empty(len(self), dtype=np.float)
factor = np.empty(len(self), dtype=float)

for b in set(self.band.tolist()):
mask = self.band == b
Expand Down
2 changes: 1 addition & 1 deletion sncosmo/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def plot_lc(data=None, model=None, bands=None, zp=25., zpsys='ab',
# filled: used only if data is not None. Guarantee array of booleans
if data is not None:
if fill_data_marker is None:
fill_data_marker = np.ones(data.time.shape, dtype=np.bool)
fill_data_marker = np.ones(data.time.shape, dtype=bool)
else:
fill_data_marker = np.asarray(fill_data_marker)
if fill_data_marker.shape != data.time.shape:
Expand Down
2 changes: 1 addition & 1 deletion sncosmo/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def flatsource():
all times."""
phase = np.linspace(0., 100., 10)
wave = np.linspace(800., 20000., 100)
flux = np.ones((len(phase), len(wave)), dtype=np.float)
flux = np.ones((len(phase), len(wave)), dtype=float)
return sncosmo.TimeSeriesSource(phase, wave, flux)


Expand Down
2 changes: 1 addition & 1 deletion sncosmo/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup_class(self):
# Create a TimeSeriesSource with a flat spectrum at all times.
phase = np.linspace(0., 100., 10)
wave = np.linspace(1000., 10000., 100)
flux = np.ones((len(phase), len(wave)), dtype=np.float)
flux = np.ones((len(phase), len(wave)), dtype=float)
source = sncosmo.TimeSeriesSource(phase, wave, flux)
self.model = sncosmo.Model(source=source)

Expand Down

0 comments on commit 98f16f8

Please sign in to comment.