Rename split() to _split() and make new split() function with known return type

This commit is contained in:
jan 2021-02-13 16:48:28 -08:00
commit b791d3c854

View file

@ -1,4 +1,5 @@
import numpy
from typing import Tuple, Union
import numpy # type: ignore
from . import poly_t, plane_t
from .util import build_empty, _get_map
@ -9,7 +10,7 @@ def clip(poly: poly_t, plane: plane_t) -> poly_t:
Clip a polyhedron with a plane, keeping only the part which is on
the same side as the plane's normal vector.
This function is equivalent to calling split(poly, plane, same_only=True).
This function is equivalent to calling _split(poly, plane, same_only=True).
Args:
poly: Polyhedron to clip, in chiral Schlegel representation.
@ -18,11 +19,26 @@ def clip(poly: poly_t, plane: plane_t) -> poly_t:
Returns:
Clipped polyhedron.
'''
left_poly = split(poly, plane, same_only=True)
left_poly = _split(poly, plane, same_only=True)
return left_poly
def split(poly: poly_t, plane: plane_t, same_only: bool = False) -> Tuple[poly_t, poly_t]:
def split(poly: poly_t, plane: plane_t) -> Tuple[poly_t, poly_t]:
'''
Clip a polyhedron with a plane, keeping both parts.
This function is equivalent to calling _split(poly, plane, same_only=False).
Args:
poly: Polyhedron to clip, in chiral Schlegel representation.
plane: Plane to clip against.
Returns:
same_side_poly, other_side_poly
The first polyhedron is on from the same side as the plane's normal vector.
'''
def _split(poly: poly_t, plane: plane_t, same_only: bool = False):
'''
Clip a polyhedron with a plane.