Skip to content

Commit

Permalink
Fix to_hoomd for convex polygons (#245)
Browse files Browse the repository at this point in the history
* Fix to_hoomd for convex polygons

* Fix test for polygon::to_hoomd

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix support for python 3.9

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
janbridley and pre-commit-ci[bot] authored Oct 30, 2024
1 parent 0c8c32f commit 723ebd6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions coxeter/shapes/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ def to_hoomd(self):
self.centroid = np.array([0, 0, 0])
data = self.to_json(["vertices", "centroid", "area", "inertia_tensor"])
hoomd_dict = _map_dict_keys(data, key_mapping=_hoomd_dict_mapping)
hoomd_dict = {**hoomd_dict, **{"vertices": self.vertices[:, :2]}}
hoomd_dict["sweep_radius"] = 0.0

self.centroid = old_centroid
Expand Down
2 changes: 1 addition & 1 deletion tests/test_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def test_to_hoomd(points):
poly.centroid = [0, 0, 0]
dict_keys = ["vertices", "centroid", "sweep_radius", "area", "moment_inertia"]
dict_vals = [
poly.vertices,
poly.vertices[:, :2],
[0, 0, 0],
0,
poly.area,
Expand Down

0 comments on commit 723ebd6

Please sign in to comment.