def test_incar_parser_invalid_tag(): """Test passing a tag that is not recognized and its override. """ test_string = '''SOMEINVALIDTAG = .TRUE.''' parsed = Incar(incar_string=test_string, validate_tags=False) incar_dict = parsed.get_dict() assert list(incar_dict.keys())[0] == 'someinvalidtag'
def test_incar_parser_from_string(): """Test passing a string. """ test_str = 'LOPTICS = .True.\nAddgrid=.false.' incar_io = Incar(incar_string=test_str) incar_dict = incar_io.get_dict() assert incar_dict.pop('loptics') is True assert incar_dict.pop('addgrid') is False assert not incar_dict
def test_from_string(): """Test passing a string. """ test_str = 'TRUE = .True.\nFalse=.false.' incar_io = Incar(incar_string=test_str) incar_dict = incar_io.get_dict() assert incar_dict.pop('true') is True assert incar_dict.pop('false') is False assert not incar_dict
def test_incar_from_dict(incar_dict): """Test passing a dictionary. """ incar_io = Incar(incar_dict=incar_dict) comp_dict = { 'encut': 350, 'sigma': 0.05, 'lreal': False, 'prec': 'Accurate' } assert str(sorted(incar_io.get_dict())) == str(sorted(comp_dict))
def _parse_file(self, inputs): """Create a DB Node from an INCAR file.""" result = inputs result = {} if isinstance(self._data_obj, get_data_class('dict')): return {'incar': self._data_obj} try: incar = Incar(file_path=self._data_obj.path, logger=self._logger) except SystemExit: self._logger.warning('Parsevasp exitited abnormally. Returning None.') return {'incar': None} result['incar'] = incar.get_dict() return result
def test_incar_parser_from_string_complexr(): """Test passing a more complex string. """ test_string = '''LOPTICS = .True. EVENONLY = .False. # this is a comment; FLOAT\t=\t1.45e-03 ISMEAR = THIS ; SIGMA = THAT NBANDS = 45 # endline comment; may contain '#' and ';' NOPARAM = this is not a parameter DIPOL = 1 2 -33 5 ''' parsed = Incar(incar_string=test_string) incar_dict = parsed.get_dict() assert incar_dict['loptics'] is True assert incar_dict['evenonly'] is False assert incar_dict['ismear'] == 'THIS' assert incar_dict['sigma'] == 'THAT' assert incar_dict['dipol'] == [1, 2, -33, 5] assert incar_dict['nbands'] == 45 assert 'noparam' not in incar_dict assert 'float' not in incar_dict
def test_parser(): """Test passing a more complex string. """ test_string = '''TRUE = .True. FALSE=.False. # this is a comment; FLOAT\t=\t1.45e-03 SOMEOTHERTHING = THIS ; ANDTHAT = .TRUE. INT = 45 # endline comment; may contain '#' and ';' NOPARAM = this is not a parameter LIST = 1 2 -33 5 ''' parsed = Incar(incar_string=test_string) incar_dict = parsed.get_dict() assert incar_dict['true'] is True assert incar_dict['false'] is False assert incar_dict['someotherthing'] == 'THIS' assert incar_dict['andthat'] is True assert incar_dict['list'] == [1, 2, -33, 5] assert incar_dict['int'] == 45 assert 'noparam' not in incar_dict assert 'float' not in incar_dict