Skip to content

Commit e637dbf

Browse files
np.nan initialization
1 parent 12ab4ab commit e637dbf

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/WarrenCowleyParameters/__init__.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ def calculate_warren_cowley_parameters(self):
127127

128128
ntypes = len(unique_types)
129129
nshells = len(self.nneigh) - 1
130-
wc_for_shells = np.empty((nshells, ntypes, ntypes))
131-
wc_per_particles_for_shells = np.empty((nparticles, nshells, ntypes * ntypes))
130+
wc_for_shells = np.full((nshells, ntypes, ntypes), np.nan)
131+
wc_per_particles_for_shells = np.full(
132+
(nparticles, nshells, ntypes * ntypes), np.nan
133+
)
132134

133135
# Calculate Warren-Cowley parameters for each shell
134136
for m in range(nshells):
@@ -183,10 +185,11 @@ def _create_central_atom_type_mask(self, unique_types, particle_types):
183185
def _compute_per_particle_wc_params(
184186
self, shell_types, central_atom_mask, concentrations, unique_types
185187
):
186-
wc_params_per_particle = np.empty(
187-
(central_atom_mask.shape[1], len(concentrations) * len(concentrations))
188+
wc_params_per_particle = np.full(
189+
(central_atom_mask.shape[1], len(concentrations) * len(concentrations)),
190+
np.nan,
188191
)
189-
wc_params = np.empty((len(concentrations), len(concentrations)))
192+
wc_params = np.full((len(concentrations), len(concentrations)), np.nan)
190193

191194
# Number of neighbor in shell
192195
Nb = shell_types.shape[1]
@@ -210,7 +213,7 @@ def _compute_per_particle_wc_params(
210213
wc = 1 - pij / concentrations
211214

212215
# Store WC
213-
wc_params[i, :] = np.mean(wc, axis=0)
216+
wc_params[i, :] = np.nanmean(wc, axis=0)
214217
wc_params_per_particle[
215218
central_atoms, i * len(concentrations) : (i + 1) * len(concentrations)
216219
] = wc
@@ -220,7 +223,7 @@ def _compute_per_particle_wc_params(
220223
def _compute_wc_params(
221224
self, shell_types, central_atom_mask, concentrations, unique_types
222225
):
223-
wc_params = np.empty((len(concentrations), len(concentrations)))
226+
wc_params = np.full((len(concentrations), len(concentrations)), np.nan)
224227

225228
Nb = shell_types.shape[1] # Number of neighbor in shell
226229

0 commit comments

Comments
 (0)