Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parser-gulp
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nomad-lab
parser-gulp
Commits
f76ed12b
Commit
f76ed12b
authored
8 years ago
by
Ask Hjorth Larsen
Browse files
Options
Downloads
Patches
Plain Diff
clean up old code
parent
af67ba0f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
parser/parser-gulp/main.py
+0
-90
0 additions, 90 deletions
parser/parser-gulp/main.py
with
0 additions
and
90 deletions
parser/parser-gulp/main.py
+
0
−
90
View file @
f76ed12b
...
...
@@ -110,90 +110,6 @@ time to end of optimisation
"""
def
errprint
(
func
):
def
wrapper
(
backend
,
lines
):
try
:
func
(
backend
,
lines
)
except
Exception
:
print
(
'
Error in %s: %d lines
'
%
(
func
.
__name__
,
len
(
lines
)))
for
line
in
lines
:
print
(
line
,
file
=
sys
.
stderr
)
raise
return
wrapper
def
tokenize
(
lines
):
return
np
.
array
([
line
.
split
()
for
line
in
lines
],
object
)
"""
# XXXX copied from Siesta parser
def ArraySM(header, row, build, stop=r
''
, **kwargs):
class LineBuf:
def __init__(self):
self.lines = []
def addrow(self, parser):
line = parser.fIn.readline()
self.lines.append(line)
def _build_array(self, parser):
build(parser.backend.superBackend, self.lines)
self.lines = []
linebuf = LineBuf()
sm = SM(header,
name=kwargs.pop(
'
name
'
,
'
startarray
'
),
required=True,
subFlags=SM.SubFlags.Sequenced,
subMatchers=[
SM(
'
(%s)
'
% row, name=
'
array
'
, repeats=True,
forwardMatch=True,
adHoc=linebuf.addrow, required=True),
SM(stop, endReStr=
''
, adHoc=linebuf._build_array, name=
'
endarray
'
,
forwardMatch=True)
],
**kwargs)
return sm
"""
"""
def get_frac_coords(backend, lines):
#print(
'
LINES
'
)
positions = []
symbols = []
for line in lines:
tokens = [t for t in line.split() if not t ==
'
*
'
]
sym = tokens[1]
assert tokens[2] ==
'
c
'
pos = [float(x) for x in tokens[3:6]]
assert len(pos) == 3
positions.append(pos)
symbols.append(sym)
positions = np.array(positions)
symbols = np.array(symbols)
backend.addArrayValues(
'
x_gulp_atomic_basis_symbols
'
, symbols)
backend.addArrayValues(
'
x_gulp_atomic_basis_positions
'
, positions)
"""
def
get_array
(
metaname
,
dtype
=
float
,
istart
=
0
,
iend
=
None
,
unit
=
None
,
storage
=
None
):
@errprint
def
buildarray
(
backend
,
lines
):
arr
=
tokenize
(
lines
)
if
iend
is
None
:
arr
=
arr
[:,
istart
:]
else
:
arr
=
arr
[:,
istart
:
iend
]
arr
=
arr
.
astype
(
dtype
)
if
unit
is
not
None
:
arr
=
convert_unit
(
arr
,
unit
)
if
storage
is
not
None
:
storage
[
metaname
]
=
arr
else
:
backend
.
addArrayValues
(
metaname
,
arr
)
return
buildarray
class
GulpContext
(
object
):
def
__init__
(
self
):
self
.
data
=
{}
...
...
@@ -201,11 +117,6 @@ class GulpContext(object):
def
startedParsing
(
self
,
fname
,
parser
):
pass
def
save_array
(
self
,
key
,
dtype
=
float
,
istart
=
0
,
iend
=
None
,
unit
=
None
):
return
get_array
(
key
,
dtype
=
dtype
,
istart
=
istart
,
iend
=
iend
,
unit
=
unit
,
storage
=
self
.
data
)
def
onClose_section_system
(
self
,
backend
,
gindex
,
section
):
data
=
self
.
data
print
(
list
(
data
.
keys
()))
...
...
@@ -319,7 +230,6 @@ class GulpContext(object):
allgroups
.
append
(
thislinegroups
)
def
savearray
(
parser
):
print
(
'
SAVE
'
,
name
)
arr
=
np
.
array
(
allgroups
,
dtype
=
object
)
del
allgroups
[:]
if
name
in
self
.
data
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment