-
Notifications
You must be signed in to change notification settings - Fork 20
Description
I have been working on automatic type checking in Splipy. This is quite challenging, because Splipy has been written to be extremely lenient in terms of types, and many functions return one of several different types based on input parameters. For example, SplineObject.split is a particularly egregious offender: it returns either a list of objects or (if the original object is periodic) only a single object. Since there's no way to encode whether an object is periodic or not in the type system, it's impossible for a type checker to know whether .split returns a list of objects or a single object in any particular case (even though the programmer does!).
I propose to phase out those functions and replace them with more stable alternatives. We can potentially leave behind the incriminating function to prevent destroying existing code, but I don't want to use them in Splipy if at all possible.
In this issue I will list out each relevant case as I find them.
-
BSplineBasis.evaluatereturns either a sparse array or a dense array. The sparse code path is more general.- Resolved with overload.
-
BSPlineBasis.continuityreturns either an int or a float. It is convenient to pretend it's always an int. What to do?- Resolved by adding
knot_continuityandmin_continuitywhich are both type-stable.
- Resolved by adding
-
SplineObject.sectionsometimes returns an array, sometimes a spline object.- Resolved by using the
unwrap_points=Falsekeyword parameter.
- Resolved by using the
-
SplineObject.splitsometimes returns a list, sometimes only one object. -
SplineObject.tangent, when called without a direction, returns a tuple of arrays (one for each direction) - except for Curves. -
Curve.curvaturereturns a float when there's only a single input parameter - most other such functions return a float only when there's a single input parameter that is not in a list. -
Curve.torsion: same problem.