66from . import _core
77
88
9- __all__ = ['parse_nnkp ' ]
9+ __all__ = ['parse_nnkp_raw ' ]
1010
1111
1212patterns = {
@@ -38,13 +38,12 @@ def parse_lattice(string: str) -> dict:
3838 match = patterns ['lattice_vectors' ].search (string )
3939
4040 if match is not None :
41- v1 = np . fromstring ( match .group ('v1' ), sep = ' ' )
42- v2 = np . fromstring ( match .group ('v2' ), sep = ' ' )
43- v3 = np . fromstring ( match .group ('v3' ), sep = ' ' )
41+ v1 = [ float ( x ) for x in match .group ('v1' ). split ()]
42+ v2 = [ float ( x ) for x in match .group ('v2' ). split ()]
43+ v3 = [ float ( x ) for x in match .group ('v3' ). split ()]
4444
4545 return {
4646 'v1' : v1 , 'v2' : v2 , 'v3' : v3 ,
47- 'lattice_vectors' : np .array ([v1 , v2 , v3 ]),
4847 }
4948 else :
5049 return None
@@ -55,7 +54,6 @@ def parse_direct_lattice(string: str) -> dict:
5554
5655 return {
5756 'a1' : lattice ['v1' ], 'a2' : lattice ['v2' ], 'a3' : lattice ['v3' ],
58- 'lattice_vectors' : lattice ['lattice_vectors' ]
5957 }
6058
6159
@@ -64,15 +62,16 @@ def parse_reciprocal_lattice(string: str) -> dict:
6462
6563 return {
6664 'b1' : lattice ['v1' ], 'b2' : lattice ['v2' ], 'b3' : lattice ['v3' ],
67- 'lattice_vectors' : lattice ['lattice_vectors' ]
6865 }
6966
7067
7168def parse_kpoints (string : str ) -> dict :
7269 match = patterns ['kpoints' ].search (string )
7370
7471 return {
75- 'kpoints' : np .fromstring (match .group ('kpoints' ), sep = '\n ' ).reshape ((len (match .group ('kpoints' ).splitlines ()), - 1 ))[:, :3 ]
72+ 'kpoints' : [
73+ [float (x ) for x in line .split ()] for line in match .group ('kpoints' ).splitlines ()
74+ ]
7675 }
7776
7877
@@ -119,19 +118,17 @@ def parse_spinor_projections(string: str) -> dict:
119118def parse_exclude_bands (string : str ) -> dict :
120119 match = patterns ['exclude_bands' ].search (string )
121120
122- exclude_bands = np .fromstring (match .group ('exclude_bands' ), sep = '\n ' , dtype = int )
123-
124- if exclude_bands .size > 0 :
121+ if match is not None :
125122 return {
126- 'exclude_bands' : exclude_bands
123+ 'exclude_bands' : [ int ( line ) for line in match . group ( ' exclude_bands' ). splitlines ()]
127124 }
128125 else :
129126 return {
130127 'exclude_bands' : None
131128 }
132129
133130
134- def parse_nnkp (string : str ) -> dict :
131+ def parse_nnkp_raw (string : str ) -> dict :
135132 """
136133 Parse NNKP
137134
0 commit comments