Skip to content

Commit b4b746f

Browse files
committed
Added noexcept flags to core package functions and methods.
1 parent 3a1f49f commit b4b746f

73 files changed

Lines changed: 390 additions & 392 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dev/notes/building_a_release.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ then a matrix of builds is performed.
2020
Move the sdist and wheels to a common folder and upload to pypi with twine. Twine needs an API key.
2121
Upload to the test repository first and confirm everything works as expected:
2222

23-
twine upload --repository testpypi wheelhouse/
23+
twine upload --repository testpypi wheelhouse/*
2424

2525
If happy, upload to the main pypi repository:
2626

27-
twine upload wheelhouse/
27+
twine upload wheelhouse/*
2828

2929

3030

raysect/core/acceleration/accelerator.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ from raysect.core.intersection cimport Intersection
3636

3737
cdef class Accelerator:
3838

39-
cpdef build(self, list primitives)
39+
cpdef object build(self, list primitives)
4040
cpdef Intersection hit(self, Ray ray)
4141
cpdef list contains(self, Point3D point)

raysect/core/acceleration/accelerator.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
cdef class Accelerator:
3333

34-
cpdef build(self, list primitives):
34+
cpdef object build(self, list primitives):
3535
pass
3636

3737
cpdef Intersection hit(self, Ray ray):

raysect/core/acceleration/boundprimitive.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ cdef class BoundPrimitive:
4444

4545
cdef Intersection hit(self, Ray ray)
4646
cdef Intersection next_intersection(self)
47-
cdef bint contains(self, Point3D point)
47+
cdef bint contains(self, Point3D point) noexcept

raysect/core/acceleration/boundprimitive.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cdef class BoundPrimitive:
5959
return self.primitive.next_intersection()
6060
return None
6161

62-
cdef bint contains(self, Point3D point):
62+
cdef bint contains(self, Point3D point) noexcept:
6363

6464
if self.box.contains(point):
6565
return self.primitive.contains(point)

raysect/core/acceleration/kdtree.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ cdef class _PrimitiveKDTree(_KDTreeCore):
7070

7171
@cython.boundscheck(False)
7272
@cython.wraparound(False)
73-
cdef bint _trace_leaf(self, int32_t id, Ray ray, double max_range):
73+
cdef bint _trace_leaf(self, int32_t id, Ray ray, double max_range) noexcept:
7474
"""
7575
Tests each item in the kd-Tree leaf node to identify if an intersection occurs.
7676
@@ -164,7 +164,7 @@ cdef class _PrimitiveKDTree(_KDTreeCore):
164164

165165
cdef class KDTree(_Accelerator):
166166

167-
cpdef build(self, list primitives):
167+
cpdef object build(self, list primitives):
168168
self._kdtree = _PrimitiveKDTree(primitives)
169169

170170
cpdef Intersection hit(self, Ray ray):

raysect/core/acceleration/unaccelerated.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cdef class Unaccelerated(Accelerator):
4545
self.primitives = []
4646
self.world_box = BoundingBox3D()
4747

48-
cpdef build(self, list primitives):
48+
cpdef object build(self, list primitives):
4949

5050
cdef:
5151
Primitive primitive

raysect/core/boundingbox.pxd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ cdef class BoundingBox3D:
4040
cdef Point3D upper
4141

4242
cdef Point3D get_centre(self)
43-
cpdef bint hit(self, Ray ray)
43+
cpdef bint hit(self, Ray ray) noexcept
4444
cpdef tuple full_intersection(self, Ray ray)
45-
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection)
46-
cdef void _slab(self, double origin, double direction, double lower, double upper, double *front_intersection, double *back_intersection) nogil
47-
cpdef bint contains(self, Point3D point)
45+
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection) noexcept
46+
cdef void _slab(self, double origin, double direction, double lower, double upper, double *front_intersection, double *back_intersection) noexcept nogil
47+
cpdef bint contains(self, Point3D point) noexcept
4848
cpdef object union(self, BoundingBox3D box)
4949
cpdef object extend(self, Point3D point, double padding=*)
50-
cpdef double surface_area(self)
51-
cpdef double volume(self)
50+
cpdef double surface_area(self) noexcept
51+
cpdef double volume(self) noexcept
5252
cpdef list vertices(self)
5353
cpdef double extent(self, int axis) except -1
54-
cpdef int largest_axis(self)
55-
cpdef double largest_extent(self)
54+
cpdef int largest_axis(self) noexcept
55+
cpdef double largest_extent(self) noexcept
5656
cpdef object pad(self, double padding)
5757
cpdef object pad_axis(self, int axis, double padding)
5858
cpdef BoundingSphere3D enclosing_sphere(self)
@@ -78,14 +78,14 @@ cdef class BoundingBox2D:
7878
cdef Point2D lower
7979
cdef Point2D upper
8080

81-
cpdef bint contains(self, Point2D point)
81+
cpdef bint contains(self, Point2D point) noexcept
8282
cpdef object union(self, BoundingBox2D box)
8383
cpdef object extend(self, Point2D point, double padding=*)
84-
cpdef double surface_area(self)
84+
cpdef double surface_area(self) noexcept
8585
cpdef list vertices(self)
8686
cpdef double extent(self, int axis) except -1
87-
cpdef int largest_axis(self)
88-
cpdef double largest_extent(self)
87+
cpdef int largest_axis(self) noexcept
88+
cpdef double largest_extent(self) noexcept
8989
cpdef object pad(self, double padding)
9090
cpdef object pad_axis(self, int axis, double padding)
9191

raysect/core/boundingbox.pyx

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3030
# POSSIBILITY OF SUCH DAMAGE.
3131

32-
# TODO: add docstrings
33-
3432
cimport cython
3533
from libc.math cimport INFINITY
3634
from raysect.core.math cimport new_point3d, new_point2d
@@ -143,7 +141,7 @@ cdef class BoundingBox3D:
143141
0.5 * (self.lower.z + self.upper.z)
144142
)
145143

146-
cpdef bint hit(self, Ray ray):
144+
cpdef bint hit(self, Ray ray) noexcept:
147145
"""
148146
Returns true if the ray hits the bounding box.
149147
@@ -177,7 +175,7 @@ cdef class BoundingBox3D:
177175

178176
return hit, front_intersection, back_intersection
179177

180-
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection):
178+
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection) noexcept:
181179

182180
# set initial ray-slab intersection search range
183181
front_intersection[0] = -INFINITY
@@ -198,7 +196,7 @@ cdef class BoundingBox3D:
198196
return True
199197

200198
@cython.cdivision(True)
201-
cdef void _slab(self, double origin, double direction, double lower, double upper, double *front_intersection, double *back_intersection) nogil:
199+
cdef void _slab(self, double origin, double direction, double lower, double upper, double *front_intersection, double *back_intersection) noexcept nogil:
202200

203201
cdef double reciprocal, tmin, tmax
204202

@@ -244,7 +242,7 @@ cdef class BoundingBox3D:
244242
if tmax < back_intersection[0]:
245243
back_intersection[0] = tmax
246244

247-
cpdef bint contains(self, Point3D point):
245+
cpdef bint contains(self, Point3D point) noexcept:
248246
"""
249247
Returns true if the given 3D point lies inside the bounding box.
250248
@@ -299,7 +297,7 @@ cdef class BoundingBox3D:
299297
self.upper.y = max(self.upper.y, point.y + padding)
300298
self.upper.z = max(self.upper.z, point.z + padding)
301299

302-
cpdef double surface_area(self):
300+
cpdef double surface_area(self) noexcept:
303301
"""
304302
Returns the surface area of the bounding box.
305303
@@ -314,7 +312,7 @@ cdef class BoundingBox3D:
314312

315313
return 2 * (dx * dy + dx * dz + dy * dz)
316314

317-
cpdef double volume(self):
315+
cpdef double volume(self) noexcept:
318316
"""
319317
Returns the volume of the bounding box.
320318
@@ -359,7 +357,7 @@ cdef class BoundingBox3D:
359357
else:
360358
raise ValueError("Axis must be in the range [0, 2].")
361359

362-
cpdef int largest_axis(self):
360+
cpdef int largest_axis(self) noexcept:
363361
"""
364362
Find the largest axis of this bounding box.
365363
@@ -386,7 +384,7 @@ cdef class BoundingBox3D:
386384

387385
return largest_axis
388386

389-
cpdef double largest_extent(self):
387+
cpdef double largest_extent(self) noexcept:
390388
"""
391389
Find the largest spatial extent across all axes.
392390
@@ -478,7 +476,6 @@ cdef class BoundingBox2D:
478476
self.upper = upper
479477

480478
def __repr__(self):
481-
482479
return "BoundingBox2D({}, {})".format(self.lower, self.upper)
483480

484481
def __getstate__(self):
@@ -517,7 +514,7 @@ cdef class BoundingBox2D:
517514
def upper(self, Point2D value not None):
518515
self.upper = value
519516

520-
cpdef bint contains(self, Point2D point):
517+
cpdef bint contains(self, Point2D point) noexcept:
521518
"""
522519
Returns true if the given 2D point lies inside the bounding box.
523520
@@ -562,7 +559,7 @@ cdef class BoundingBox2D:
562559
self.upper.x = max(self.upper.x, point.x + padding)
563560
self.upper.y = max(self.upper.y, point.y + padding)
564561

565-
cpdef double surface_area(self):
562+
cpdef double surface_area(self) noexcept:
566563
"""
567564
Returns the surface area of the bounding box.
568565
@@ -598,7 +595,7 @@ cdef class BoundingBox2D:
598595
else:
599596
raise ValueError("Axis must be in the range [0, 1].")
600597

601-
cpdef int largest_axis(self):
598+
cpdef int largest_axis(self) noexcept:
602599
"""
603600
Find the largest axis of this bounding box.
604601
@@ -619,7 +616,7 @@ cdef class BoundingBox2D:
619616

620617
return largest_axis
621618

622-
cpdef double largest_extent(self):
619+
cpdef double largest_extent(self) noexcept:
623620
"""
624621
Find the largest spatial extent across all axes.
625622

raysect/core/boundingsphere.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ cdef class BoundingSphere3D:
3838
double radius
3939
Point3D centre
4040

41-
cpdef bint hit(self, Ray ray)
41+
cpdef bint hit(self, Ray ray) noexcept
4242
cpdef tuple full_intersection(self, Ray ray)
43-
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection)
44-
cpdef bint contains(self, Point3D point)
43+
cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection) noexcept
44+
cpdef bint contains(self, Point3D point) noexcept
4545
cpdef object union(self, BoundingSphere3D sphere)
4646
cpdef object extend(self, Point3D point, double padding=*)
47-
cpdef double surface_area(self)
48-
cpdef double volume(self)
47+
cpdef double surface_area(self) noexcept
48+
cpdef double volume(self) noexcept
4949
cpdef object pad(self, double padding)

0 commit comments

Comments
 (0)