Skip to content

Commit

Permalink
Fix Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
sivonxay committed Nov 6, 2023
1 parent d636e5a commit 3c191a5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
11 changes: 6 additions & 5 deletions src/NanoParticleTools/analysis/simulation_replayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ def update_state(self, states, row, state_map_species_id):

current_left_state = states[seed][acceptor_i][state_map_species_id[
_interaction['species_id_2']][_interaction['left_state_2']]]
current_right_state = states[seed][acceptor_i][state_map_species_id[
_interaction['species_id_2']][_interaction['right_state_2']]]

current_right_state = states[seed][acceptor_i][
state_map_species_id[_interaction['species_id_2']][
_interaction['right_state_2']]]

if current_left_state == 1 and current_right_state == 0:
states[seed][acceptor_i][state_map_species_id[_interaction[
'species_id_2']][_interaction['left_state_2']]] = 0
Expand All @@ -177,8 +178,8 @@ def update_state(self, states, row, state_map_species_id):
print('current right state', current_right_state)
print(states)
raise RuntimeError('Inconsistent simulation state encountered.'
'Please rerun the simulation. If this issue'
'persists, please raise a github issue')
'Please rerun the simulation. If this issue'
'persists, please raise a github issue')

def save_populations(self, states, seed, time, x, population_evolution,
site_evolution, step_size):
Expand Down
34 changes: 20 additions & 14 deletions src/NanoParticleTools/flows/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint],
all_tables_exist, missing = tables_exist(cur, expected_tables)
if not all_tables_exist:
LOGGER.info(f'Existing run found, but missing {missing} table.'
f'Re-initializing the simulation')
f'Re-initializing the simulation')
fresh_start = True

cur.close()
Expand All @@ -115,7 +115,7 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint],
all_tables_exist, missing = tables_exist(cur, expected_tables)
if not all_tables_exist:
LOGGER.info(f'Existing run found, but missing {missing} table.'
f'Re-initializing the simulation')
f'Re-initializing the simulation')
fresh_start = True
# # Check the number of sites
# num_dopant_site_db = len(list(cur.execute('SELECT * from sites')))
Expand Down Expand Up @@ -144,32 +144,36 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint],

table_exist, _ = tables_exist(cur, ['interupt_state'])
if not table_exist:
LOGGER.info('creating interupt_state and interupt_cutoff table')
LOGGER.info(
'creating interupt_state and interupt_cutoff table')
cur.execute(create_interupt_state_sql)
cur.execute(create_interupt_cutoff_sql)
cur.close()
else:
LOGGER.info(
'Existing run found, but some files are missing. ')
LOGGER.info('Existing run found, but some files are missing. ')
fresh_start = True

if fresh_start or os.path.exists(output_dir) is False:
if override or os.path.exists(output_dir) is False:
LOGGER.info('Writing new input files')
# Generate Nanoparticle
nanoparticle = DopedNanoparticle(constraints, dopant_specifications,
doping_seed, prune_hosts=True)
nanoparticle = DopedNanoparticle(constraints,
dopant_specifications,
doping_seed,
prune_hosts=True)
nanoparticle.generate()

# Initialize Spectral Kinetics class to calculate transition rates
dopants = [
Dopant(key, concentration)
for key, concentration in nanoparticle.dopant_concentrations().items()
Dopant(key, concentration) for key, concentration in
nanoparticle.dopant_concentrations().items()
]
spectral_kinetics = SpectralKinetics(dopants, **spectral_kinetics_args)
spectral_kinetics = SpectralKinetics(dopants,
**spectral_kinetics_args)

# Create an NPMCInput class
npmc_input = NPMCInput(spectral_kinetics, nanoparticle, initial_states)
npmc_input = NPMCInput(spectral_kinetics, nanoparticle,
initial_states)

# Write files
_initial_state_db_args = {
Expand Down Expand Up @@ -226,9 +230,11 @@ def npmc_job(constraints: Sequence[NanoParticleConstraint],
if 'simulation_time' in npmc_args.keys():
for seed, simulation_time in data[0].items():
if simulation_time < npmc_args['simulation_time']:
raise RuntimeError(f'Run did not successfully complete.'
f' Simulation {seed} did not complete. Simulated'
f' {simulation_time} s of {npmc_args["simulation_time"]} s')
raise RuntimeError(
f'Run did not successfully complete.'
f' Simulation {seed} did not complete. Simulated'
f' {simulation_time} s of {npmc_args["simulation_time"]} s'
)

# get population by shell

Expand Down
2 changes: 1 addition & 1 deletion tests/inputs/test_nanoparticle.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_serialization():
dopants = [(0, 0.1, 'Na', 'Y'), (0, 0.2, 'Yb', 'Y')]
dnp = DopedNanoparticle(constraints, dopants)
dnp.generate()

dnp_dict = dnp.as_dict()

dnp_copy = DopedNanoparticle.from_dict(dnp_dict)
Expand Down

0 comments on commit 3c191a5

Please sign in to comment.