The LAMMPS library has a python interface that I am trying to use in Julia via PyCall. One of the things that can be obtained is a pointer to an array for the positions of the atoms. Within Python, I could call:
X = numpy.ctypeslib.as_array(lmp.extract_atom("x",3).contents,shape=(natoms,3))
and I would have a numpy array wrapped around the underlying data. In Julia, I can successfully call
xptr= lmp[:extract_atom]("x",3)
which gives a structure of type
PyObject <lammps.LP_LP_c_double object at 0x11e4a1f28>
and I can index the elements as xptr[1][2]
. But is there a way to wrap a structure around this so that I can treat this as an array within Julia which can be manipulated in the “standard” way? In other wrods, is there an analog of numpy.ctypeslib.as_array
?