This week I wrote function bindings for functions in the namespaces sinp
, nneigh
, bond
, primitive
, ring
, tum3
and gen
. I made some commits as well over in pyseams
. I worked a little bit on string representation for users while using the dSEAMS in python, it looks like this but this would be confusing for the users as the representation was <build.cyoda.pointdouble 0x7fbab9a75a30="" at="" object=""> </build.cyoda.pointdouble>which is terrible in lists.
So, we changed it to <pointdouble mem_loc:1eb6b20=""></pointdouble> by using this:
.def("__repr__", [](const molSys::Point<double> &a) {
std::uintptr_t ptr_val = std::uintptr_t(&a);
return fmt::format("<pointdouble mem_loc:="">"</pointdouble>, static_cast<uint>(ptr_val));
.def("__str__", [](const molSys::Point<double> &a) {
return fmt::format(
"x: {} y: {} z: {} type: {} molID: {} atomID: {} inSlice: {}",
a.x,
a.y,
a.z,
a.type,
a.molID,
a.atomID,
a.inSlice);
});</uint>
this looks more clear and specific. It also allows for users to get the memory location fairly easily if needed with aa.pts[0].split(':')[:-1]
.
Since we implemented __str__
as well, by using the following command, they can get more information by calling str() on a PointDouble.
However we might change this to expose a print()
or info
function instead.
Check-in Questions
What did you do this week?
-
python bindings for functions. The following are the commits made in response to that.
What is coming up next?
-
Writing python scripts
- Writing pytests
- More repr and str work
Did you get stuck anywhere?
No, I didn't get stuck anywhere.
-