Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replace np.Inf with np.inf #70

Merged
merged 4 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10"]
python-version: [3.9, "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
Expand All @@ -20,9 +20,10 @@ jobs:
- name: Test with pytest
run: pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/warnings-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run Warnings Tests

on: [push]

jobs:
Tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: |
pip install -e .[dev]
- name: Test with pytest
run: pytest -Werror --cov=./ --cov-report=xml
2 changes: 1 addition & 1 deletion aipy/amp.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def response(self, xyz):
class Beam2DGaussian(phs.Beam):
"""Representation of a 2D Gaussian beam pattern, with default setting for
a flat beam."""
def __init__(self, freqs, xwidth=np.Inf, ywidth=np.Inf):
def __init__(self, freqs, xwidth=np.inf, ywidth=np.inf):
"""xwidth = angular width (radians) in EW direction
ywidth = angular width (radians) in NS direction"""
phs.Beam.__init__(self, freqs)
Expand Down
8 changes: 4 additions & 4 deletions aipy/deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def recenter(a, c):
return a2

def lsq(im, ker, mdl=None, area=None, gain=.1, tol=1e-3, maxiter=200,
lower=lo_clip_lev, upper=np.Inf, verbose=False):
lower=lo_clip_lev, upper=np.inf, verbose=False):
"""This simple least-square fitting procedure for deconvolving an image
saves computing by assuming a diagonal pixel-pixel gradient of the fit.
In essence, this assumes that the convolution kernel is a delta-function.
Expand Down Expand Up @@ -132,7 +132,7 @@ def f(x):
return x, info

def maxent(im, ker, var0, mdl=None, gain=.1, tol=1e-3, maxiter=200,
lower=lo_clip_lev, upper=np.Inf, verbose=False):
lower=lo_clip_lev, upper=np.inf, verbose=False):
"""Maximum entropy deconvolution (MEM) (see Cornwell and Evans 1984
"A Simple Maximum Entropy Deconvolution Algorithm" and Sault 1990
"A Modification of the Cornwell and Evans Maximum Entropy Algorithm")
Expand Down Expand Up @@ -197,7 +197,7 @@ def dot(x, y): return (x*y/-gg_J).sum()
return b_i, info

def maxent_findvar(im, ker, var=None, f_var0=.6, mdl=None, gain=.1, tol=1e-3,
maxiter=200, lower=lo_clip_lev, upper=np.Inf, verbose=False,
maxiter=200, lower=lo_clip_lev, upper=np.inf, verbose=False,
maxiterok=False):
"""This frontend to maxent tries to find a variance for which maxent will
converge. If the starting variance (var) is not specified, it will be
Expand Down Expand Up @@ -237,7 +237,7 @@ def maxent_findvar(im, ker, var=None, f_var0=.6, mdl=None, gain=.1, tol=1e-3,
if verbose: print('Done with MEM.')
return cl, info

def anneal(im, ker, mdl=None, maxiter=1000, lower=lo_clip_lev, upper=np.Inf,
def anneal(im, ker, mdl=None, maxiter=1000, lower=lo_clip_lev, upper=np.inf,
cooling=lambda i,x: 1e+1*(1-np.cos(i/50.))*(x**2), verbose=False):
"""Annealing takes a non-deterministic approach to deconvolution by
randomly perturbing the model and selecting perturbations that improve the
Expand Down
3 changes: 2 additions & 1 deletion aipy/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def to_map(self, nside, pixwin=False, fwhm=0.0, sigma=None,
polarized input)'''
return healpy.alm2map(self.get_data(), nside,
lmax=self._lmax, mmax=self._mmax,
pixwin=pixwin, fwhm=fwhm, sigma=sigma, pol=pol, verbose=verbose)
pixwin=pixwin, fwhm=fwhm, sigma=sigma, pol=pol
)
def from_map(self, data, iter=3, pol=True, use_weights=False, gal_cut=0):
'''Set the coefficients of this Alm object (with its specified
lmax and mmax) from the data of a HealpixMap in 'RING' mode.
Expand Down
2 changes: 1 addition & 1 deletion scripts/cl_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def to_fits(prefix,ftag,i,kwds):
level = float(opts.rewgt.split('(')[-1][:-1])
abms = np.abs(bms)
thresh = abms.max() * level
divisor = abms.clip(thresh, np.Inf)
divisor = abms.clip(thresh, np.inf)
uvs /= divisor; bms /= divisor
elif opts.rewgt.startswith('radial'):
#x,y = np.indices(dim.shape)
Expand Down
2 changes: 1 addition & 1 deletion scripts/combine_freqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def mfunc(uv, p, d, f):
d = d.sum(axis=1)
f.shape = (opts.nchan, nchan/opts.nchan)
f = np.logical_not(f).astype(np.int_).sum(axis=1)
d /= f.clip(1,np.Inf)
d /= f.clip(1,np.inf)
if opts.careful_flag: f = np.where(f < nchan/opts.nchan, 1, 0)
elif opts.dont_flag: f = np.where(f < 1, 1, 0)
else: f = np.where(f <= nchan/opts.nchan/2, 1, 0)
Expand Down
8 changes: 4 additions & 4 deletions scripts/fitmdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
aa.set_jultime(t)
cat.compute(aa)
del(uv)
if opts.maxiter < 0: opts.maxiter = np.Inf
if opts.maxiter < 0: opts.maxiter = np.inf

# Figure out parameters to fit
prms, prm_dict, shkeys = {}, {}, []
Expand Down Expand Up @@ -234,7 +234,7 @@ def fit_func(prms):
fit_func, prm_list,
#args=(args, opts.decimate, opts.decphs),
full_output=1, disp=0,
maxfun=opts.maxiter, maxiter=np.Inf,
maxfun=opts.maxiter, maxiter=np.inf,
ftol=opts.ftol, xtol=opts.xtol
)
prms,score = rv[:2]
Expand All @@ -252,7 +252,7 @@ def fit_func(prms):
fit_func, prm_list,
args=(args, opts.decimate, opts.decphs),
full_output=1, disp=0,
maxfun=opts.maxiter, maxiter=np.Inf,
maxfun=opts.maxiter, maxiter=np.inf,
ftol=opts.ftol, xtol=opts.xtol
)
prms,score = rv[:2]
Expand Down Expand Up @@ -283,7 +283,7 @@ def fit_func(prms):
fit_func, prm_list,
args=([uvfile], decimate, opts.decimate*cnt + opts.decphs),
full_output=1, disp=0,
maxfun=opts.maxiter, maxiter=np.Inf,
maxfun=opts.maxiter, maxiter=np.inf,
ftol=opts.ftol, xtol=opts.xtol
)
prms,score = rv[:2]
Expand Down
2 changes: 1 addition & 1 deletion scripts/xtalk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
guess[bl] += np.where(f, 0, d)
cnt[bl] += np.logical_not(f)
del(uv)
for bl in guess: xtalk[bl] = guess[bl] / np.clip(cnt[bl], 1, np.Inf)
for bl in guess: xtalk[bl] = guess[bl] / np.clip(cnt[bl], 1, np.inf)
if opts.outfile:
xfile = '%f.xtalk.npz' % jd
print('Writing', xfile)
Expand Down
Loading