Reduce verbosity when reading tpr files.
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
# cython: c_string_type=unicode, c_string_encoding=utf8
|
# cython: c_string_type=unicode, c_string_encoding=utf8
|
||||||
# Cython wrapper around tpxio.cpp
|
# Cython wrapper around tpxio.cpp
|
||||||
|
|
||||||
# from cython cimport view
|
from libc cimport stdio
|
||||||
# from array import array
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
cimport numpy as np
|
cimport numpy as np
|
||||||
|
|
||||||
@ -88,6 +88,21 @@ cdef atom_charge(t_atom atom):
|
|||||||
cdef atom_mass(t_atom atom):
|
cdef atom_mass(t_atom atom):
|
||||||
return atom.m
|
return atom.m
|
||||||
|
|
||||||
|
|
||||||
|
cdef open_tpx(const char* filename, t_inputrec *ir, matrix box, int *natoms, gmx_mtop_t *top):
|
||||||
|
#cdef stdio.FILE *old_stderr = stdio.stderr
|
||||||
|
#stdio.stderr = stdio.freopen('tmp', 'w', stdio.stderr)
|
||||||
|
cdef char buffer[stdio.BUFSIZ]
|
||||||
|
stdio.setbuf(stdio.stderr, buffer)
|
||||||
|
return_code = read_tpx(filename, ir, box, natoms, NULL, NULL, NULL, top)
|
||||||
|
|
||||||
|
for i in range(stdio.BUFSIZ):
|
||||||
|
buffer[i] = 0
|
||||||
|
stdio.fflush(stdio.stderr)
|
||||||
|
stdio.fseek(stdio.stderr, 0, stdio.SEEK_END)
|
||||||
|
stdio.setbuf(stdio.stderr, NULL)
|
||||||
|
return return_code
|
||||||
|
|
||||||
cdef class TPXReader:
|
cdef class TPXReader:
|
||||||
cdef:
|
cdef:
|
||||||
t_tpxheader header
|
t_tpxheader header
|
||||||
@ -181,16 +196,11 @@ cdef class TPXReader:
|
|||||||
# cdef np.ndarray[real, ndim=2] coordinates = np.empty((self.n_atoms, 3), dtype=np.float32)
|
# cdef np.ndarray[real, ndim=2] coordinates = np.empty((self.n_atoms, 3), dtype=np.float32)
|
||||||
# cdef np.ndarray[real, ndim=2] velocites = np.empty((self.n_atoms, 3), dtype=np.float32)
|
# cdef np.ndarray[real, ndim=2] velocites = np.empty((self.n_atoms, 3), dtype=np.float32)
|
||||||
# cdef np.ndarray[real, ndim=2] forces = np.empty((self.n_atoms, 3), dtype=np.float32)
|
# cdef np.ndarray[real, ndim=2] forces = np.empty((self.n_atoms, 3), dtype=np.float32)
|
||||||
|
open_tpx(
|
||||||
return_code = read_tpx(
|
|
||||||
<char *>filename,
|
<char *>filename,
|
||||||
&self.input_record,
|
&self.input_record,
|
||||||
self.box,
|
self.box,
|
||||||
&self.n_atoms,
|
&self.n_atoms,
|
||||||
NULL, NULL, NULL,
|
|
||||||
# <rvec *>coordinates.data,
|
|
||||||
# <rvec *>velocites.data,
|
|
||||||
# <rvec *>forces.data,
|
|
||||||
&self.topology
|
&self.topology
|
||||||
)
|
)
|
||||||
self.topology_name = self.topology.name[0]
|
self.topology_name = self.topology.name[0]
|
||||||
|
Reference in New Issue
Block a user