Skip to content

Commit

Permalink
Flake8 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlarson1 committed Oct 30, 2019
1 parent b791c18 commit c81ad46
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions libensemble/gen_funcs/aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ def advance_local_run(H, user_specs, c_flag, run, persis_info):
advance_local_run.pt_in_run = 0

if user_specs['localopt_method'] in ['LN_SBPLX', 'LN_BOBYQA',
'LN_COBYLA', 'LN_NELDERMEAD',
'LD_MMA']:
'LN_COBYLA', 'LN_NELDERMEAD',
'LD_MMA']:

if user_specs['localopt_method'] in ['LD_MMA']:
fields_to_pass = ['x_on_cube', 'f', 'grad']
Expand Down Expand Up @@ -900,7 +900,7 @@ def initialize_APOSMM(H, gen_specs):

if 'single_component_at_a_time' in user_specs and user_specs['single_component_at_a_time']:
assert user_specs['batch_mode'], ("Must be in batch mode when using "
"'single_component_at_a_time'")
"'single_component_at_a_time'")
c_flag = True
else:
c_flag = False
Expand Down
4 changes: 2 additions & 2 deletions libensemble/gen_funcs/persistent_aposmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def aposmm(H, persis_info, gen_specs, libE_info):
if user_specs['localopt_method'] in ['LD_MMA', 'blmvm']:
fields_to_pass = ['x_on_cube', 'f', 'grad']
elif user_specs['localopt_method'] in ['LN_SBPLX', 'LN_BOBYQA', 'LN_COBYLA',
'LN_NELDERMEAD', 'scipy_Nelder-Mead']:
'LN_NELDERMEAD', 'scipy_Nelder-Mead']:
fields_to_pass = ['x_on_cube', 'f']
elif user_specs['localopt_method'] in ['pounders']:
fields_to_pass = ['x_on_cube', 'fvec']
Expand Down Expand Up @@ -386,7 +386,7 @@ def nlopt_callback_fun(x, grad, comm_queue, child_can_read, parent_can_read, use
grad[:] = grad_recv
else:
assert user_specs['localopt_method'] in ['LN_SBPLX', 'LN_BOBYQA',
'LN_COBYLA', 'LN_NELDERMEAD', 'LD_MMA']
'LN_COBYLA', 'LN_NELDERMEAD', 'LD_MMA']
x_recv, f_recv = comm_queue.get()

assert np.array_equal(x, x_recv), "The point I gave is not the point I got back!"
Expand Down
7 changes: 4 additions & 3 deletions libensemble/libE.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
allowed_gen_spec_keys = ['gen_f', 'in', 'out', 'save_every_k', 'user']
allowed_alloc_spec_keys = ['alloc_f', 'in', 'out', 'user']


def report_manager_exception(hist, persis_info, mgr_exc=None):
"Write out exception manager exception to log."
if mgr_exc is not None:
Expand Down Expand Up @@ -481,7 +482,7 @@ def check_alloc_specs(alloc_specs):
assert alloc_specs['alloc_f'], "Allocation function must be specified"

for k in alloc_specs.keys():
assert k in allowed_alloc_spec_keys, "Key %s is not allowed in alloc_specs. Supported keys are: %s " % (k,allowed_alloc_spec_keys)
assert k in allowed_alloc_spec_keys, "Key %s is not allowed in alloc_specs. Supported keys are: %s " % (k, allowed_alloc_spec_keys)


def check_sim_specs(sim_specs):
Expand All @@ -493,15 +494,15 @@ def check_sim_specs(sim_specs):
assert isinstance(sim_specs['in'], list), "'in' field must exist and be a list of field names"

for k in sim_specs.keys():
assert k in allowed_sim_spec_keys, "Key %s is not allowed in sim_specs. Supported keys are: %s " % (k,allowed_sim_spec_keys)
assert k in allowed_sim_spec_keys, "Key %s is not allowed in sim_specs. Supported keys are: %s " % (k, allowed_sim_spec_keys)


def check_gen_specs(gen_specs):
assert isinstance(gen_specs, dict), "gen_specs must be a dictionary"
assert not bool(gen_specs) or len(gen_specs['out']), "gen_specs must have 'out' entries"

for k in gen_specs.keys():
assert k in allowed_gen_spec_keys, "Key %s is not allowed in gen_specs. Supported keys are: %s " % (k,allowed_gen_spec_keys)
assert k in allowed_gen_spec_keys, "Key %s is not allowed in gen_specs. Supported keys are: %s " % (k, allowed_gen_spec_keys)


def check_exit_criteria(exit_criteria, sim_specs, gen_specs):
Expand Down
2 changes: 1 addition & 1 deletion libensemble/tests/regression_tests/test_1d_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'user': {'gen_batch_size': 500,
'lb': np.array([-3]),
'ub': np.array([3]),
}
}
}

persis_info = per_worker_stream({}, nworkers + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'user': {'lb': np.array([-3]),
'ub': np.array([3]),
'gen_batch_size': 500
}
}
}

persis_info = per_worker_stream({}, nworkers + 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
'num_active_gens': 1,
'dist_to_bound_multiple': 0.5,
'localopt_maxeval': 4
}
}
}
}

alloc_specs = {'alloc_f': alloc_f, 'out': gen_out}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
'save_every_k': 300, # Tell libE to save every 300 gen entries
'user': {'gen_batch_size': 500, # Tell gen_f how much to generate per call
'lb': np.array([-3, -2]), # Tell gen_f lower bounds
'ub': np.array([3, 2]), # Tell gen_f upper bounds
}
'ub': np.array([3, 2]) # Tell gen_f upper bounds
}
}
# end_gen_specs_rst_tag

Expand Down
4 changes: 2 additions & 2 deletions libensemble/tests/unit_tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ def make_criteria_and_specs_0(simx=10, n=1):

def make_criteria_and_specs_1(simx=10):
sim_specs = {'sim_f': np.linalg.norm, 'in': ['x'], 'out': [('g', float)], }
gen_specs = {'gen_f': np.random.uniform, 'in': [], 'out': [('x', float), ('priority', float)], 'user': {} }
gen_specs = {'gen_f': np.random.uniform, 'in': [], 'out': [('x', float), ('priority', float)], 'user': {}}
exit_criteria = {'sim_max': simx, 'stop_val': ('g', -1), 'elapsed_wallclock_time': 0.5}

return sim_specs, gen_specs, exit_criteria


def make_criteria_and_specs_1A(simx=10):
sim_specs = {'sim_f': np.linalg.norm, 'in': ['x'], 'out': [('g', float)], }
gen_specs = {'gen_f': np.random.uniform, 'in': [], 'out': [('x', float), ('priority', float), ('sim_id', int)], 'user': {} }
gen_specs = {'gen_f': np.random.uniform, 'in': [], 'out': [('x', float), ('priority', float), ('sim_id', int)], 'user': {}}
exit_criteria = {'sim_max': simx, 'stop_val': ('g', -1), 'elapsed_wallclock_time': 0.5}

return sim_specs, gen_specs, exit_criteria
Expand Down

0 comments on commit c81ad46

Please sign in to comment.