Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bjmorgan/vasppy
Browse files Browse the repository at this point in the history
  • Loading branch information
bjmorgan committed May 5, 2019
2 parents bd78ae9 + cc2d144 commit d23b8d2
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy
numpy>=1.16.2
monty
pandas
pymatgen
Expand Down
13 changes: 13 additions & 0 deletions tests/test_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def setUp( self, mock_parse_vaspun, MockVASPMeta ):
self.summary = Summary()
self.summary.vasprun = Mock( spec=Vasprun )
self.summary.meta = Mock( spec=VASPMeta )
self.summary.meta.notes = None

def test_functional_not_PBE( self ):
self.summary.potcars_are_pbe = Mock( return_value=False )
Expand Down Expand Up @@ -169,6 +170,17 @@ def test_print_title( self, mock_stdout ):
self.summary.print_title()
self.assertEqual( mock_stdout.getvalue(), 'title: TITLE\n' )

@patch('sys.stdout', new_callable=StringIO)
def test_print_notes( self, mock_stdout ):
self.summary.meta.notes = 'NOTES'
self.summary.print_notes()
self.assertEqual( mock_stdout.getvalue(), 'notes: NOTES\n' )

@patch('sys.stdout', new_callable=StringIO)
def test_print_notes_handles_empty_notes_attribute( self, mock_stdout ):
self.summary.print_notes()
self.assertEqual( mock_stdout.getvalue(), 'notes: ~\n' )

class SummaryHelperFunctionsTestCase( unittest.TestCase ):

def test_md5sum( self ):
Expand Down Expand Up @@ -209,5 +221,6 @@ def test_load_vasp_summary( self ):
vasp_summary = load_vasp_summary( vasp_summary_test_filename )
self.assertEqual( vasp_summary, expected_dict )


if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion vasppy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.4.0.9'
__version__ = '0.4.0.11'
2 changes: 1 addition & 1 deletion vasppy/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def import_calculations_from_file( filename ):
"""
calcs = {}
with open( filename, 'r' ) as stream:
docs = yaml.load_all( stream )
docs = yaml.load_all( stream, Loader=yaml.SafeLoader )
for d in docs:
stoichiometry = Counter()
for s in d['stoichiometry']:
Expand Down
4 changes: 2 additions & 2 deletions vasppy/data/potcar_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

for potcar_set in potcar_sets:
with open( '{}_md5.yaml'.format( os.path.join( my_path, potcar_set ) ), 'r' ) as stream:
potcar_md5sum_data[ potcar_set ] = yaml.load( stream )
potcar_md5sum_data[ potcar_set ] = yaml.load( stream, Loader=yaml.SafeLoader )

for potcar_set in potcar_sets:
with open( '{}_nelect.yaml'.format( os.path.join( my_path, potcar_set ) ), 'r' ) as stream:
potcar_nelect[ potcar_set ] = yaml.load( stream )
potcar_nelect[ potcar_set ] = yaml.load( stream, Loader=yaml.SafeLoader )
2 changes: 1 addition & 1 deletion vasppy/scripts/vasp_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def main():
sys.exit()
if args.file:
with open( args.file, 'r' ) as stream:
settings = yaml.load( stream )
settings = yaml.load( stream, Loader=yaml.SafeLoader )
if 'to_print' in settings:
to_print = settings['to_print']
if 'titles' in settings:
Expand Down
7 changes: 5 additions & 2 deletions vasppy/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def load_vasp_summary( filename ):
"""
with open( filename, 'r' ) as stream:
docs = yaml.load_all( stream )
docs = yaml.load_all( stream, Loader=yaml.SafeLoader )
data = { d['title']: d for d in docs }
return data

Expand Down Expand Up @@ -256,7 +256,10 @@ def print_description( self ):
print( "description: {}".format( self.meta.description.strip() ) )

def print_notes( self ):
print( "notes: {}".format( self.meta.notes.strip() ) )
if self.meta.notes:
print( "notes: {}".format( self.meta.notes.strip() ) )
else:
print( "notes: ~" )

def print_status( self ):
print( "status: {}".format( self.meta.status ) )
Expand Down
2 changes: 1 addition & 1 deletion vasppy/vaspmeta.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def from_file( cls, filename ):
(vasppy.VASPMeta): the VASPMeta object
"""
with open( filename, 'r' ) as stream:
data = yaml.load( stream )
data = yaml.load( stream, Loader=yaml.SafeLoader )
notes = data.get( 'notes' )
v_type = data.get( 'type' )
track = data.get( 'track' )
Expand Down

0 comments on commit d23b8d2

Please sign in to comment.