From fc83aa28d7e3affeeb5a85dd105da861a771ac66 Mon Sep 17 00:00:00 2001 From: Andrew Bae Date: Fri, 12 Jun 2026 20:43:41 -0700 Subject: [PATCH] MNT: replace removed NumPy aliases for NumPy >=1.24 / 2.0 compatibility NumPy 1.24 removed the deprecated builtin-type aliases (np.float, np.int, np.object, np.complex) and NumPy 2.0 removed np.infty. Since requirements.txt installs an unpinned (current) NumPy, these names raise AttributeError at runtime, breaking large parts of the package. Replace them with the exact equivalents the NumPy migration guide recommends: np.float/np.int/np.object/np.complex -> the Python builtins they aliased, and np.infty -> np.inf. These substitutions are behavior-preserving. Done with a tokenize-based pass so only real code is touched; occurrences in comments and string literals are left unchanged. np.in1d is intentionally NOT changed here because np.isin differs in output shape and needs case-by-case review. Continues the cleanup from #81 and #90. 106 substitutions across 23 files. All modified files compile. Co-Authored-By: Claude Opus 4.8 (1M context) --- pyCHX/Two_Time_Correlation_Function.py | 6 ++-- pyCHX/chx_compress.py | 2 +- pyCHX/chx_crosscor.py | 2 +- pyCHX/chx_generic_functions.py | 2 +- pyCHX/chx_speckle.py | 2 +- pyCHX/chx_specklecp.py | 30 +++++++++---------- .../Two_Time_Correlation_Function.py | 6 ++-- pyCHX/v2/_commonspeckle/chx_compress.py | 10 +++---- pyCHX/v2/_commonspeckle/chx_correlationc.py | 8 ++--- .../_commonspeckle/chx_generic_functions.py | 8 ++--- pyCHX/v2/_commonspeckle/chx_speckle.py | 2 +- pyCHX/v2/_commonspeckle/chx_specklecp.py | 30 +++++++++---------- pyCHX/v2/_commonspeckle/xpcs_timepixel.py | 6 ++-- pyCHX/v2/_futurepyCHX/Create_Report.py | 2 +- .../Two_Time_Correlation_Function.py | 6 ++-- pyCHX/v2/_futurepyCHX/chx_compress.py | 10 +++---- pyCHX/v2/_futurepyCHX/chx_correlationc.py | 8 ++--- pyCHX/v2/_futurepyCHX/chx_crosscor.py | 2 +- .../v2/_futurepyCHX/chx_generic_functions.py | 8 ++--- pyCHX/v2/_futurepyCHX/chx_speckle.py | 2 +- pyCHX/v2/_futurepyCHX/chx_specklecp.py | 30 +++++++++---------- pyCHX/v2/_futurepyCHX/xpcs_timepixel.py | 6 ++-- pyCHX/xpcs_timepixel.py | 2 +- 23 files changed, 95 insertions(+), 95 deletions(-) diff --git a/pyCHX/Two_Time_Correlation_Function.py b/pyCHX/Two_Time_Correlation_Function.py index a110211..b88b626 100644 --- a/pyCHX/Two_Time_Correlation_Function.py +++ b/pyCHX/Two_Time_Correlation_Function.py @@ -289,7 +289,7 @@ def get_qedge2(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_qedge(qstart, qend, qwidth, noqs, return_int=False): @@ -308,7 +308,7 @@ def get_qedge(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_time_edge(tstart, tend, twidth, nots, return_int=False): @@ -328,7 +328,7 @@ def get_time_edge(tstart, tend, twidth, nots, return_int=False): if not return_int: return tedge, tcenter else: - return np.int(tedge), np.int(tcenter) + return int(tedge), int(tcenter) def rotate_g12q_to_rectangle(g12q): diff --git a/pyCHX/chx_compress.py b/pyCHX/chx_compress.py index 97ca96a..9735d49 100644 --- a/pyCHX/chx_compress.py +++ b/pyCHX/chx_compress.py @@ -452,7 +452,7 @@ def para_segment_compress_eigerdata( print("It will create %i temporary files for parallel compression." % Nf) if Nf > num_max_para_process: - N_runs = np.int(np.ceil(Nf / float(num_max_para_process))) + N_runs = int(np.ceil(Nf / float(num_max_para_process))) print("The parallel run number: %s is larger than num_max_para_process: %s" % (Nf, num_max_para_process)) else: N_runs = 1 diff --git a/pyCHX/chx_crosscor.py b/pyCHX/chx_crosscor.py index c95d417..8b41239 100644 --- a/pyCHX/chx_crosscor.py +++ b/pyCHX/chx_crosscor.py @@ -484,7 +484,7 @@ def fftconvolve_new(in1, in2, mode="full"): s1 = array(in1.shape) s2 = array(in2.shape) - complex_result = np.issubdtype(in1.dtype, np.complex) or np.issubdtype(in2.dtype, np.complex) + complex_result = np.issubdtype(in1.dtype, complex) or np.issubdtype(in2.dtype, complex) shape = s1 + s2 - 1 if mode == "valid": diff --git a/pyCHX/chx_generic_functions.py b/pyCHX/chx_generic_functions.py index 6a67dd2..589f89f 100644 --- a/pyCHX/chx_generic_functions.py +++ b/pyCHX/chx_generic_functions.py @@ -2448,7 +2448,7 @@ def get_series_g2_taus(fra_max_list, acq_time=1, max_fra_num=None, log_taus=True if max_fra_num != None: L = max_fra_num else: - L = np.infty + L = np.inf if n > L: warnings.warn( "Warning: the dose value is too large, and please" diff --git a/pyCHX/chx_speckle.py b/pyCHX/chx_speckle.py index a6eb8f3..b87a1a9 100644 --- a/pyCHX/chx_speckle.py +++ b/pyCHX/chx_speckle.py @@ -113,7 +113,7 @@ def xsvs( num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k_all = np.zeros([num_times, num_roi], dtype=np.object) + prob_k_all = np.zeros([num_times, num_roi], dtype=object) # square of probability density of detecting photons prob_k_pow_all = np.zeros_like(prob_k_all) diff --git a/pyCHX/chx_specklecp.py b/pyCHX/chx_specklecp.py index d03ea3b..b49540f 100644 --- a/pyCHX/chx_specklecp.py +++ b/pyCHX/chx_specklecp.py @@ -221,7 +221,7 @@ def xsvsp_single( # print(time_bin) # number of times in the time bin num_times = len(time_bin) - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) prob_k_std_dev = np.zeros_like(prob_k) his_sum = np.zeros([num_times, num_roi]) # print( len(res) ) @@ -430,7 +430,7 @@ def xsvsc_single( # number of pixels per ROI num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) his_sum = np.zeros([num_times, num_roi]) # square of probability density of detecting photons prob_k_pow = np.zeros_like(prob_k) @@ -706,9 +706,9 @@ def get_his_std(data_pixel, rois, max_cts=None): max_cts = np.max(data_pixel) + 1 qind, pixelist = roi.extract_label_indices(rois) noqs = len(np.unique(qind)) - his = np.zeros([noqs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([noqs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) for qi in range(noqs): pixelist_qi = np.where(qind == qi + 1)[0] # print(qi, max_cts) @@ -779,10 +779,10 @@ def get_binned_his_std_qi(data_pixel_qi, lag_steps, max_cts=None): lag_steps = np.array(lag_steps) lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs], dtype=np.object) - bins = np.zeros_like(his, dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs], dtype=object) + bins = np.zeros_like(his, dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in lag_steps: data_pixel_qi_ = np.sum(reshape_array(data_pixel_qi, lag), axis=1) @@ -813,10 +813,10 @@ def get_binned_his_std(data_pixel, rois, lag_steps, max_cts=None): lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs, noqs], dtype=np.object) - bins = np.zeros([nologs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs, noqs], dtype=object) + bins = np.zeros([nologs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in tqdm(lag_steps): data_pixel_ = np.sum(reshape_array(data_pixel, lag), axis=1) @@ -1351,8 +1351,8 @@ def get_his_std_from_pds(spec_pds, his_shapes=None): if his_shapes is None: M, N = 2, int((len(spkeys) - 1) / 4) # print(M,N) - spec_his = np.zeros([M, N], dtype=np.object) - spec_std = np.zeros([M, N], dtype=np.object) + spec_his = np.zeros([M, N], dtype=object) + spec_std = np.zeros([M, N], dtype=object) for i in range(M): for j in range(N): spec_his[i, j] = np.array(spec_pds[spkeys[1 + i * N + j]][~np.isnan(spec_pds[spkeys[1 + i * N + j]])]) diff --git a/pyCHX/v2/_commonspeckle/Two_Time_Correlation_Function.py b/pyCHX/v2/_commonspeckle/Two_Time_Correlation_Function.py index 6d05898..09ae2af 100644 --- a/pyCHX/v2/_commonspeckle/Two_Time_Correlation_Function.py +++ b/pyCHX/v2/_commonspeckle/Two_Time_Correlation_Function.py @@ -289,7 +289,7 @@ def get_qedge2(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_qedge(qstart, qend, qwidth, noqs, return_int=False): @@ -308,7 +308,7 @@ def get_qedge(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_time_edge(tstart, tend, twidth, nots, return_int=False): @@ -328,7 +328,7 @@ def get_time_edge(tstart, tend, twidth, nots, return_int=False): if not return_int: return tedge, tcenter else: - return np.int(tedge), np.int(tcenter) + return int(tedge), int(tcenter) def rotate_g12q_to_rectangle(g12q): diff --git a/pyCHX/v2/_commonspeckle/chx_compress.py b/pyCHX/v2/_commonspeckle/chx_compress.py index f6c1bf3..329f813 100644 --- a/pyCHX/v2/_commonspeckle/chx_compress.py +++ b/pyCHX/v2/_commonspeckle/chx_compress.py @@ -251,8 +251,8 @@ def read_compressed_eigerdata( CAL = True if CAL: FD = Multifile(filename, beg, end) - imgsum = np.zeros(FD.end - FD.beg, dtype=np.float) - avg_img = np.zeros([FD.md["ncols"], FD.md["nrows"]], dtype=np.float) + imgsum = np.zeros(FD.end - FD.beg, dtype=float) + avg_img = np.zeros([FD.md["ncols"], FD.md["nrows"]], dtype=float) imgsum, bad_frame_list_ = get_each_frame_intensityc( FD, sampling=1, @@ -461,7 +461,7 @@ def para_segment_compress_eigerdata( print("It will create %i temporary files for parallel compression." % Nf) if Nf > num_max_para_process: - N_runs = np.int(np.ceil(Nf / float(num_max_para_process))) + N_runs = int(np.ceil(Nf / float(num_max_para_process))) print("The parallel run number: %s is larger than num_max_para_process: %s" % (Nf, num_max_para_process)) else: N_runs = 1 @@ -544,7 +544,7 @@ def segment_compress_eigerdata( Nimg_ = len(images) M, N = images[0].shape - avg_img = np.zeros([M, N], dtype=np.float) + avg_img = np.zeros([M, N], dtype=float) Nopix = float(avg_img.size) n = 0 good_count = 0 @@ -791,7 +791,7 @@ def init_compress_eigerdata( fp.write(Header) Nimg_ = len(images) - avg_img = np.zeros_like(images[0], dtype=np.float) + avg_img = np.zeros_like(images[0], dtype=float) Nopix = float(avg_img.size) n = 0 good_count = 0 diff --git a/pyCHX/v2/_commonspeckle/chx_correlationc.py b/pyCHX/v2/_commonspeckle/chx_correlationc.py index fb31982..eeb3062 100644 --- a/pyCHX/v2/_commonspeckle/chx_correlationc.py +++ b/pyCHX/v2/_commonspeckle/chx_correlationc.py @@ -1530,14 +1530,14 @@ def get_data(self): Return: 2-D array, shape as (len(images), len(pixellist)) """ - data_array = np.zeros([self.length, len(self.pixelist)], dtype=np.float) + data_array = np.zeros([self.length, len(self.pixelist)], dtype=float) # fra_pix = np.zeros_like( pixelist, dtype=np.float64) timg = np.zeros(self.FD.md["ncols"] * self.FD.md["nrows"], dtype=np.int32) timg[self.pixelist] = np.arange(1, len(self.pixelist) + 1) if self.norm_inten is not None: # Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float) - Mean_Int_Qind = np.ones(len(self.qind), dtype=np.float) + Mean_Int_Qind = np.ones(len(self.qind), dtype=float) noqs = len(np.unique(self.qind)) nopr = np.bincount(self.qind - 1) noprs = np.concatenate([np.array([0]), np.cumsum(nopr)]) @@ -1645,14 +1645,14 @@ def get_data(self): Return: 2-D array, shape as (len(images), len(pixellist)) """ - data_array = np.zeros([self.length, len(self.pixelist)], dtype=np.float) + data_array = np.zeros([self.length, len(self.pixelist)], dtype=float) # fra_pix = np.zeros_like( pixelist, dtype=np.float64) timg = np.zeros(self.FD.md["ncols"] * self.FD.md["nrows"], dtype=np.int32) timg[self.pixelist] = np.arange(1, len(self.pixelist) + 1) if self.mean_int_sets is not None: # Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float) - Mean_Int_Qind = np.ones(len(self.qind), dtype=np.float) + Mean_Int_Qind = np.ones(len(self.qind), dtype=float) noqs = len(np.unique(self.qind)) nopr = np.bincount(self.qind - 1) noprs = np.concatenate([np.array([0]), np.cumsum(nopr)]) diff --git a/pyCHX/v2/_commonspeckle/chx_generic_functions.py b/pyCHX/v2/_commonspeckle/chx_generic_functions.py index fb6db14..f63b281 100644 --- a/pyCHX/v2/_commonspeckle/chx_generic_functions.py +++ b/pyCHX/v2/_commonspeckle/chx_generic_functions.py @@ -1438,7 +1438,7 @@ def get_waxs_beam_center(gamma, origin=[432, 363], Ldet=1495, pixel_size=75 * 1e beam center: for the target gamma, in pixel """ return [ - np.int(origin[0] + np.tan(np.radians(gamma)) * Ldet / pixel_size), + int(origin[0] + np.tan(np.radians(gamma)) * Ldet / pixel_size), origin[1], ] @@ -2543,7 +2543,7 @@ def get_series_g2_taus(fra_max_list, acq_time=1, max_fra_num=None, log_taus=True if max_fra_num is not None: L = max_fra_num else: - L = np.infty + L = np.inf if n > L: warnings.warn( "Warning: the dose value is too large, and please" @@ -2638,8 +2638,8 @@ def combine_images(filenames, outputfile, outsize=(2000, 2400)): # nx = np.int( np.ceil( np.sqrt(N)) ) # ny = np.int( np.ceil( N / float(nx) ) ) - ny = np.int(np.ceil(np.sqrt(N))) - nx = np.int(np.ceil(N / float(ny))) + ny = int(np.ceil(np.sqrt(N))) + nx = int(np.ceil(N / float(ny))) # print(nx,ny) result = Image.new("RGB", outsize, color=(255, 255, 255, 0)) diff --git a/pyCHX/v2/_commonspeckle/chx_speckle.py b/pyCHX/v2/_commonspeckle/chx_speckle.py index 75ab068..1444989 100644 --- a/pyCHX/v2/_commonspeckle/chx_speckle.py +++ b/pyCHX/v2/_commonspeckle/chx_speckle.py @@ -113,7 +113,7 @@ def xsvs( num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k_all = np.zeros([num_times, num_roi], dtype=np.object) + prob_k_all = np.zeros([num_times, num_roi], dtype=object) # square of probability density of detecting photons prob_k_pow_all = np.zeros_like(prob_k_all) diff --git a/pyCHX/v2/_commonspeckle/chx_specklecp.py b/pyCHX/v2/_commonspeckle/chx_specklecp.py index 771e51f..a96d312 100644 --- a/pyCHX/v2/_commonspeckle/chx_specklecp.py +++ b/pyCHX/v2/_commonspeckle/chx_specklecp.py @@ -232,7 +232,7 @@ def xsvsp_single( # print(time_bin) # number of times in the time bin num_times = len(time_bin) - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) prob_k_std_dev = np.zeros_like(prob_k) his_sum = np.zeros([num_times, num_roi]) # print( len(res) ) @@ -441,7 +441,7 @@ def xsvsc_single( # number of pixels per ROI num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) his_sum = np.zeros([num_times, num_roi]) # square of probability density of detecting photons prob_k_pow = np.zeros_like(prob_k) @@ -727,9 +727,9 @@ def get_his_std(data_pixel, rois, max_cts=None): max_cts = np.max(data_pixel) + 1 qind, pixelist = roi.extract_label_indices(rois) noqs = len(np.unique(qind)) - his = np.zeros([noqs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([noqs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) for qi in range(noqs): pixelist_qi = np.where(qind == qi + 1)[0] # print(qi, max_cts) @@ -800,10 +800,10 @@ def get_binned_his_std_qi(data_pixel_qi, lag_steps, max_cts=None): lag_steps = np.array(lag_steps) lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs], dtype=np.object) - bins = np.zeros_like(his, dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs], dtype=object) + bins = np.zeros_like(his, dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in lag_steps: data_pixel_qi_ = np.sum(reshape_array(data_pixel_qi, lag), axis=1) @@ -834,10 +834,10 @@ def get_binned_his_std(data_pixel, rois, lag_steps, max_cts=None): lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs, noqs], dtype=np.object) - bins = np.zeros([nologs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs, noqs], dtype=object) + bins = np.zeros([nologs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in tqdm(lag_steps): data_pixel_ = np.sum(reshape_array(data_pixel, lag), axis=1) @@ -1390,8 +1390,8 @@ def get_his_std_from_pds(spec_pds, his_shapes=None): if his_shapes is None: M, N = 2, int((len(spkeys) - 1) / 4) # print(M,N) - spec_his = np.zeros([M, N], dtype=np.object) - spec_std = np.zeros([M, N], dtype=np.object) + spec_his = np.zeros([M, N], dtype=object) + spec_std = np.zeros([M, N], dtype=object) for i in range(M): for j in range(N): spec_his[i, j] = np.array(spec_pds[spkeys[1 + i * N + j]][~np.isnan(spec_pds[spkeys[1 + i * N + j]])]) diff --git a/pyCHX/v2/_commonspeckle/xpcs_timepixel.py b/pyCHX/v2/_commonspeckle/xpcs_timepixel.py index 6c594a9..6427dd5 100644 --- a/pyCHX/v2/_commonspeckle/xpcs_timepixel.py +++ b/pyCHX/v2/_commonspeckle/xpcs_timepixel.py @@ -336,7 +336,7 @@ def init_compress_timepix_data(pos, t, binstep, filename, mask=None, md=None, no ) fp.write(Header) - N_ = np.int(np.ceil((t.max() - t.min()) / binstep)) + N_ = int(np.ceil((t.max() - t.min()) / binstep)) print("There are %s frames to be compressed..." % (N_ - 1)) ps, vs, cs = get_pvlist_from_post(pos, t, binstep, detx=md["sx"], dety=md["sy"]) @@ -344,7 +344,7 @@ def init_compress_timepix_data(pos, t, binstep, filename, mask=None, md=None, no css = np.cumsum(cs) imgsum = np.zeros(N) good_count = 0 - avg_img = np.zeros([md["sy"], md["sx"]], dtype=np.float) + avg_img = np.zeros([md["sy"], md["sx"]], dtype=float) for i in tqdm(range(0, N)): if i == 0: @@ -436,7 +436,7 @@ def init_compress_timepix_data_light_duty( imgsum = np.zeros(N - 1) print("There are %s frames to be compressed..." % (N - 1)) good_count = 0 - avg_img = np.zeros([md["sy"], md["sx"]], dtype=np.float) + avg_img = np.zeros([md["sy"], md["sx"]], dtype=float) for i in tqdm(range(N - 1)): ind1 = np.argmin(np.abs(tx[i] - t)) ind2 = np.argmin(np.abs(tx[i + 1] - t)) diff --git a/pyCHX/v2/_futurepyCHX/Create_Report.py b/pyCHX/v2/_futurepyCHX/Create_Report.py index 4c7a560..6e84633 100644 --- a/pyCHX/v2/_futurepyCHX/Create_Report.py +++ b/pyCHX/v2/_futurepyCHX/Create_Report.py @@ -2018,7 +2018,7 @@ def recursively_save_dict_contents_to_group(h5file, path, dic): if not isinstance(key, str): raise ValueError("dict keys must be strings to save to hdf5") # save strings, numpy.int64, and numpy.float64 types - if isinstance(item, (np.int64, np.float64, str, np.float, float, np.float32, int)): + if isinstance(item, (np.int64, np.float64, str, float, float, np.float32, int)): # print( 'here' ) h5file[path + key] = item if not h5file[path + key].value == item: diff --git a/pyCHX/v2/_futurepyCHX/Two_Time_Correlation_Function.py b/pyCHX/v2/_futurepyCHX/Two_Time_Correlation_Function.py index b3d7899..3a5e4f9 100644 --- a/pyCHX/v2/_futurepyCHX/Two_Time_Correlation_Function.py +++ b/pyCHX/v2/_futurepyCHX/Two_Time_Correlation_Function.py @@ -289,7 +289,7 @@ def get_qedge2(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_qedge(qstart, qend, qwidth, noqs, return_int=False): @@ -308,7 +308,7 @@ def get_qedge(qstart, qend, qwidth, noqs, return_int=False): if not return_int: return qedge, qcenter else: - return np.int(qedge), np.int(qcenter) + return int(qedge), int(qcenter) def get_time_edge(tstart, tend, twidth, nots, return_int=False): @@ -328,7 +328,7 @@ def get_time_edge(tstart, tend, twidth, nots, return_int=False): if not return_int: return tedge, tcenter else: - return np.int(tedge), np.int(tcenter) + return int(tedge), int(tcenter) def rotate_g12q_to_rectangle(g12q): diff --git a/pyCHX/v2/_futurepyCHX/chx_compress.py b/pyCHX/v2/_futurepyCHX/chx_compress.py index 8ac7184..d81a3e6 100644 --- a/pyCHX/v2/_futurepyCHX/chx_compress.py +++ b/pyCHX/v2/_futurepyCHX/chx_compress.py @@ -248,8 +248,8 @@ def read_compressed_eigerdata( CAL = True if CAL: FD = Multifile(filename, beg, end) - imgsum = np.zeros(FD.end - FD.beg, dtype=np.float) - avg_img = np.zeros([FD.md["ncols"], FD.md["nrows"]], dtype=np.float) + imgsum = np.zeros(FD.end - FD.beg, dtype=float) + avg_img = np.zeros([FD.md["ncols"], FD.md["nrows"]], dtype=float) imgsum, bad_frame_list_ = get_each_frame_intensityc( FD, sampling=1, @@ -458,7 +458,7 @@ def para_segment_compress_eigerdata( print("It will create %i temporary files for parallel compression." % Nf) if Nf > num_max_para_process: - N_runs = np.int(np.ceil(Nf / float(num_max_para_process))) + N_runs = int(np.ceil(Nf / float(num_max_para_process))) print("The parallel run number: %s is larger than num_max_para_process: %s" % (Nf, num_max_para_process)) else: N_runs = 1 @@ -541,7 +541,7 @@ def segment_compress_eigerdata( Nimg_ = len(images) M, N = images[0].shape - avg_img = np.zeros([M, N], dtype=np.float) + avg_img = np.zeros([M, N], dtype=float) Nopix = float(avg_img.size) n = 0 good_count = 0 @@ -788,7 +788,7 @@ def init_compress_eigerdata( fp.write(Header) Nimg_ = len(images) - avg_img = np.zeros_like(images[0], dtype=np.float) + avg_img = np.zeros_like(images[0], dtype=float) Nopix = float(avg_img.size) n = 0 good_count = 0 diff --git a/pyCHX/v2/_futurepyCHX/chx_correlationc.py b/pyCHX/v2/_futurepyCHX/chx_correlationc.py index fb31982..eeb3062 100644 --- a/pyCHX/v2/_futurepyCHX/chx_correlationc.py +++ b/pyCHX/v2/_futurepyCHX/chx_correlationc.py @@ -1530,14 +1530,14 @@ def get_data(self): Return: 2-D array, shape as (len(images), len(pixellist)) """ - data_array = np.zeros([self.length, len(self.pixelist)], dtype=np.float) + data_array = np.zeros([self.length, len(self.pixelist)], dtype=float) # fra_pix = np.zeros_like( pixelist, dtype=np.float64) timg = np.zeros(self.FD.md["ncols"] * self.FD.md["nrows"], dtype=np.int32) timg[self.pixelist] = np.arange(1, len(self.pixelist) + 1) if self.norm_inten is not None: # Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float) - Mean_Int_Qind = np.ones(len(self.qind), dtype=np.float) + Mean_Int_Qind = np.ones(len(self.qind), dtype=float) noqs = len(np.unique(self.qind)) nopr = np.bincount(self.qind - 1) noprs = np.concatenate([np.array([0]), np.cumsum(nopr)]) @@ -1645,14 +1645,14 @@ def get_data(self): Return: 2-D array, shape as (len(images), len(pixellist)) """ - data_array = np.zeros([self.length, len(self.pixelist)], dtype=np.float) + data_array = np.zeros([self.length, len(self.pixelist)], dtype=float) # fra_pix = np.zeros_like( pixelist, dtype=np.float64) timg = np.zeros(self.FD.md["ncols"] * self.FD.md["nrows"], dtype=np.int32) timg[self.pixelist] = np.arange(1, len(self.pixelist) + 1) if self.mean_int_sets is not None: # Mean_Int_Qind = np.array( self.qind.copy(), dtype=np.float) - Mean_Int_Qind = np.ones(len(self.qind), dtype=np.float) + Mean_Int_Qind = np.ones(len(self.qind), dtype=float) noqs = len(np.unique(self.qind)) nopr = np.bincount(self.qind - 1) noprs = np.concatenate([np.array([0]), np.cumsum(nopr)]) diff --git a/pyCHX/v2/_futurepyCHX/chx_crosscor.py b/pyCHX/v2/_futurepyCHX/chx_crosscor.py index 28e839b..deae401 100644 --- a/pyCHX/v2/_futurepyCHX/chx_crosscor.py +++ b/pyCHX/v2/_futurepyCHX/chx_crosscor.py @@ -492,7 +492,7 @@ def fftconvolve_new(in1, in2, mode="full"): s1 = array(in1.shape) s2 = array(in2.shape) - complex_result = np.issubdtype(in1.dtype, np.complex) or np.issubdtype(in2.dtype, np.complex) + complex_result = np.issubdtype(in1.dtype, complex) or np.issubdtype(in2.dtype, complex) shape = s1 + s2 - 1 if mode == "valid": diff --git a/pyCHX/v2/_futurepyCHX/chx_generic_functions.py b/pyCHX/v2/_futurepyCHX/chx_generic_functions.py index 0e3c577..d58d0cc 100644 --- a/pyCHX/v2/_futurepyCHX/chx_generic_functions.py +++ b/pyCHX/v2/_futurepyCHX/chx_generic_functions.py @@ -1438,7 +1438,7 @@ def get_waxs_beam_center(gamma, origin=[432, 363], Ldet=1495, pixel_size=75 * 1e beam center: for the target gamma, in pixel """ return [ - np.int(origin[0] + np.tan(np.radians(gamma)) * Ldet / pixel_size), + int(origin[0] + np.tan(np.radians(gamma)) * Ldet / pixel_size), origin[1], ] @@ -2543,7 +2543,7 @@ def get_series_g2_taus(fra_max_list, acq_time=1, max_fra_num=None, log_taus=True if max_fra_num is not None: L = max_fra_num else: - L = np.infty + L = np.inf if n > L: warnings.warn( "Warning: the dose value is too large, and please" @@ -2638,8 +2638,8 @@ def combine_images(filenames, outputfile, outsize=(2000, 2400)): # nx = np.int( np.ceil( np.sqrt(N)) ) # ny = np.int( np.ceil( N / float(nx) ) ) - ny = np.int(np.ceil(np.sqrt(N))) - nx = np.int(np.ceil(N / float(ny))) + ny = int(np.ceil(np.sqrt(N))) + nx = int(np.ceil(N / float(ny))) # print(nx,ny) result = Image.new("RGB", outsize, color=(255, 255, 255, 0)) diff --git a/pyCHX/v2/_futurepyCHX/chx_speckle.py b/pyCHX/v2/_futurepyCHX/chx_speckle.py index 75ab068..1444989 100644 --- a/pyCHX/v2/_futurepyCHX/chx_speckle.py +++ b/pyCHX/v2/_futurepyCHX/chx_speckle.py @@ -113,7 +113,7 @@ def xsvs( num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k_all = np.zeros([num_times, num_roi], dtype=np.object) + prob_k_all = np.zeros([num_times, num_roi], dtype=object) # square of probability density of detecting photons prob_k_pow_all = np.zeros_like(prob_k_all) diff --git a/pyCHX/v2/_futurepyCHX/chx_specklecp.py b/pyCHX/v2/_futurepyCHX/chx_specklecp.py index a4e5029..b109e2d 100644 --- a/pyCHX/v2/_futurepyCHX/chx_specklecp.py +++ b/pyCHX/v2/_futurepyCHX/chx_specklecp.py @@ -226,7 +226,7 @@ def xsvsp_single( # print(time_bin) # number of times in the time bin num_times = len(time_bin) - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) prob_k_std_dev = np.zeros_like(prob_k) his_sum = np.zeros([num_times, num_roi]) # print( len(res) ) @@ -435,7 +435,7 @@ def xsvsc_single( # number of pixels per ROI num_pixels = np.bincount(labels, minlength=(num_roi + 1))[1:] # probability density of detecting photons - prob_k = np.zeros([num_times, num_roi], dtype=np.object) + prob_k = np.zeros([num_times, num_roi], dtype=object) his_sum = np.zeros([num_times, num_roi]) # square of probability density of detecting photons prob_k_pow = np.zeros_like(prob_k) @@ -721,9 +721,9 @@ def get_his_std(data_pixel, rois, max_cts=None): max_cts = np.max(data_pixel) + 1 qind, pixelist = roi.extract_label_indices(rois) noqs = len(np.unique(qind)) - his = np.zeros([noqs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([noqs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) for qi in range(noqs): pixelist_qi = np.where(qind == qi + 1)[0] # print(qi, max_cts) @@ -794,10 +794,10 @@ def get_binned_his_std_qi(data_pixel_qi, lag_steps, max_cts=None): lag_steps = np.array(lag_steps) lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs], dtype=np.object) - bins = np.zeros_like(his, dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs], dtype=object) + bins = np.zeros_like(his, dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in lag_steps: data_pixel_qi_ = np.sum(reshape_array(data_pixel_qi, lag), axis=1) @@ -828,10 +828,10 @@ def get_binned_his_std(data_pixel, rois, lag_steps, max_cts=None): lag_steps = lag_steps[np.nonzero(lag_steps)] nologs = len(lag_steps) - his = np.zeros([nologs, noqs], dtype=np.object) - bins = np.zeros([nologs], dtype=np.object) - std = np.zeros_like(his, dtype=np.object) - kmean = np.zeros_like(his, dtype=np.object) + his = np.zeros([nologs, noqs], dtype=object) + bins = np.zeros([nologs], dtype=object) + std = np.zeros_like(his, dtype=object) + kmean = np.zeros_like(his, dtype=object) i = 0 for lag in tqdm(lag_steps): data_pixel_ = np.sum(reshape_array(data_pixel, lag), axis=1) @@ -1384,8 +1384,8 @@ def get_his_std_from_pds(spec_pds, his_shapes=None): if his_shapes is None: M, N = 2, int((len(spkeys) - 1) / 4) # print(M,N) - spec_his = np.zeros([M, N], dtype=np.object) - spec_std = np.zeros([M, N], dtype=np.object) + spec_his = np.zeros([M, N], dtype=object) + spec_std = np.zeros([M, N], dtype=object) for i in range(M): for j in range(N): spec_his[i, j] = np.array(spec_pds[spkeys[1 + i * N + j]][~np.isnan(spec_pds[spkeys[1 + i * N + j]])]) diff --git a/pyCHX/v2/_futurepyCHX/xpcs_timepixel.py b/pyCHX/v2/_futurepyCHX/xpcs_timepixel.py index 264da7e..eb3130a 100644 --- a/pyCHX/v2/_futurepyCHX/xpcs_timepixel.py +++ b/pyCHX/v2/_futurepyCHX/xpcs_timepixel.py @@ -336,7 +336,7 @@ def init_compress_timepix_data(pos, t, binstep, filename, mask=None, md=None, no ) fp.write(Header) - N_ = np.int(np.ceil((t.max() - t.min()) / binstep)) + N_ = int(np.ceil((t.max() - t.min()) / binstep)) print("There are %s frames to be compressed..." % (N_ - 1)) ps, vs, cs = get_pvlist_from_post(pos, t, binstep, detx=md["sx"], dety=md["sy"]) @@ -344,7 +344,7 @@ def init_compress_timepix_data(pos, t, binstep, filename, mask=None, md=None, no css = np.cumsum(cs) imgsum = np.zeros(N) good_count = 0 - avg_img = np.zeros([md["sy"], md["sx"]], dtype=np.float) + avg_img = np.zeros([md["sy"], md["sx"]], dtype=float) for i in tqdm(range(0, N)): if i == 0: @@ -436,7 +436,7 @@ def init_compress_timepix_data_light_duty( imgsum = np.zeros(N - 1) print("There are %s frames to be compressed..." % (N - 1)) good_count = 0 - avg_img = np.zeros([md["sy"], md["sx"]], dtype=np.float) + avg_img = np.zeros([md["sy"], md["sx"]], dtype=float) for i in tqdm(range(N - 1)): ind1 = np.argmin(np.abs(tx[i] - t)) ind2 = np.argmin(np.abs(tx[i + 1] - t)) diff --git a/pyCHX/xpcs_timepixel.py b/pyCHX/xpcs_timepixel.py index 85080c5..af4a364 100644 --- a/pyCHX/xpcs_timepixel.py +++ b/pyCHX/xpcs_timepixel.py @@ -301,7 +301,7 @@ def init_compress_timepix_data(pos, t, binstep, filename, mask=None, md=None, no ) fp.write(Header) - N_ = np.int(np.ceil((t.max() - t.min()) / binstep)) + N_ = int(np.ceil((t.max() - t.min()) / binstep)) print("There are %s frames to be compressed..." % (N_ - 1)) ps, vs, cs = get_pvlist_from_post(pos, t, binstep, detx=md["sx"], dety=md["sy"])