Skip to content

Commit

Permalink
(RSS) KS2022_randomSolutions code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
amkrajewski committed Feb 12, 2024
1 parent 1a8de5c commit 7b8ae27
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions pysipfenn/descriptorDefinitions/KS2022_randomSolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,30 +427,29 @@ def profile(test: str = 'FCC',
except KeyError:
raise NotImplementedError(f'Unrecognized test name: {test}')

name = f'TestResult_KS2022_randomSolution_{test}_{nIterations}iter.csv'

if nIterations == 1:
d, meta = generate_descriptor(s, comp, plotParameters=plotParameters, returnMeta=True)
print(f"Got meta with :{meta.keys()} keys")
with open(name, 'w+') as f:
f.writelines([f'{v}\n' for v in d])
if returnDescriptorAndMeta:
return d, meta
elif nIterations > 1:
print(f'Running {nIterations} iterations in parallel...')
d = process_map(generate_descriptor,
[s for _ in range(nIterations)],
[comp for _ in range(nIterations)],
chunksize=1,
max_workers=8)
with open(name, 'w+') as f:
f.writelines([f'{",".join([str(v) for v in di])}\n' for di in d])
return None
else:
print('No descriptors generated.')
return None

name = f'TestResult_KS2022_randomSolution_{test}_{nIterations}iter.csv'
if nIterations == 1:
with open(name, 'w+') as f:
f.writelines([f'{v}\n' for v in d])
if returnDescriptorAndMeta:
return d, meta
else:
with open(name, 'w+') as f:
f.writelines([f'{",".join([str(v) for v in di])}\n' for di in d])
return None
print('Done!')


Expand Down

0 comments on commit 7b8ae27

Please sign in to comment.