From 616e648c5331b67791e0ba12e8a05319882231f7 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 23 Dec 2022 11:02:26 +0100 Subject: [PATCH] deal with numpy deprecation notices --- n3fit/src/n3fit/checks.py | 2 +- n3fit/src/n3fit/stopping.py | 4 ++-- validphys2/src/validphys/dataplots.py | 2 +- validphys2/src/validphys/lhio.py | 2 +- validphys2/src/validphys/n3fit_data.py | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/n3fit/src/n3fit/checks.py b/n3fit/src/n3fit/checks.py index e07d27d74c..b651f512c5 100644 --- a/n3fit/src/n3fit/checks.py +++ b/n3fit/src/n3fit/checks.py @@ -21,7 +21,7 @@ def _is_floatable(num): if isinstance(num, numbers.Number): return True try: - np.float(num) + float(num) return True except (ValueError, TypeError): return False diff --git a/n3fit/src/n3fit/stopping.py b/n3fit/src/n3fit/stopping.py index 7b805beccd..d08a0e04ef 100644 --- a/n3fit/src/n3fit/stopping.py +++ b/n3fit/src/n3fit/stopping.py @@ -451,8 +451,8 @@ def __init__( # Initialize internal variables for the stopping self.n_replicas = len(pdf_models) self.threshold_chi2 = threshold_chi2 - self.stopping_degree = np.zeros(self.n_replicas, dtype=np.int) - self.count = np.zeros(self.n_replicas, dtype=np.int) + self.stopping_degree = np.zeros(self.n_replicas, dtype=int) + self.count = np.zeros(self.n_replicas, dtype=int) self.dont_stop = dont_stop self.stop_now = False diff --git a/validphys2/src/validphys/dataplots.py b/validphys2/src/validphys/dataplots.py index 80e2709a7e..41248c842c 100644 --- a/validphys2/src/validphys/dataplots.py +++ b/validphys2/src/validphys/dataplots.py @@ -299,7 +299,7 @@ def _plot_fancy_impl(results, commondata, cutlist, x = info.get_xcol(line_data) try: - x = np.asanyarray(x, np.float) + x = np.asanyarray(x, float) except ValueError: xticklabels = x npoints = len(x) diff --git a/validphys2/src/validphys/lhio.py b/validphys2/src/validphys/lhio.py index 6aaf2a0bf0..615afd63ca 100644 --- a/validphys2/src/validphys/lhio.py +++ b/validphys2/src/validphys/lhio.py @@ -33,7 +33,7 @@ def read_xqf_from_file(f): return None xvals = np.fromstring(xtext, sep = " ") qvals = np.fromstring(qtext, sep = " ") - fvals = np.fromstring(ftext, sep = " ", dtype=np.int) + fvals = np.fromstring(ftext, sep = " ", dtype=int) vals = np.fromstring(b''.join(lines), sep= " ") return pd.Series(vals, index = pd.MultiIndex.from_product((xvals, qvals, fvals))) diff --git a/validphys2/src/validphys/n3fit_data.py b/validphys2/src/validphys/n3fit_data.py index 3c4cc78095..7f50c96992 100644 --- a/validphys2/src/validphys/n3fit_data.py +++ b/validphys2/src/validphys/n3fit_data.py @@ -98,7 +98,7 @@ def tr_masks(data, replica_trvlseed): # If that number is 0, then get 1 point with probability frac trmax = int(rng.random() < frac) mask = np.concatenate( - [np.ones(trmax, dtype=np.bool), np.zeros(ndata - trmax, dtype=np.bool)] + [np.ones(trmax, dtype=bool), np.zeros(ndata - trmax, dtype=bool)] ) rng.shuffle(mask) trmask_partial.append(mask) @@ -164,10 +164,10 @@ def kfold_masks(kpartitions, data): ndata = len(cuts.load()) if cuts else dataset.commondata.ndata # If the dataset is in the fold, its mask is full of 0s if str(dataset) in data_fold: - mask.append(np.zeros(ndata, dtype=np.bool)) + mask.append(np.zeros(ndata, dtype=bool)) # otherwise of ones else: - mask.append(np.ones(ndata, dtype=np.bool)) + mask.append(np.ones(ndata, dtype=bool)) list_folds.append(np.concatenate(mask)) return list_folds @@ -519,7 +519,7 @@ def _fitting_lagrange_dict(lambdadataset): ndata = positivity_datasets[0].ndata return { "datasets": positivity_datasets, - "trmask": np.ones(ndata, dtype=np.bool), + "trmask": np.ones(ndata, dtype=bool), "name": lambdadataset.name, "expdata": np.zeros((1, ndata)), "ndata": ndata,