week 8: More python binding for functions

ruhi
Published: 07/17/2023

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?

  1. python bindings for functions. The following are the commits made in response to that.

    1. commit 1.
    2. commit 2.
    3. commit 3.
    4. commit 4.
    5. commit 5.
    6. commit 6.
    7. commit 7.

    What is coming up next?

    1. Writing python scripts

    2. Writing pytests
    3. More repr and str work

    Did you get stuck anywhere?

    No, I didn't get stuck anywhere.

DJDT

Versions

Time

Settings from gsoc.settings

Headers

Request

SQL queries from 1 connection

Static files (2312 found, 3 used)

Templates (11 rendered)

Cache calls from 1 backend

Signals

Log messages