raysect / source

The main source repository for the Raysect project.
http://www.raysect.org
BSD 3-Clause "New" or "Revised" License
89 stars 23 forks source link

"Custom volume emitters" example broken #429

Closed MaxHerbs closed 9 months ago

MaxHerbs commented 9 months ago

Hello Currently it seems the "Custom Volume Emitter" sample does not work. Is there an alternative way to define custom light sources?

I'm using Raysect Version: raysect-0.8.1.post1

and the code fails with the following output:

Rendering pass 1... Traceback (most recent call last): File "Untitled-1.py", line 50, in camera.observe() File "raysect/optical/observer/base/observer.pyx", line 265, in raysect.optical.observer.base.observer._ObserverBase.observe File "raysect/optical/observer/base/observer.pyx", line 301, in raysect.optical.observer.base.observer._ObserverBase.observe File "/home/max/.local/lib/python3.8/site-packages/raysect/core/workflow.py", line 239, in run raise results AttributeError: attribute 'samples' of 'raysect.optical.spectrum.Spectrum' objects is not writable

A copy of the code is available from the raysect repository, and the error occurs with no changes made to the example. Thank you

vsnever commented 9 months ago

Hi @MaxHerbs, the issue is fixed already in the development branch. Just replace line 23 of the demo:

        spectrum.samples += cos((shift + 5) * radius)**4

with

        spectrum.samples[:] += cos((shift + 5) * radius)**4
MaxHerbs commented 9 months ago

Hi @vsnever, Thank you for the quick response, that's perfect