Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new classes to return the edges of polyhedra (#171)
* test: Fix assumption on quaternions. Only test quaternions that are not effectively zero. * Added new classes to return the edges of polyhedra The new class ``polyhedron.edges`` returns the a list of the edges of a polyhedron as vertex-index pairs, similar to the current ``polyhedron.faces`` class. The class ``polyhedron.get_edge_vectors`` returns a list of edges as vectors in 3D space. * Fixed return for get_edge_vectors method. * Renamed get_edge_vectors property to edge_vectors Co-authored-by: Vyas Ramasubramani <[email protected]> * Vectorized edge_vectors return with numpy Co-authored-by: Vyas Ramasubramani <[email protected]> * Updated test_polyhedron to be compatible with the renamed edge_vectors property * Updated test_polyhedron to explicitly cover the edges property * Updated rtol for edge property test Until the precision improvements in #177 are added, a decrease in rtol and the merge_faces call are required for pytest to succeed on the dodecahedron's edges. Once the precision is increased, these temporary solutions can be reverted * Reverted small fixes that account for inaccuracies in polyhedron stored data Currently, the stored data for polyhedra is not accurate enough for the ``edges`` and ``edge_vectors`` properties to function as expected. Once #177 is merged, the accuracy increase should fix the issue and assertion tolerances for testing can be tightened. In addition, ``merge_faces`` should no longer be required for any of the polyhedra included with this package. * Removed unnecessary comment from ``test_edges`` * Changed ``edge_vectors`` property to return a numpy array Co-authored-by: Bradley Dice <[email protected]> * Rewrote ``edges`` method and updated ``edge_vectors`` for compatibility After discussing possible options for returning polyhedral edges, it was determined that a set of i<j pairs of vertices was the best option for output in the ``edges`` method. A description of how to generate (j,i) pairs was added to the docstring, and the edge_vectors method was updated to work with the new set/tuple structure. * Updated ``test_polyhedron`` to work with set edges * Fixed docstring formatting for ``edges`` and ``edge_vectors`` * Updated edges method to return Numpy array It was determined that edges should be returned as an ordered Numpy array. This commit ensures the final output is a numpy array, sorted first by the (i) element and then by the (j) element where i<j. This mimics Mathematica's edges output format and should aid in usability. Documentation was updated accordingly. * test_polyhedron::test_edges now checks edge count * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Updated edges property to cache result * Updated edges and edge_vectors to make better use of numpy functions and functools caching * Added num_edges method * Updated credits * Updated test_polyhedron to test num_edges property * Updated edges documentation Co-authored-by: Bradley Dice <[email protected]> * Updated edge_vectors documentation Co-authored-by: Bradley Dice <[email protected]> * Refactored test_edges to be more comprehensive Added explicit tests for sorting, double checks for edge length, and an additional test for the number of edges based on the euler characteristic * Added fast num_edges calculation for convex polyhedron and improved pytests * test_num_edges now covers nonconvex Polyhedron class * Update Credits.rst Co-authored-by: Bradley Dice <[email protected]> * Test i-i edges Co-authored-by: Bradley Dice <[email protected]> * Removed changes to .gitignore --------- Co-authored-by: Brandon Butler <[email protected]> Co-authored-by: Vyas Ramasubramani <[email protected]> Co-authored-by: Bradley Dice <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information