Closed oeolartep closed 3 years ago
The problem is that when the optical path calculation function is called, a comparison between a Ray and a NoneType object is raised (at least once), but this comparison is not implemented at the __eq__
method.
A workaround for this problem is to modify the __eq__
method (at ray.pyx) like this:
def __eq__(self, other):
if isinstance(other, Ray):
return np.array_equal(self.pos, other.pos) and\
np.array_equal(self.dir, other.dir) and\
self.intensity == other.intensity and\
self.wavelength == other.wavelength and\
self.n == other.n and\
self.label == other.label and\
self.order == other.order and\
self.orig_surf == other.orig_surf
else:
return NotImplemented
Original implementation:
def __eq__(self, other):
return np.array_equal(self.pos, other.pos) and\
np.array_equal(self.dir, other.dir) and\
self.intensity == other.intensity and\
self.wavelength == other.wavelength and\
self.n == other.n and\
self.label == other.label and\
self.order == other.order and\
self.orig_surf == other.orig_surf
The solution proposed may wirk, but the real problem was that the method optical path parent had a line:
if self.parent != None:
and it should be:
if self.parent is not None:
I already corrected it in my own fork, and will merge to master later today.
Will close the issue after the merge.
Solved
This error message pops up when running the first example of the section optical maps at the Tutorial.1 notebook:
Way to reproduce
Version information
Python 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0] Linux-4.19.0-9-amd64-x86_64-with-debian-10.4 cython version: 0.16.2 pyoptools version: 1.18.2