From f8ba2c0178b26c5b4663c678ba68de6ea295b12f Mon Sep 17 00:00:00 2001 From: Jonathan Vandermause Date: Sun, 15 Sep 2024 08:17:26 -0400 Subject: [PATCH 1/2] change np floats to float 64s --- flare/descriptors/env.py | 2 +- flare/utils/parameters.py | 2 +- requirements.txt | 2 +- tests/test_grid_kernel.py | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/flare/descriptors/env.py b/flare/descriptors/env.py index 2c6cb2e1d..acb8d5e52 100644 --- a/flare/descriptors/env.py +++ b/flare/descriptors/env.py @@ -192,7 +192,7 @@ def setup_mask(self, cutoffs_mask): self.cut3b_mask = cutoffs_mask.get("cut3b_mask", None) if "threebody_cutoff_list" in cutoffs_mask: self.threebody_cutoff_list = np.array( - cutoffs_mask["threebody_cutoff_list"], dtype=np.float + cutoffs_mask["threebody_cutoff_list"], dtype=np.float64 ) def compute_env(self): diff --git a/flare/utils/parameters.py b/flare/utils/parameters.py index b69c59ba3..5ed1478fc 100644 --- a/flare/utils/parameters.py +++ b/flare/utils/parameters.py @@ -247,7 +247,7 @@ def check_instantiation(hyps, cutoffs, kernels, param_dict): # Ensure typed correctly as numpy array param_dict["original_hyps"] = nparray( - param_dict["original_hyps"], dtype=np.float + param_dict["original_hyps"], dtype=np.float64 ) if (len(param_dict["original_hyps"]) - 1) not in param_dict["map"]: assert ( diff --git a/requirements.txt b/requirements.txt index 2d1bf81ba..0a9a2c01b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -numpy >=1.18, <1.23 +numpy scipy memory_profiler numba diff --git a/tests/test_grid_kernel.py b/tests/test_grid_kernel.py index eaf6fa957..b47c7ce64 100644 --- a/tests/test_grid_kernel.py +++ b/tests/test_grid_kernel.py @@ -171,10 +171,10 @@ def get_reference(grid_env, species, parameter, kernel_name, same_hyps): ) args = from_mask_to_args(hm["hyps"], hm["cutoffs"], None if same_hyps else hm) - energy_force = np.zeros(3, dtype=np.float) - # force_force = np.zeros(3, dtype=np.float) - # force_energy = np.zeros(3, dtype=np.float) - # energy_energy = np.zeros(3, dtype=np.float) + energy_force = np.zeros(3, dtype=np.float64) + # force_force = np.zeros(3, dtype=np.float64) + # force_energy = np.zeros(3, dtype=np.float64) + # energy_energy = np.zeros(3, dtype=np.float64) for i in range(3): energy_force[i] = force_en_kernel(env, grid_env, i + 1, *args) # force_energy[i] = force_en_kernel(env, grid_env, i, *args) From 26943d9c6228b1d80d122add8f365072ea558a33 Mon Sep 17 00:00:00 2001 From: Jonathan Vandermause Date: Sun, 15 Sep 2024 08:36:34 -0400 Subject: [PATCH 2/2] replace ints with int8s --- flare/utils/parameter_helper.py | 2 +- flare/utils/parameters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flare/utils/parameter_helper.py b/flare/utils/parameter_helper.py index 3b3aaf8fb..d3ca17fec 100644 --- a/flare/utils/parameter_helper.py +++ b/flare/utils/parameter_helper.py @@ -839,7 +839,7 @@ def summarize_group(self, group_type): for ele in self.groups["specie"][idt]: atom_n = atomic_numbers[ele] if atom_n >= len(self.species_mask): - new_mask = np.ones(atom_n, dtype=np.int) * (nspecie - 1) + new_mask = np.ones(atom_n, dtype=np.int8) * (nspecie - 1) new_mask[: len(self.species_mask)] = self.species_mask self.species_mask = new_mask self.species_mask[atom_n] = idt diff --git a/flare/utils/parameters.py b/flare/utils/parameters.py index 5ed1478fc..7fabd856c 100644 --- a/flare/utils/parameters.py +++ b/flare/utils/parameters.py @@ -196,7 +196,7 @@ def check_instantiation(hyps, cutoffs, kernels, param_dict): # check mask has the right dimension and values mask = param_dict[f"{kernel}_mask"] - param_dict[f"{kernel}_mask"] = nparray(mask, dtype=np.int) + param_dict[f"{kernel}_mask"] = nparray(mask, dtype=np.int8) assert npmax(mask) < n dim = Parameters.ndim[kernel]