raysect / source

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

SpectralPowerPipeline2D cannot be unpickled #411

Closed seidlj closed 1 year ago

seidlj commented 1 year ago

Hello,

when I try to unpickle raysect.optical.observer.SpectralPowerPipeline2D object, it raises

File ~/.local/lib/python3.10/site-packages/raysect/optical/observer/pipeline/spectral/power.pyx:390, 
in raysect.optical.observer.pipeline.spectral.power.SpectralPowerPipeline2D.__setstate__()

TypeError: Expected tuple, got int

I've discussed that with @Mateasek, who thinks that this is caused by incompatibility of the __getstate__ and __setstate__ methods of that class. The following code raises the same error:

from raysect.optical.observer import SpectralPowerPipeline2D

pipeline = SpectralPowerPipeline2D()
pipeline.__setstate__(pipeline.__getstate__())

Raysect version: 0.8.0

Mateasek commented 1 year ago

Hi @seidlj , the problem is wrong typing here: self._pixels = 0

I think the fix could be changing it to : self._pixels = None

CnlPepper commented 1 year ago

Fixed in development branch (v0.8.1).