raysect / source

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

Should SpectralFunction be a Function1D? #262

Closed mattngc closed 5 years ago

mattngc commented 5 years ago

At the moment spectral function is a standalone class, but to me it looks like it should inherit from Function1D. Then it should follow the normal pattern of call() and cpdef evaluate() in the reset of the framework. In fact a lot of the attributes and functions on this class appear to be supporting higher level functional operations, such as integration and sampling the function over a range. I would argue a lot of this could be consolidated into the function framework.

Perhaps the big disadvantages of this change would be the amount of work to support all this machinery in 2D and 3D functions.

CnlPepper commented 5 years ago

i've already considered this on multiple occasions. There are a few API issues to solve - notably how to handle the self sampling. Easier to explain this in person. This would be an API breaking change.

mattngc commented 5 years ago

Discussed this with @CnlPepper, sounds like this is deceptively complicated. Will leave it for a later refactor. But I suggest as a minumum, SpectralFunction should mirror the Function1D interface where possible. i.e. there should be a cdef evaluate() method.