Skip to content

making use of pypact reading for density#9

Merged
jbae11 merged 2 commits intojbae11:mainfrom
shimwell:adding-pypact-reading-for-density
May 25, 2025
Merged

making use of pypact reading for density#9
jbae11 merged 2 commits intojbae11:mainfrom
shimwell:adding-pypact-reading-for-density

Conversation

@shimwell
Copy link
Collaborator

Recently I added the ability for pypact to read the density keyword from a fispact input file
fispact/pypact#59

we can now make use of this in the script and save some lines of code

this code block

def read_density(filepath):
     lines = open(filepath).readlines()
     for line in lines:
         spl = line.strip().split()
         if 'DENSITY' in line:
             assert('DENSITY' == spl[0])
             return float(spl[1])
     raise ValueError('Density not found')

can be replaced by this

def read_density(filepath):
     ff = pp.InputData()
     pp.from_file(ff, filepath)
     return ff._density

@jbae11 jbae11 merged commit 63ae099 into jbae11:main May 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants