Skip to content

Commit

Permalink
Merge pull request #18 from LSSTDESC/issue/17/infnan
Browse files Browse the repository at this point in the history
change inf nan and alltrue to np2.0 compatible equivalents
  • Loading branch information
sschmidt23 authored Jul 30, 2024
2 parents 2352743 + 2946d62 commit b9eb753
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.9, "3.10", "3.11"]

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
"Operating System :: OS Independent"
]
dependencies = [
"numpy",
"numpy<2.0",
"scipy",
"pandas>=1.1",
"h5py",
Expand Down
8 changes: 4 additions & 4 deletions src/desc_bpz/MLab_coe_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,8 @@ def rotdeg(x, y, ang):
def linefit(x1, y1, x2, y2):
"""y = mx + b FIT TO TWO POINTS"""
if x2 == x1:
m = Inf
b = NaN
m = inf
b = nan
else:
m = (y2 - y1) / (x2 - x1)
b = y1 - m * x1
Expand Down Expand Up @@ -964,7 +964,7 @@ def sym8(a):
return x / 8.

#def divsafe(a, b, inf=1e30, nan=0.):
def divsafe(a, b, inf=Inf, nan=NaN):
def divsafe(a, b, inf=inf, nan=nan):
"""a / b with a / 0 = inf and 0 / 0 = nan"""
a = array(a).astype(float)
b = array(b).astype(float)
Expand Down Expand Up @@ -1205,7 +1205,7 @@ def norepxy(x, y, tol=1e-8):

def isseq(a):
"""TELLS YOU IF a IS SEQUENTIAL, LIKE [3, 4, 5, 6]"""
return (alltrue(a == arange(len(a)) + a[0]))
return (all(a == arange(len(a)) + a[0]))

def between(lo, x, hi): # --DC
# RETURNS 1 WHERE lo < x < hi
Expand Down
2 changes: 1 addition & 1 deletion src/desc_bpz/coeio_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ def loadsexcat(infile, purge=1, maxflags=8, minfwhm=1, minrf=0, maxmag=99, magna
if not silent:
print(sum(good))

if purge and not alltrue(good):
if purge and not all(good):
data = compress(good, data)
if (flags != None): flags = compress(good, flags)
if (mag != None): mag = compress(good, mag)
Expand Down
4 changes: 2 additions & 2 deletions src/desc_bpz/scripts/bpz.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def updateblank(var, ext):
print("""Allowed values for magnitudes are
0<m<"""+repr(undet)+" m="+repr(undet)+"(non detection), m="+repr(unobs)+"(not observed)")
for i in range(len(todo)):
if not alltrue(todo[i,:]):
if not all(todo[i,:]):
print(i+1,f_obs[i,:],ef_obs[i,:])
sys.exit()

Expand Down Expand Up @@ -1395,7 +1395,7 @@ def updateblank(var, ext):
#texto='%s ' % str(id[ig])
#texto+= len(p_bayes)*'%.3e '+'\n'
#probs.write(texto % tuple(p_bayes))
idwrite[ig] = np.int(id[ig])
idwrite[ig] = np.int64(id[ig])
probswrite[ig] = p_bayes

#if ig<ng-1:
Expand Down
2 changes: 1 addition & 1 deletion src/desc_bpz/useful_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def ascend(x):
Recommended usage:
if not ascend(x): sort(x)
"""
return alltrue(greater_equal(x[1:],x[0:-1]))
return all(greater_equal(x[1:],x[0:-1]))


#def match_resol(xg,yg,xf,method="linear"):
Expand Down

0 comments on commit b9eb753

Please sign in to comment.