Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ea72675
add reverse method like `__radd__`, `__rmul__`, etc.
Jul 27, 2023
4095c99
fix inconsistent indentation
Jul 28, 2023
2d1a680
fix binary arithmetic operators in `math` module
Jul 28, 2023
e9800f3
add `noexcept` to `_edge_compare` function
Jul 28, 2023
245faf7
add ignoring `numpy` deplicated warning
Aug 2, 2023
b993ac6
change to return from raise
Jul 27, 2023
7a12a04
update cython version constraint in pyproject.toml
munechika-koyo Nov 27, 2024
80a6f5f
fix: replace `DEF` statements with `cdef enum`, `cdef const` and use …
munechika-koyo Jul 18, 2025
4bf12d8
refactor: remove redundant DEF constants for R_2_PI and R_4_PI
munechika-koyo Jul 18, 2025
a87eb2d
refactor: remove unused constants and clean up docstring formatting
munechika-koyo Jul 18, 2025
1ad5da5
chore: update cython version constraint to 3.1 in pyproject.toml
munechika-koyo Jul 18, 2025
fb31ca6
Merge remote-tracking branch 'munechika/cython_v3_support' into featu…
CnlPepper Jul 19, 2025
d91e083
Update cython version.
CnlPepper Jul 19, 2025
1df6f31
Update cython version.
CnlPepper Jul 19, 2025
1696d1f
Revised various segments of the code to both modernise it and support…
CnlPepper Jul 20, 2025
e4804b0
Revised various segments of the code to both modernise it and support…
CnlPepper Jul 20, 2025
2359eff
Revised various segments of the code to both modernise it and support…
CnlPepper Jul 20, 2025
e6a3c02
Add python 3.13 to the test matrix.
CnlPepper Jul 20, 2025
3bc16d2
Removed random text that was accidentally added to .gitignore.
CnlPepper Jul 20, 2025
ce4bff9
Renamed all instances of the word "targetted" with "targeted" to fix …
CnlPepper Jul 20, 2025
a5a571b
Merge branch 'refs/heads/development' into feature/cython3
CnlPepper Jul 22, 2025
3d1ee34
Regenerated meson.build files using new generator.
CnlPepper Jul 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
numpy-version: ["numpy"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -21,7 +21,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: python -m pip install --prefer-binary meson-python meson ninja setuptools "cython>=0.28,<3.0" "matplotlib>=3,<4" ${{ matrix.numpy-version }}
run: python -m pip install --prefer-binary meson-python meson ninja setuptools "cython>=3.1" "matplotlib>=3,<4" ${{ matrix.numpy-version }}
- name: Build and install Raysect
run: dev/install_editable.sh
- name: Run tests
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Build changes:
- Meson-python performs the build out of the project folder, so the project source folders will no longer be polluted with build artefacts.
- Cython build annotations are now always enabled, the annotation files can be found in the build folder under the build artefacts folder associated with each so file (*.so.p folder).

API changes:
* Corrected spelling of all classes, methods and functions where "targeted" was incorrectly spelt "targetted".


Release 0.8.1 (12 Feb 2023)
---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import matplotlib.pyplot as plt
from math import atan2, sqrt, degrees

from raysect.core.math import Point3D, TargettedHemisphereSampler, TargettedSphereSampler
from raysect.core.math import Point3D, TargetedHemisphereSampler, TargetedSphereSampler


def display_samples(samples, title):
Expand Down Expand Up @@ -34,8 +34,8 @@ def display_samples(samples, title):
observation_point = Point3D(0, 0, 0)

# generate samplers
hemisphere = TargettedHemisphereSampler(targets)
sphere = TargettedSphereSampler(targets)
hemisphere = TargetedHemisphereSampler(targets)
sphere = TargetedSphereSampler(targets)

# sample for origin point and point at (0, 0, -10)
h_samples = hemisphere(observation_point, samples=samples)
Expand Down
8 changes: 4 additions & 4 deletions demos/observers/cornell_box_cooke_triplet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from raysect.optical import World, Node, translate, rotate, Point3D
from raysect.optical.material import Lambert, UniformSurfaceEmitter, AbsorbingSurface, Checkerboard
from raysect.optical.library import *
from raysect.optical.observer import TargettedCCDArray
from raysect.optical.observer import TargetedCCDArray
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, PowerPipeline2D
from raysect.optical.observer import RGBAdaptiveSampler2D
from raysect.core.math import mm
Expand Down Expand Up @@ -184,9 +184,9 @@
rgb = RGBPipeline2D(display_unsaturated_fraction=0.96, name="sRGB")
sampler = RGBAdaptiveSampler2D(rgb, ratio=10, fraction=0.2, min_samples=1000, cutoff=0.01)

# CCD targetting all rays at last lens element for speed
ccd = TargettedCCDArray(
targetted_path_prob=1.0, targets=[l3],
# CCD targeting all rays at last lens element for speed
ccd = TargetedCCDArray(
targeted_path_prob=1.0, targets=[l3],
width=mm(35), pixels=(512, 512),
parent=image_plane, transform=translate(0, 0, 0)*rotate(0, 0, 180),
pipelines=[rgb]
Expand Down
4 changes: 2 additions & 2 deletions demos/observers/cornell_box_real_pinhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from raysect.optical import World, Node, translate, rotate, Point3D
from raysect.optical.material import Lambert, UniformSurfaceEmitter, NullMaterial
from raysect.optical.library import *
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, PowerPipeline2D, TargettedCCDArray
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, PowerPipeline2D, TargetedCCDArray
from raysect.optical.observer import RGBAdaptiveSampler2D


Expand Down Expand Up @@ -144,7 +144,7 @@

camera = Node(parent=world, transform=translate(0, 0, -3.3))
pinhole = Sphere(0.0005, camera, transform=translate(0, 0, 0), material=NullMaterial())
film = TargettedCCDArray(targetted_path_prob=1.0, targets=[pinhole], width=0.1, pixels=(512, 512), parent=camera,
film = TargetedCCDArray(targeted_path_prob=1.0, targets=[pinhole], width=0.1, pixels=(512, 512), parent=camera,
transform=translate(0, 0, -0.1207), pipelines=pipelines)
film.frame_sampler = sampler
film.pixel_samples = 250
Expand Down
4 changes: 2 additions & 2 deletions demos/observers/metal_with_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from raysect.optical.library.metal import Gold, Silver, Copper, Titanium, Aluminium, Beryllium
from raysect.optical.material import Lambert, UniformSurfaceEmitter, AbsorbingSurface, NullMaterial
from raysect.optical.library import schott
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, TargettedCCDArray, CCDArray, RGBAdaptiveSampler2D
from raysect.optical.observer import RGBPipeline2D, BayerPipeline2D, TargetedCCDArray, CCDArray, RGBAdaptiveSampler2D
from raysect.optical.colour import ciexyz_x, ciexyz_y, ciexyz_z


Expand Down Expand Up @@ -49,7 +49,7 @@
pipelines = [rgb, bayer]

# ccd = CCDArray(parent=camera, pipelines=pipelines)
ccd = TargettedCCDArray(targets=[aperture], parent=camera, pipelines=pipelines)
ccd = TargetedCCDArray(targets=[aperture], parent=camera, pipelines=pipelines)
ccd.frame_sampler = sampler
ccd.pixels = (180*2, 120*2) # (360, 240)
ccd.pixel_samples = 250
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from raysect.primitive import Box
from raysect.optical import World, translate, Point3D, Node
from raysect.optical.observer import Pixel, TargettedPixel, PowerPipeline0D
from raysect.optical.observer import Pixel, TargetedPixel, PowerPipeline0D
from raysect.optical.material import UnitySurfaceEmitter


Expand All @@ -28,16 +28,16 @@
basic_pipeline = PowerPipeline0D(name="Basic Pixel Observer")
basic_pixel = Pixel(parent=world, pixel_samples=SAMPLES, pipelines=[basic_pipeline])

# setup targetted pixel
targetted_pipeline = PowerPipeline0D(name="Targeted Pixel Observer")
targetted_pixel = TargettedPixel(parent=world, targets=targets, pixel_samples=SAMPLES, pipelines=[targetted_pipeline])
targetted_pixel.targetted_path_prob = 1
# setup targeted pixel
targeted_pipeline = PowerPipeline0D(name="Targeted Pixel Observer")
targeted_pixel = TargetedPixel(parent=world, targets=targets, pixel_samples=SAMPLES, pipelines=[targeted_pipeline])
targeted_pixel.targeted_path_prob = 1

# render
ion()
basic_pixel.observe()
print()
targetted_pixel.observe()
targeted_pixel.observe()

ioff()
show()
10 changes: 5 additions & 5 deletions demos/optics/etendue_of_pinhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.pyplot as plt

from raysect.core import Point3D, Vector3D, rotate_basis, translate, Ray as CoreRay
from raysect.core.math.sampler import DiskSampler3D, RectangleSampler3D, TargettedHemisphereSampler
from raysect.core.math.sampler import DiskSampler3D, RectangleSampler3D, TargetedHemisphereSampler
from raysect.optical import World
from raysect.primitive import Box, Cylinder, Subtract
from raysect.optical.material import AbsorbingSurface, NullMaterial
Expand Down Expand Up @@ -35,8 +35,8 @@ def raytraced_etendue(distance, detector_radius=0.001, ray_count=100000, batches
sphere = target.bounding_sphere()
spheres = [(sphere.centre.transform(detector_transform), sphere.radius, 1.0)]

# instance targetted pixel sampler
targetted_sampler = TargettedHemisphereSampler(spheres)
# instance targeted pixel sampler
targeted_sampler = TargetedHemisphereSampler(spheres)

point_sampler = DiskSampler3D(detector_radius)

Expand All @@ -53,8 +53,8 @@ def raytraced_etendue(distance, detector_radius=0.001, ray_count=100000, batches
passed = 0.0
for origin in origins:

# obtain targetted vector sample
direction, pdf = targetted_sampler(origin, pdf=True)
# obtain targeted vector sample
direction, pdf = targeted_sampler(origin, pdf=True)
path_weight = R_2_PI * direction.z/pdf

origin = origin.transform(detector_transform)
Expand Down
3 changes: 2 additions & 1 deletion dev/root-meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ py = import('python').find_installation(pure: false)
numpy = dependency('numpy', method: 'config-tool')
fs = import('fs')

cython_args = ['--annotate']
# disabling explicit noexcept until pycharm fixes their cython 3 support (causes a large number of build warnings)
cython_args = ['--annotate', '-X legacy_implicit_noexcept=True']
cython_dependencies = [numpy]
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ py = import('python').find_installation(pure: false)
numpy = dependency('numpy', method: 'config-tool')
fs = import('fs')

cython_args = ['--annotate']
# disabling explicit noexcept until pycharm fixes their cython 3 support (causes a large number of build warnings)
cython_args = ['--annotate', '-X legacy_implicit_noexcept=True']
cython_dependencies = [numpy]

subdir('raysect')
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Issues = "https://github.com/raysect/source/issues"
Changelog = "https://github.com/raysect/source/blob/master/CHANGELOG.txt"

[build-system]
requires = ["meson-python", "setuptools", "wheel", "numpy", "cython<3.0"]
requires = ["meson-python", "setuptools", "wheel", "numpy", "cython>=3.1"]
build-backend = "mesonpy"
3 changes: 1 addition & 2 deletions raysect/core/acceleration/accelerator.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ from raysect.core.ray cimport Ray
from raysect.core.math cimport Point3D
from raysect.core.intersection cimport Intersection


cdef class Accelerator:

cpdef build(self, list primitives)

cpdef Intersection hit(self, Ray ray)

cpdef list contains(self, Point3D point)
3 changes: 0 additions & 3 deletions raysect/core/acceleration/accelerator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@
cdef class Accelerator:

cpdef build(self, list primitives):

pass

cpdef Intersection hit(self, Ray ray):

raise NotImplementedError("Accelerator virtual method hit() has not been implemented.")

cpdef list contains(self, Point3D point):

raise NotImplementedError("Accelerator virtual method contains() has not been implemented.")
9 changes: 4 additions & 5 deletions raysect/core/acceleration/boundprimitive.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ from raysect.core.intersection cimport Intersection

cdef class BoundPrimitive:

cdef readonly Primitive primitive
cdef readonly BoundingBox3D box
cdef bint _primitive_tested
cdef:
readonly Primitive primitive
readonly BoundingBox3D box
bint _primitive_tested

cdef Intersection hit(self, Ray ray)

cdef Intersection next_intersection(self)

cdef bint contains(self, Point3D point)
3 changes: 3 additions & 0 deletions raysect/core/acceleration/kdtree.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ from raysect.core.acceleration.accelerator cimport Accelerator as _Accelerator
from raysect.core.math.spatial.kdtree3d cimport KDTree3DCore as _KDTreeCore
from raysect.core.intersection cimport Intersection


cdef class _PrimitiveKDTree(_KDTreeCore):

cdef:
list primitives
Intersection hit_intersection


cdef class KDTree(_Accelerator):

cdef _PrimitiveKDTree _kdtree

1 change: 0 additions & 1 deletion raysect/core/acceleration/kdtree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ cdef class _PrimitiveKDTree(_KDTreeCore):
# dereference the primitives and check if they contain the point
enclosing_primitives = []
for item in range(count):

index = self._nodes[id].items[item]
primitive = <BoundPrimitive> self.primitives[index]
if primitive.contains(point):
Expand Down
5 changes: 3 additions & 2 deletions raysect/core/acceleration/unaccelerated.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ from raysect.core.boundingbox cimport BoundingBox3D

cdef class Unaccelerated(Accelerator):

cdef list primitives
cdef BoundingBox3D world_box
cdef:
list primitives
BoundingBox3D world_box
13 changes: 2 additions & 11 deletions raysect/core/acceleration/unaccelerated.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ from raysect.core.math cimport Point3D
from raysect.core.intersection cimport Intersection
from raysect.core.acceleration.boundprimitive cimport BoundPrimitive


cdef class Unaccelerated(Accelerator):

def __init__(self):
Expand All @@ -54,7 +55,6 @@ cdef class Unaccelerated(Accelerator):
self.world_box = BoundingBox3D()

for primitive in primitives:

accel_primitive = BoundPrimitive(primitive)
self.primitives.append(accel_primitive)
self.world_box.union(accel_primitive.box)
Expand All @@ -70,23 +70,17 @@ cdef class Unaccelerated(Accelerator):

# does the ray intersect the space containing the primitives
if not self.world_box.hit(ray):

return None

# find the closest primitive-ray intersection
closest_intersection = None

# intial search distance is maximum possible ray extent
# initial search distance is maximum possible ray extent
distance = ray.max_distance

for primitive in self.primitives:

intersection = primitive.hit(ray)

if intersection is not None:

if intersection.ray_distance < distance:

distance = intersection.ray_distance
closest_intersection = intersection

Expand All @@ -101,15 +95,12 @@ cdef class Unaccelerated(Accelerator):
BoundPrimitive primitive

if not self.world_box.contains(point):

return []

enclosing_primitives = []

for primitive in self.primitives:

if primitive.contains(point):

enclosing_primitives.append(primitive.primitive)

return enclosing_primitives
25 changes: 0 additions & 25 deletions raysect/core/boundingbox.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,21 @@ cdef class BoundingBox3D:
cdef Point3D upper

cdef Point3D get_centre(self)

cpdef bint hit(self, Ray ray)

cpdef tuple full_intersection(self, Ray ray)

cdef bint intersect(self, Ray ray, double *front_intersection, double *back_intersection)

cdef void _slab(self, double origin, double direction, double lower, double upper, double *front_intersection, double *back_intersection) nogil

cpdef bint contains(self, Point3D point)

cpdef object union(self, BoundingBox3D box)

cpdef object extend(self, Point3D point, double padding=*)

cpdef double surface_area(self)

cpdef double volume(self)

cpdef list vertices(self)

cpdef double extent(self, int axis) except -1

cpdef int largest_axis(self)

cpdef double largest_extent(self)

cpdef object pad(self, double padding)

cpdef object pad_axis(self, int axis, double padding)

cpdef BoundingSphere3D enclosing_sphere(self)


Expand All @@ -95,23 +79,14 @@ cdef class BoundingBox2D:
cdef Point2D upper

cpdef bint contains(self, Point2D point)

cpdef object union(self, BoundingBox2D box)

cpdef object extend(self, Point2D point, double padding=*)

cpdef double surface_area(self)

cpdef list vertices(self)

cpdef double extent(self, int axis) except -1

cpdef int largest_axis(self)

cpdef double largest_extent(self)

cpdef object pad(self, double padding)

cpdef object pad_axis(self, int axis, double padding)


Expand Down
Loading