Skip to content

Commit

Permalink
fixed none pep8 error
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerfick committed Feb 2, 2018
1 parent a7fef98 commit 9b1f407
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dmipy/core/modeling_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def parameter_initial_guess_to_parameter_vector(self, **parameters):
print("All model parameters set.")
else:
for parameter, card in parameter_cardinality.items():
set_parameters[parameter] = np.tile(None, card)
set_parameters[parameter] = np.tile(np.nan, card)
return self.parameters_to_parameter_vector(**set_parameters)

def _prepare_parameters(self):
Expand Down Expand Up @@ -633,13 +633,13 @@ def fit(self, acquisition_scheme, data, parameter_initial_guess=None,

# make starting parameters and data the same size
if parameter_initial_guess is None:
x0_ = np.tile(None,
x0_ = np.tile(np.nan,
np.r_[data_.shape[:-1], N_parameters])
else:
x0_ = homogenize_x0_to_data(
data_, parameter_initial_guess)
x0_bool = np.all(
x0_ == None, axis=tuple(np.arange(x0_.ndim - 1)))
np.isnan(x0_), axis=tuple(np.arange(x0_.ndim - 1)))
x0_[..., ~x0_bool] /= self.scales_for_optimization[~x0_bool]

if use_parallel_processing and not have_pathos:
Expand Down
16 changes: 8 additions & 8 deletions dmipy/optimizers/brute2fine.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, model, acquisition_scheme,

if x0_vector is None:
self.global_optimization_grid = True
x0_vector = np.tile(None, len(model.bounds_for_optimization))
x0_vector = np.tile(np.nan, len(model.bounds_for_optimization))
self.precompute_signal_grid(model, x0_vector, Ns, N_sphere_samples)
elif x0_vector.squeeze().ndim == 1:
self.global_optimization_grid = True
Expand Down Expand Up @@ -103,22 +103,22 @@ def precompute_signal_grid(self, model, x0_vector, Ns, N_sphere_samples):
for name, card in parameter_cardinality_items:
par_range = model.parameter_ranges[name]
if card == 1:
if x0_vector[counter] is None:
if np.isnan(x0_vector[counter]):
per_parameter_vectors.append(np.linspace(
par_range[0], par_range[1], Ns) *
model.parameter_scales[name])
else:
per_parameter_vectors.append([x0_vector[counter]])
counter += 1
if card == 2:
if x0_vector[counter] is None:
if np.isnan(x0_vector[counter]):
per_parameter_vectors.append(
mu[:, card_counter] *
model.parameter_scales[name][0])
else:
per_parameter_vectors.append(
[x0_vector[counter + card_counter]])
per_parameter_vectors.append([None])
per_parameter_vectors.append(np.nan)
counter += 2
# append nested volume fractions now.
if N_model_fracts > 0:
Expand Down Expand Up @@ -278,13 +278,13 @@ def __call__(self, data, x0_vector):
bounds_brute = []
bounds_fine = list(bounds)
for i, x0_ in enumerate(x0_vector):
if x0_ is None:
if np.isnan(x0_):
bounds_brute.append(
slice(bounds[i][0], bounds[i][1],
(bounds[i][1] - bounds[i][0]) / float(self.Ns)))
if x0_ is not None:
if not np.isnan(x0_):
bounds_brute.append(slice(x0_, x0_ + 1e-2, None))
if (x0_ is not None and
if (not np.isnan(x0_) and
self.model.opt_params_for_optimization[i] is False):
bounds_fine[i] = np.r_[x0_, x0_]

Expand All @@ -293,7 +293,7 @@ def __call__(self, data, x0_vector):
bounds_fine = bounds_fine[:-1]
x0_vector = x0_vector[:-1]

if np.any(x0_vector == None):
if np.any(np.isnan(x0_vector)):
x0_brute = brute(
self.objective_function, ranges=bounds_brute, args=fit_args,
finish=None)
Expand Down

0 comments on commit 9b1f407

Please sign in to comment.