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

Add pickling functionality #32

Closed
sixpearls opened this issue Jun 23, 2019 · 6 comments
Closed

Add pickling functionality #32

sixpearls opened this issue Jun 23, 2019 · 6 comments

Comments

@sixpearls
Copy link
Collaborator

@ixjlyons Do you think it would be a nice feature to add some pickling functionality? I'm not sure how useful it would be practically, since the least squares and interpolating constructors are relatively fast, deterministic, etc. But it may help the aesthetic "completeness" or self-containment. I might also use it in other projects as a discipline, but it would be easy to add it to the other project if needed. For that project, I could also just store the arguments to the least square/interpolating constructors.

@ixjlyons
Copy link
Member

Seems like it'd be nice to have to me. Does pickling the BSplineNDInterpolator object not just work currently?

@sixpearls
Copy link
Collaborator Author

I never checked, actually. All of the data that is actually kept is in NumPy arrays of standard types. The only possible question is the impl attribute, which we shouldn't want to save to disk, anyway. I am not actually very familiar with Pickle and was using it as a general short hand for de/serializing objects.

@ixjlyons
Copy link
Member

Yeah it does seem to work currently, though I agree it storing the impl attribute isn't ideal.

Serializing just the arrays/args needed to re-construct the "fitted" spline would be good and avoids some of the usual concerns with pickling. Then you could have to_pickle/from_pickle or to_file/from_file methods.

@ixjlyons
Copy link
Member

Another idea would be going back to impl as a module-wide variable and call it a day

@sixpearls
Copy link
Collaborator Author

Let's write an instance method to_file and module function from_file that writes/reads the __init__ arguments in a single .npz file.

I don't remember what the motivation was for impl as a class attribute rather than module or instance. It does seem nice as a module attribute so pickle "just works" the right way (not that we're using it). A per-instance attribute could also allow using the better implementation for specific tasks in the same work space, although it is unlikely anyone would practically find a benefit to doing so.

@sixpearls
Copy link
Collaborator Author

Closed by #34

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

2 participants