Skip to content

Commit 92a5871

Browse files
Copilotandreicuceu
andcommitted
Replace deprecated np.in1d with np.isin across codebase
Co-authored-by: andreicuceu <28951059+andreicuceu@users.noreply.github.com> Agent-Logs-Url: https://github.com/igmhub/picca/sessions/a84f61d6-2f15-418c-8701-3552c51ed26b
1 parent b09f718 commit 92a5871

9 files changed

Lines changed: 11 additions & 11 deletions

File tree

py/picca/bin/picca_export_co.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def main(cmdargs):
209209
sys.exit()
210210

211211
w = np.logical_not(
212-
np.in1d(data[type_corr1]['HEALPID'],
212+
np.isin(data[type_corr1]['HEALPID'],
213213
data[type_corr2]['HEALPID']))
214214
if w.sum() != 0:
215215
userprint("WARNING: HEALPID are different by {} for {}:{} "

py/picca/bin/picca_export_cross_covariance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def main(cmdargs):
7777
# Add unshared healpix as empty data
7878
for key in sorted(list(data.keys())):
7979
key2 = (key + 1) % 2
80-
w = np.logical_not(np.in1d(data[key2]['HEALPID'], data[key]['HEALPID']))
80+
w = np.logical_not(np.isin(data[key2]['HEALPID'], data[key]['HEALPID']))
8181
if w.sum() > 0:
8282
new_healpix = data[key2]['HEALPID'][w]
8383
num_new_healpix = new_healpix.size

py/picca/bin/picca_reduce_spall.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
qso_catalog = Table.read(args.qso_catalog)
2929
print(f'{len(qso_catalog)} entries found in QSO catalog')
3030

31-
w = np.in1d(spall['THING_ID'], qso_catalog['THING_ID'])
31+
w = np.isin(spall['THING_ID'], qso_catalog['THING_ID'])
3232
spall_qso = spall[w]
3333
#-- Columns required for picca_deltas.py for spec, spplate formats and usage of multiple observations
3434
spall_qso.keep_columns(

py/picca/cf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ def compute_xi_1d_cross(healpix):
13231323
weights1 = delta1.weights[select1]
13241324

13251325
thingids = [delta2.thingid for delta2 in data2[healpix]]
1326-
neighbours = data2[healpix][np.in1d(thingids, [delta1.thingid])]
1326+
neighbours = data2[healpix][np.isin(thingids, [delta1.thingid])]
13271327
for delta2 in neighbours:
13281328
select2 = delta2.log_lambda <= log_lambda_max
13291329
select2 &= delta2.log_lambda >= log_lambda_min

py/picca/delta_extraction/quasar_catalogues/drq_catalogue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def read_spall(self, drq_catalogue):
274274
f"message: {str(error)}"
275275
) from error
276276

277-
w = np.in1d(catalogue["THING_ID"], drq_catalogue["THING_ID"])
277+
w = np.isin(catalogue["THING_ID"], drq_catalogue["THING_ID"])
278278
self.logger.progress(f"Found {np.sum(w)} spectra with required THING_ID")
279279
w &= catalogue["PLATEQUALITY"] == "good"
280280
self.logger.progress(f"Found {np.sum(w)} spectra with 'good' plate")

py/picca/pk1d/compute_pk1d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def fill_masked_pixels(
326326
lambda_or_log_lambda_index += 0.5
327327
lambda_or_log_lambda_index = np.array(lambda_or_log_lambda_index, dtype=int)
328328
index_all = range(lambda_or_log_lambda_index[-1] + 1)
329-
index_ok = np.in1d(index_all, lambda_or_log_lambda_index)
329+
index_ok = np.isin(index_all, lambda_or_log_lambda_index)
330330

331331
delta_new = np.zeros(len(index_all))
332332
delta_new[index_ok] = delta

py/picca/raw_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def read_transmission_file(filename, num_bins, objs_thingid, tracer='F_LYA', lam
7373

7474
hdul = fitsio.FITS(filename)
7575
thingid = hdul['METADATA']['MOCKID'][:]
76-
if np.in1d(thingid, objs_thingid).sum() == 0:
76+
if np.isin(thingid, objs_thingid).sum() == 0:
7777
hdul.close()
7878
return
7979
if 'RA' in hdul['METADATA'].get_colnames() and 'DEC' in hdul['METADATA'].get_colnames():
@@ -116,7 +116,7 @@ def read_transmission_file(filename, num_bins, objs_thingid, tracer='F_LYA', lam
116116
(lambda_rest_frame < lambda_max_rest_frame)] = 1
117117
num_pixels = np.sum(valid_pixels, axis=1)
118118
w = num_pixels >= 50
119-
w &= np.in1d(thingid, objs_thingid)
119+
w &= np.isin(thingid, objs_thingid)
120120
if w.sum() == 0:
121121
hdul.close()
122122
return

py/picca/xcf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,15 +965,15 @@ def compute_wick_terms(healpixs):
965965
thingid4 = np.array([obj4.thingid for obj4 in neighbours])
966966

967967
if max_diagram == 5:
968-
w = np.in1d(delta1.neighbours, delta3.neighbours)
968+
w = np.isin(delta1.neighbours, delta3.neighbours)
969969
if w.sum() == 0:
970970
continue
971971
aux_ang12 = ang12[w]
972972
aux_r_comov2 = r_comov2[w]
973973
aux_weights2 = weights2[w]
974974
aux_thingid2 = thingid2[w]
975975

976-
w = np.in1d(delta3.neighbours, delta1.neighbours)
976+
w = np.isin(delta3.neighbours, delta1.neighbours)
977977
if w.sum() == 0:
978978
continue
979979
ang34 = ang34[w]

tutorials/picca_export_stacked_correlation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
### Add unshared healpix as empty data
8383
for i in range(nbData):
8484
for j in range(nbData):
85-
w = np.logical_not( np.in1d(data[j]['HEALPID'],data[i]['HEALPID']) )
85+
w = np.logical_not( np.isin(data[j]['HEALPID'],data[i]['HEALPID']) )
8686
if w.sum()>0:
8787
new_healpix = data[j]['HEALPID'][w]
8888
nb_new_healpix = new_healpix.size

0 commit comments

Comments
 (0)