Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify type stability issues #174

Open
7 tasks
TheBB opened this issue Feb 8, 2024 · 0 comments
Open
7 tasks

Clarify type stability issues #174

TheBB opened this issue Feb 8, 2024 · 0 comments

Comments

@TheBB
Copy link
Member

TheBB commented Feb 8, 2024

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.evaluate returns either a sparse array or a dense array. The sparse code path is more general.
  • BSPlineBasis.continuity returns either an int or a float. It is convenient to pretend it's always an int. What to do?
  • SplineObject.section sometimes returns an array, sometimes a spline object.
  • SplineObject.split sometimes 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.curvature returns 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant