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

maint: add pyproject to allow installing from empty environment #61

Merged
merged 20 commits into from
Feb 22, 2021
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
55 changes: 55 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run Tests
on: [push, pull_request]

jobs:
tests:
name: Run Tests
defaults:
run:
shell: bash -l {0}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2

- name: set up Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2.0.0
with:
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
environment-file: ci/test_environment.yml
activate-environment: aipy_tests

- name: Conda Info
run: |
conda info -a
conda list
PYVER=`python -c "import sys; print('{:d}.{:d}'.format(sys.version_info.major, sys.version_info.minor))"`
if [[ $PYVER != $PYTHON ]]; then
exit 1;
fi

- name: Install
run: |
pip install -e .

- name: Run Tests
run: |
pytest --cov=aipy --cov-report xml:coverage.xml

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
files: ./coverage.xml
flags: unittests
env_vars: PYTHON
verbose: true
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AIPY (Astronomical Interferometry in PYthon)

[![Build Status](https://travis-ci.org/HERA-Team/aipy.svg?branch=master)](https://travis-ci.org/HERA-Team/aipy)
[![Coverage Status](https://coveralls.io/repos/github/HERA-Team/aipy/badge.svg?branch=master)](https://coveralls.io/github/HERA-Team/aipy?branch=master)
[![Build Status](https://github.com/HERA-Team/aipy/workflows/Run%20Tests/badge.svg)](https://github.com/HERA-Team/aipy/actions)
[![Coverage Status](https://codecov.io/gh/HERA-Team/aipy/branch/master/graph/badge.svg?token=Vrr4XFcE8p)](https://codecov.io/gh/HERA-Team/aipy)

## Description

Expand Down
2 changes: 1 addition & 1 deletion aipy/amp.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def response(self, top):
if zang.size == 1:
zang = np.array([zang]); zang.shape = (1,)
az = np.array([az]); az.shape = (1,)
a = 2 * np.arange(self.poly.shape[0], dtype=np.float)
a = 2 * np.arange(self.poly.shape[0], dtype=np.float64)
a.shape = (1,) + a.shape; az.shape += (1,); zang.shape += (1,)
a = np.cos(np.dot(az, a))
a[:,0] = 0.5
Expand Down
2 changes: 1 addition & 1 deletion aipy/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from . import src

def get_freqs(sdf, sfreq, nchan):
return np.arange(nchan, dtype=np.float) * sdf + sfreq
return np.arange(nchan, dtype=np.float64) * sdf + sfreq

def get_aa(*args):
'''Return the AntennaArray specified by cal_key, which should be the
Expand Down
10 changes: 5 additions & 5 deletions aipy/deconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from . import _deconv

# Find smallest representable # > 0 for setting clip level
lo_clip_lev = np.finfo(np.float).tiny
lo_clip_lev = np.finfo(np.float64).tiny

def clean(im, ker, mdl=None, area=None, gain=.1, maxiter=10000, tol=1e-3,
stop_if_div=True, verbose=False, pos_def=False):
Expand Down Expand Up @@ -48,9 +48,9 @@ def clean(im, ker, mdl=None, area=None, gain=.1, maxiter=10000, tol=1e-3,
np.fft.fft2(ker)).astype(im.dtype)
else: raise ValueError('Number of dimensions != 1 or 2')
if area is None:
area = np.ones(im.shape, dtype=np.int)
area = np.ones(im.shape, dtype=np.int_)
else:
area = area.astype(np.int)
area = area.astype(np.int_)

iter = _deconv.clean(res, ker, mdl, area,
gain=gain, maxiter=maxiter, tol=tol,
Expand Down Expand Up @@ -96,9 +96,9 @@ def lsq(im, ker, mdl=None, area=None, gain=.1, tol=1e-3, maxiter=200,
mdl = np.zeros(im.shape, dtype=im.dtype)
x = mdl.copy()
if area is None:
area = np.ones(im.shape, dtype=np.int)
area = np.ones(im.shape, dtype=np.int_)
else:
area = area.astype(np.int)
area = area.astype(np.int_)
# Estimate gain of the kernel
q = np.sqrt((np.abs(ker)**2).sum())
ker_i = np.fft.fft2(ker)
Expand Down
4 changes: 2 additions & 2 deletions aipy/healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ def __setitem__(self, crd, val):
else:
m = np.zeros_like(self.map)
px = px.reshape(px.size,1)
cnt = np.zeros(self.map.shape, dtype=np.bool)
cnt = np.zeros(self.map.shape, dtype=np.bool_)
val = mk_arr(val, dtype=m.dtype)
utils.add2array(m, px, val)
utils.add2array(cnt, px, np.ones(val.shape, dtype=np.bool))
utils.add2array(cnt, px, np.ones(val.shape, dtype=np.bool_))
self.map = np.where(cnt, m, self.map)
def from_hpm(self, hpm):
"""Initialize this HealpixMap with data from another. Takes care
Expand Down
4 changes: 2 additions & 2 deletions aipy/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def get_LM(self, center=(0,0)):
def get_indices(self, u, v):
"""Get the pixel indices corresponding to the provided uv coordinates."""
if not USEDSP:
u = np.round(u / self.res).astype(np.int)
v = np.round(v / self.res).astype(np.int)
u = np.round(u / self.res).astype(np.int_)
v = np.round(v / self.res).astype(np.int_)
return np.array([-v,u],).transpose()
else:
return (-v / self.res).astype(np.float32), (u / self.res).astype(np.float32)
Expand Down
4 changes: 2 additions & 2 deletions aipy/interp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def subsample(a, factor):
rv = np.zeros((a.size, factor), dtype=a.dtype)
rv[:,0] = a
wgts = np.zeros((a.size, factor), dtype=np.float)
wgts = np.zeros((a.size, factor), dtype=np.float64)
wgts[:,0] = 1.
return rv.flatten(), wgts.flatten()

Expand All @@ -37,7 +37,7 @@ def default_filter(xs, freq=.25):
"""A basic smoothing filter using a Hamming window and a sinc function
of the specified frequency. Input a sample grid [-x,x] to get the
FIR coefficients used for smoothing."""
i = np.arange(xs.size, dtype=np.float) / xs.size * 2*np.pi
i = np.arange(xs.size, dtype=np.float64) / xs.size * 2*np.pi
return (1-np.cos(i)) * np.sinc(freq*xs)

def interpolate(ys, factor, filter=default_filter, order=4):
Expand Down
4 changes: 2 additions & 2 deletions aipy/rfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ def flag_by_int(preflagged_auto, nsig=1, raw=False):
hi_thr, lo_thr = gen_rfi_thresh(spikey_pwr_vs_t, cnt_per_bin=20, nsig=nsig)
spikey_pwr_vs_t = spikey_pwr_vs_t.filled(hi_thr)
mask = spikey_pwr_vs_t >= hi_thr
return mask.astype(np.int)
return mask.astype(np.int_)

def remove_spikes(data, mask=None, order=6, iter=3, return_poly=False):
"""Iteratively fits a smooth function by removing outliers and fitting
a polynomial, then using the polynomial to remove other outliers."""
xs = np.arange(data.size)
if mask is None or mask.size != data.size:
mask = np.zeros(data.shape, dtype=np.bool)
mask = np.zeros(data.shape, dtype=np.bool_)
im = np.logical_not(mask)
nxs = xs.compress(im)
ndata = data.compress(im)
Expand Down
16 changes: 16 additions & 0 deletions ci/test_environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: aipy_tests
channels:
- defaults
- conda-forge
dependencies:
- astropy
- ephem
- healpy
- matplotlib
- numpy
- pip
- pytest
- pytest-runner
- pytz
- pip:
- pytest-cov
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[build-system]
requires = ["setuptools>=42", "wheel", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
minversion = "6.0"
testpaths = [
"tests/alm_test.py",
"tests/amp_test.py",
"tests/coord_test.py",
"tests/deconv_test.py",
"tests/dsp_test.py",
"tests/healpix_test.py",
"tests/miriad_test.py",
"tests/phs_test.py",
"tests/scripting_test.py",
"tests/twodgauss_test.py",
]
2 changes: 1 addition & 1 deletion scripts/combine_freqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def mfunc(uv, p, d, f):
d.shape = (opts.nchan, nchan/opts.nchan)
d = d.sum(axis=1)
f.shape = (opts.nchan, nchan/opts.nchan)
f = np.logical_not(f).astype(np.int).sum(axis=1)
f = np.logical_not(f).astype(np.int_).sum(axis=1)
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)
Expand Down
2 changes: 1 addition & 1 deletion scripts/filter_src.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def gen_skypass_delay(aa, sdf, nchan, pol, max_bl_frac=1.5):
cat.compute(aa)
bl = a.miriad.ij2bl(i,j)
try:
flags = np.logical_not(f).astype(np.float)
flags = np.logical_not(f).astype(np.float64)
# Check first if source is up
if not src is None:
d = aa.phs2src(d, src, i, j)
Expand Down
2 changes: 1 addition & 1 deletion scripts/fitmdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def fit_func(prms, filelist, decimate, decphs):
for bl in dbuf[t]:
for pol in dbuf[t][bl]:
samp += len(dbuf[t][bl][pol][1])
vsamp += np.logical_not(dbuf[t][bl][pol][1]).astype(np.int).sum()
vsamp += np.logical_not(dbuf[t][bl][pol][1]).astype(np.int_).sum()
wgts += dbuf[t][bl][pol][2]
print('Cache summary:')
print(' %d samples' % samp)
Expand Down
2 changes: 1 addition & 1 deletion scripts/inspect_phs_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
if not pol in DD.keys(): DD[pol] = {}
if not (i,j) in DD[pol].keys(): DD[pol][(i,j)] = np.zeros_like(d)
#Construct flagging kernel
flags = np.logical_not(d.mask).astype(np.float)
flags = np.logical_not(d.mask).astype(np.float64)
gain = np.sqrt(np.average(flags**2))
ker = np.fft.ifft(flags)
d = d.filled(0)
Expand Down
6 changes: 3 additions & 3 deletions scripts/mk_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def img_it(im):
#print('Imaging with %d integrations' % n_ints)
n_ints = 0
# Form dirty images/beams
uvs = a.img.recenter(np.abs(im.uv).astype(np.float), (DIM/2,DIM/2))
bms = a.img.recenter(np.abs(im.bm[0]).astype(np.float), (DIM/2,DIM/2))
uvs = a.img.recenter(np.abs(im.uv).astype(np.float64), (DIM/2,DIM/2))
bms = a.img.recenter(np.abs(im.bm[0]).astype(np.float64), (DIM/2,DIM/2))
dim = im.image((DIM/2, DIM/2))
dbm = im.bm_image(term=0, center=(DIM/2,DIM/2))
return uvs,bms, dim,dbm
Expand Down Expand Up @@ -226,7 +226,7 @@ def img_it(im):
# Optimal SNR: down-weight beam-attenuated data
# by another factor of the beam response.
d *= wgt; wgt *= wgt
else: wgt = np.ones(d.shape, dtype=np.float)
else: wgt = np.ones(d.shape, dtype=np.float64)
valid = np.logical_and(np.logical_not(f), longenough)
d = d.compress(valid)
if len(d) == 0: continue
Expand Down
8 changes: 4 additions & 4 deletions scripts/plot_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def __init__(self, projection, lat_0=0, lon_0=0, **kwargs):
self.lat_0, self.lon_0 = lat_0, lon_0
def __call__(self, lon, lat, inverse=False):
if inverse:
lon = lon.astype(np.float) * 90 - self.lon_0
lon = lon.astype(np.float64) * 90 - self.lon_0
lon = self.wrap(lon, -180, 180)
lat = lat.astype(np.float) * 90 - self.lat_0
lat = lat.astype(np.float64) * 90 - self.lat_0
lat = self.wrap(lat, -90, 90)
return lon,lat
else:
Expand All @@ -49,8 +49,8 @@ def drawparallels(self, lats, **kwargs):
p.grid(True)
def makegrid(self, dim1, dim2, returnxy=True):
y,x = np.indices((dim2,dim1))
x = 4 * x.astype(np.float)/dim1 - 2
y = 1 - 2 * y.astype(np.float)/dim2
x = 4 * x.astype(np.float64)/dim1 - 2
y = 1 - 2 * y.astype(np.float64)/dim2
lon,lat = self(x,y, inverse=True)
if returnxy: return lon,lat, x,y
else: return lon,lat
Expand Down
4 changes: 2 additions & 2 deletions scripts/plot_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ def data_mode(data, mode='abs'):
if opts.delay:
w = a.dsp.gen_window(d.shape[-1], window=opts.window)
if opts.unmask:
flags = np.ones(d.shape, dtype=np.float)
flags = np.ones(d.shape, dtype=np.float64)
d = d.data
else:
flags = np.logical_not(d.mask).astype(np.float)
flags = np.logical_not(d.mask).astype(np.float64)
d = d.filled(0)
d = np.fft.ifft(d*w)
ker = np.fft.ifft(flags*w)
Expand Down
2 changes: 1 addition & 1 deletion scripts/xrfi_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
for pol in mask:
for bl in mask[pol]:
for t in mask[pol][bl]:
new_mask[t] = new_mask.get(t,0)+mask[pol][bl][t].astype(np.int)
new_mask[t] = new_mask.get(t,0)+mask[pol][bl][t].astype(np.int_)
for t in new_mask:
m = np.where(new_mask[t] >= opts.thresh, 1, 0)
for pol in mask:
Expand Down
2 changes: 1 addition & 1 deletion scripts/xtalk3.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
gain[bl].append(np.average(adat[chans[0]:chans[1]]))
dat /= gain[bl][-1]
xsum[bl] = xsum.get(bl, 0) + dat
cnt[bl] = cnt.get(bl, 0) + np.logical_not(adat.mask).astype(np.int)
cnt[bl] = cnt.get(bl, 0) + np.logical_not(adat.mask).astype(np.int_)
for bl in xsum: xsum[bl] /= np.where(cnt[bl] == 0, 1, cnt[bl])
for c, jd in enumerate(times):
repfile = '%f.xtalk.rep.npz' % jd
Expand Down
Loading