User-defined functions used in feature specifications can cause models to throw undesirable exceptions.
A version of Semantics that can morph into other instances of the same structure but with a different type parameter.
A version of Semantics that can morph into other instances of the same structure but with a different type parameter.
An example:
case class X[A]() extends MorphableSemantics[X, A] { // ... def morph[B: RefInfo]: Option[X[B]] = Some(X[B]()) }
Notice for class X
, that the M
type constructor is X
and the A
is the same for
the second type parameter of MorphableSemantics as for the type parameter in Semantics.
This can be use like the following:
import com.eharmony.aloha.reflect.RefInfo val xF = X[Float] val riD = implicitly[RefInfo[Double]] val xDo: Option[X[Double]] = xF.morph[Double] val xDo1: Option[X[Double]] = xF.morph(riD)
or use it generically:
def morph[M[_] <: Semantics[_], A, B: RefInfo](m: MorphableSemantics[M, A]): Option[Semantics[B]] = { m.morph[B] } val sDO: Option[Semantics[Double]] = morph(xF)
a type constructor providing the structure of the Semantics. This will most likely always be the concrete subclass of Semantics that implements MorphableSemantics.
the type parameter to which M
is applied for this instance of Semantics,
also the type parameter for the Semantics.
This is passed to the factory.
An exception used to denote that an error occurred while applying a user-defined function on the input data.
An exception used to denote that an error occurred while applying a user-defined function on the input data. This was not a problem with the model but rather the code that the model called. This is differentiated because the code may have been defined outside of the Aloha libraries.
The instantiation of this class should not throw exceptions.
a specification for the feature that produced an error.
output of the accessor functions for the feature that produced an error.
names of accessor functions with missing data in the feature that produced an error.
names of accessor functions that produced errors in the feature that produced an error.
the actual exception denoting the cause of the problem in the feature.
input to the feature that caused a problem. (Note: this parameter was intentionally chosen to go last because of a possible verbose toString output)
User-defined functions used in feature specifications can cause models to throw undesirable exceptions. This semantics mixin can allow the the exception to be caught, reformulated as a com.eharmony.aloha.semantics.SemanticsUdfException and rethrown. This has the distinct advantage of providing the caller with the exact feature specification that failed along with the features that were present and missing and the input data that caused the problem.
Example usage: Assume a we have an implementation UnsafeSemantics, implementing com.eharmony.aloha.semantics.Semantics\[Xyz\]. We can recast the errors by doing
the input type.