Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Cythonizes GROParser & GROReader very minimally #2227

Closed
wants to merge 9 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cython_gro_reader
fenilsuchak authored and richardjgowers committed Jun 21, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1669bbc5060b9b298b0eb9bc81b6fbef3bed8e81
Original file line number Diff line number Diff line change
@@ -116,6 +116,10 @@
from ..core import flags
from ..exceptions import NoDataError
from ..lib import util
cimport cython
@cython.boundscheck(False) # Deactivate bounds checking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these decorators aren't doing what you are expecting here, they won't apply to the whole file. I think they're probably just modifying the Timestep object.

You probably need to decorate the class method directly

@cython.wraparound(False)



class Timestep(base.Timestep):
@@ -167,11 +171,17 @@ class GROReader(base.SingleFrameReaderBase):
.. versionchanged:: 0.11.0
Frames now 0-based instead of 1-based
"""
format = 'GRO'
units = {'time': None, 'length': 'nm', 'velocity': 'nm/ps'}
_Timestep = Timestep

def _read_first_frame(self):
cdef str format = 'GRO'
cpdef dict units = {'time': None, 'length': 'nm', 'velocity': 'nm/ps'}
cdef int n_atoms
cdef str first_atomline
cdef int cs
cdef float[:,:] velocities
cdef int pos
cdef str line
cdef float unitcell
with util.openany(self.filename, 'rt') as grofile:
# Read first two lines to get number of atoms
grofile.readline()
7 changes: 6 additions & 1 deletion package/setup.py
Original file line number Diff line number Diff line change
@@ -335,6 +335,11 @@ def extensions(config):
include_dirs = include_dirs + ['MDAnalysis/topology/include'],
define_macros = define_macros,
extra_compile_args= extra_compile_args)
groreader = MDAExtension('MDAnalysis.coordinates.GRO',
['MDAnalysis/coordinates/GRO' + source_suffix],
include_dirs = include_dirs + ['MDAnalysis/coordinates/include'],
define_macros = define_macros,
extra_compile_args= extra_compile_args)
distances = MDAExtension('MDAnalysis.lib.c_distances',
['MDAnalysis/lib/c_distances' + source_suffix],
include_dirs=include_dirs + ['MDAnalysis/lib/include'],
@@ -421,7 +426,7 @@ def extensions(config):
extra_link_args= cpp_extra_link_args)
pre_exts = [libdcd, distances, distances_omp, qcprot,
transformation, libmdaxdr, util, encore_utils,
ap_clustering, spe_dimred, cutil, augment, nsgrid, groparser]
ap_clustering, spe_dimred, cutil, augment, nsgrid, groparser, groreader]


cython_generated = []