Document and test loss function signatures
A loss function is a significant part of the interface of each learner. It provides the users with nearly infinite ways to customize the learner's behavior, and it is also the main way for the users to do so.
As a consequence I believe we need to do the following:
- Each learner that allows a custom loss function must specify the detailed call signature of this function in the docstring.
- We should test whether a learner provides a correct input to the loss function. For example if we say that
Learner2D
passes an interpolation instance to the loss, we should try and runLearner2D
with the loss that verifies that its input is indeed an instance of interpolation. We did not realize this, butloss
is a part of the learner's public API. - All loss functions that we provide should instead be factory functions that return a loss function whose call signature conforms to the spec. For example
learner2D.resolution_loss(ip, min_distance=0, max_distance=1)
does not conform to the spec, and is not directly reusable. Instead this should have been afunctools.partial(learner2D.resolution_loss, min_distance=0, max_distance=1)
. - We should convert all our loss functions that have arbitrary hard-coded parameters into such factory functions, and we should test their conformance to the spec.