Skip to content

Commit 717bce9

Browse files
committed
remove past and future
1 parent a65c202 commit 717bce9

24 files changed

+175
-277
lines changed

astromodels/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
import os
42

53
from ._version import get_versions

astromodels/core/serialization.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from future import standard_library
2-
31
from astromodels.core.model import Model
42
from astromodels.core.model_parser import ModelParser
53

6-
standard_library.install_aliases()
74
# We do not want to actually import anything from this module
85
__all__ = []
96

astromodels/core/tree.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import collections
22
from typing import Any, Dict
33

4-
from future import standard_library
5-
64
from astromodels.core.node_type import NodeBase
75
from astromodels.utils.io import display
86
from astromodels.utils.logging import setup_logger
97
from astromodels.utils.valid_variable import is_valid_variable_name
108

11-
standard_library.install_aliases()
12-
139

1410
class DuplicatedNode(Exception):
1511
pass

astromodels/functions/dark_matter/dm_models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import astropy.units as astropy_units
42
import numpy as np
53
from scipy.interpolate import RegularGridInterpolator

astromodels/functions/functions_1D/blackbody.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from __future__ import division
2-
31
import astropy.units as astropy_units
4-
from past.utils import old_div
52

63
import astromodels.functions.numba_functions as nb_func
74
from astromodels.functions.function import (
@@ -34,7 +31,7 @@ class Blackbody(Function1D, metaclass=FunctionMeta):
3431

3532
def _set_units(self, x_unit, y_unit):
3633
# The normalization has the same units as y
37-
self.K.unit = old_div(y_unit, (x_unit**2))
34+
self.K.unit = y_unit / (x_unit**2)
3835

3936
# The break point has always the same dimension as the x variable
4037
self.kT.unit = x_unit

astromodels/functions/functions_1D/functions.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
from __future__ import division
2-
31
import astropy.units as astropy_units
42
import astropy.units as u
53
import numpy as np
6-
from past.utils import old_div
74

85
from astromodels.core.units import get_units
96
from astromodels.functions.function import Function1D, FunctionMeta
@@ -448,8 +445,8 @@ def set_particle_distribution(self, function):
448445
# returns an astropy quantity, so we need to create a wrapper which will
449446
# remove the unit from x and add the unit to the return value
450447

451-
self._particle_distribution_wrapper = lambda x: old_div(
452-
function(x.value), current_units.energy
448+
self._particle_distribution_wrapper = (
449+
lambda x: function(x.value) / current_units.energy
453450
)
454451

455452
def get_particle_distribution(self):
@@ -552,7 +549,7 @@ class _ComplexTestFunction(Function1D, metaclass=FunctionMeta):
552549
def _set_units(self, x_unit, y_unit):
553550

554551
self.A.unit = y_unit
555-
self.B.unit = old_div(y_unit, x_unit)
552+
self.B.unit = y_unit / x_unit
556553

557554
def set_particle_distribution(self, function):
558555

@@ -680,7 +677,7 @@ def peak_energy(self):
680677

681678
return self.piv.value * pow(
682679
10,
683-
old_div(((2 + self.alpha.value) * np.log(10)), (2 * self.beta.value)),
680+
((2 + self.alpha.value) * np.log(10)) / (2 * self.beta.value),
684681
)
685682

686683

@@ -745,7 +742,7 @@ def _integral(a, b, index, ec):
745742
ap1 = index + 1
746743

747744
def integrand(x):
748-
return -pow(ec, ap1) * gamma_inc(ap1, old_div(x, ec))
745+
return -pow(ec, ap1) * gamma_inc(ap1, x / ec)
749746

750747
return integrand(b) - integrand(a)
751748

astromodels/functions/functions_1D/powerlaws.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import astropy.units as astropy_units
22
import numpy as np
3-
from past.utils import old_div
43
from scipy.special import gamma, gammaincc
54

65
import astromodels.functions.numba_functions as nb_func
@@ -805,7 +804,7 @@ def _set_units(self, x_unit, y_unit):
805804
self.beta.unit = astropy_units.dimensionless_unscaled
806805

807806
def evaluate(self, x, K, alpha, xp, beta, piv):
808-
E0 = old_div(xp, (2 + alpha))
807+
E0 = xp / (2 + alpha)
809808

810809
if alpha < beta:
811810
alpha = beta
@@ -900,14 +899,12 @@ def evaluate(self, x, K, alpha, xc, beta, piv):
900899

901900
out = np.zeros(x.shape) * K * 0
902901

903-
out[idx] = (
904-
K * np.power(old_div(x[idx], piv), alpha) * np.exp(old_div(-x[idx], xc))
905-
)
902+
out[idx] = K * np.power(x[idx] / piv, alpha) * np.exp(-x[idx] / xc)
906903
out[~idx] = (
907904
K
908905
* np.power((alpha - beta) * xc / piv, alpha - beta)
909906
* np.exp(beta - alpha)
910-
* np.power(old_div(x[~idx], piv), beta)
907+
* np.power(x[~idx] / piv, beta)
911908
)
912909

913910
return out
@@ -1004,8 +1001,8 @@ def _set_units(self, x_unit, y_unit):
10041001
def ggrb_int_cpl(a, Ec, Emin, Emax):
10051002

10061003
# Gammaincc does not support quantities
1007-
i1 = gammaincc(2 + a, old_div(Emin, Ec)) * gamma(2 + a)
1008-
i2 = gammaincc(2 + a, old_div(Emax, Ec)) * gamma(2 + a)
1004+
i1 = gammaincc(2 + a, Emin / Ec) * gamma(2 + a)
1005+
i2 = gammaincc(2 + a, Emax / Ec) * gamma(2 + a)
10091006

10101007
return -Ec * Ec * (i2 - i1)
10111008

@@ -1023,11 +1020,11 @@ def evaluate(self, x, alpha, beta, xp, F, a, b, opt):
10231020

10241021
if alpha == -2:
10251022

1026-
Ec = old_div(xp, 0.0001) # TRICK: avoid a=-2
1023+
Ec = xp / 0.0001 # TRICK: avoid a=-2
10271024

10281025
else:
10291026

1030-
Ec = old_div(xp, (2 + alpha))
1027+
Ec = xp / (2 + alpha)
10311028

10321029
# Split energy
10331030

@@ -1095,9 +1092,6 @@ def evaluate(self, x, alpha, beta, xp, F, a, b, opt):
10951092

10961093
flux = nb_func.cplaw_eval(x_, 1.0, Ec_, alpha_, Ec_)
10971094

1098-
# flux = norm * np.power(old_div(x, Ec), alpha) * \
1099-
# np.exp(old_div(- x, Ec))
1100-
11011095
else:
11021096

11031097
# The norm * 0 is to keep the units right

astromodels/functions/functions_2D.py

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
from __future__ import division
2-
31
import hashlib
42

53
import astropy.units as u
64
import numpy as np
75
from astropy import wcs
86
from astropy.coordinates import ICRS, BaseCoordinateFrame, SkyCoord
97
from astropy.io import fits
10-
from past.utils import old_div
118

129
from astromodels.functions.function import Function2D, FunctionMeta
1310
from astromodels.utils.angular_distance import angular_distance
@@ -83,7 +80,7 @@ def evaluate(self, x, y, K, sigma_b, l_min, l_max):
8380

8481
return (
8582
K
86-
* np.exp(old_div(-(b**2), (2 * sigma_b**2)))
83+
* np.exp(-(b**2) / (2 * sigma_b**2))
8784
* np.logical_or(
8885
np.logical_and(l > l_min, l < l_max),
8986
np.logical_and(l_min > l_max, np.logical_or(l > l_min, l < l_max)),
@@ -193,10 +190,7 @@ def evaluate(self, x, y, lon0, lat0, sigma):
193190
s2 = sigma**2
194191

195192
return (
196-
(old_div(180, np.pi)) ** 2
197-
* 1
198-
/ (2.0 * np.pi * s2)
199-
* np.exp(-0.5 * angsep**2 / s2)
193+
(180 / np.pi) ** 2 * 1 / (2.0 * np.pi * s2) * np.exp(-0.5 * angsep**2 / s2)
200194
)
201195

202196
def get_boundaries(self):
@@ -340,15 +334,15 @@ def evaluate(self, x, y, lon0, lat0, a, e, theta):
340334

341335
sin_2phi = np.sin(2.0 * phi * np.pi / 180.0)
342336

343-
A = old_div(cos2_phi, (2.0 * b**2)) + old_div(sin2_phi, (2.0 * a**2))
337+
A = cos2_phi / (2.0 * b**2) + sin2_phi / (2.0 * a**2)
344338

345-
B = old_div(-sin_2phi, (4.0 * b**2)) + old_div(sin_2phi, (4.0 * a**2))
339+
B = -sin_2phi / (4.0 * b**2) + sin_2phi / (4.0 * a**2)
346340

347-
C = old_div(sin2_phi, (2.0 * b**2)) + old_div(cos2_phi, (2.0 * a**2))
341+
C = sin2_phi / (2.0 * b**2) + cos2_phi / (2.0 * a**2)
348342

349343
E = -A * np.power(dX, 2) + 2.0 * B * dX * dY - C * np.power(dY, 2)
350344

351-
return np.power(old_div(180, np.pi), 2) * 1.0 / (2 * np.pi * a * b) * np.exp(E)
345+
return np.power(180 / np.pi, 2) * 1.0 / (2 * np.pi * a * b) * np.exp(E)
352346

353347
def get_boundaries(self):
354348

@@ -452,12 +446,7 @@ def evaluate(self, x, y, lon0, lat0, radius):
452446

453447
angsep = angular_distance(lon0, lat0, lon, lat)
454448

455-
return (
456-
np.power(old_div(180, np.pi), 2)
457-
* 1.0
458-
/ (np.pi * radius**2)
459-
* (angsep <= radius)
460-
)
449+
return np.power(180 / np.pi, 2) * 1.0 / (np.pi * radius**2) * (angsep <= radius)
461450

462451
def get_boundaries(self):
463452

@@ -614,9 +603,7 @@ def evaluate(self, x, y, lon0, lat0, a, e, theta):
614603
angsep2 = angular_distance(self.lon2, self.lat2, lon, lat)
615604
angsep = angsep1 + angsep2
616605

617-
return (
618-
np.power(old_div(180, np.pi), 2) * 1.0 / (np.pi * a * b) * (angsep <= 2 * a)
619-
)
606+
return np.power(180 / np.pi, 2) * 1.0 / (np.pi * a * b) * (angsep <= 2 * a)
620607

621608
def get_boundaries(self):
622609

0 commit comments

Comments
 (0)