Skip to content

Commit

Permalink
Merge branch 'master' into migrate_to_furo
Browse files Browse the repository at this point in the history
  • Loading branch information
DomFijan authored Oct 3, 2023
2 parents 050e6b8 + bcf7f07 commit a9d6bf6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
The format is based on `Keep a Changelog <http://keepachangelog.com/en/1.0.0/>`__.
This project adheres to `Semantic Versioning <http://semver.org/spec/v2.0.0.html>`__.

v0.x.x - 20xx-xx-xx

Added
~~~~~

- New `edge_lengths` method.

v0.7.0 - 2023-09-18
-------------------

Expand Down
2 changes: 1 addition & 1 deletion Credits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Jen Bradley
* Added shape families for Archimedean, Catalan, and Johnson solids.
* Added shape family for prisms and antiprisms.
* Added shape family for equilateral pyramids and dipyramids.
* Added edges, edge_vectors, and num_edges methods.
* Added edges, edge_vectors, edge_lengths, and num_edges methods.

Domagoj Fijan

Expand Down
13 changes: 12 additions & 1 deletion coxeter/shapes/polyhedron.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,20 @@ def edges(self):

@property
def edge_vectors(self):
""":class:`numpy.ndarray`: Get the polyhedron's edges as vectors."""
""":class:`numpy.ndarray`: Get the polyhedron's edges as vectors.
:code:`edge_vectors` are returned in the same order as in :attr:`edges`.
"""
return self.vertices[self.edges[:, 1]] - self.vertices[self.edges[:, 0]]

@property
def edge_lengths(self):
""":class:`numpy.ndarray`: Get the length of each edge of the polyhedron.
:code:`edge_lengths` are returned in the same order as in :attr:`edges`.
"""
return np.linalg.norm(self.edge_vectors, axis=1)

@property
def num_edges(self):
"""int: Get the number of edges."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_polyhedron.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def test_edge_lengths():
poly.vertices[poly.edges[:, 1]] - poly.vertices[poly.edges[:, 0]], axis=1
)
assert np.allclose(veclens, edgelength)
assert np.allclose(poly.edge_lengths, edgelength)
assert np.allclose(veclens, np.linalg.norm(poly.edge_vectors, axis=1))


Expand Down

0 comments on commit a9d6bf6

Please sign in to comment.