Increased transform flexibility#13
Conversation
|
First I want to say I really appreciate the work you've put into the project, but I will not be able to merge this as is, since it breaks two invariants of the trait:
However I think this does reveal some flaws in the transforms, namely:
|
I'm not sure I follow this response -- that's what it still does, it just copies the data using
Definitely curious to see what "reusable" means to you here. After all, the |
| { | ||
| let mut new_data = self.clone(); | ||
| new_data.transform(transform); | ||
| let mut new_data = self.to_owned(); |
There was a problem hiding this comment.
annot: note specifically here that it's still making a copy of it https://doc.rust-lang.org/std/borrow/trait.ToOwned.html
There was a problem hiding this comment.
Ok fair point - I concede that the ToOwned version is more general.
However I still want to keep the &R here
implementing Transform for &Transform makes it compatible but imho encourages stateful or single use transforms, which I don't love
There was a problem hiding this comment.
To me the thing that enforces that is that https://docs.rs/polyfit/latest/polyfit/transforms/trait.Transform.html#tymethod.apply takes &self, which I do not propose to change. You'd still have to use Cell or similar to make a stateful transform as a result.
I just got sad having to do blah.transform(&NormalizationTransform::MeanSubtraction); when the & didn't really seem to help anything at all, vs being able to just blah.transform(NormalizationTransform::MeanSubtraction);.
| // This will return an error! | ||
|
|
||
| let bad_prediction_probably = fit.as_polynomial().y(150.0); // This is outside the range of the data, but you asked for it specifically | ||
| let bad_prediction_probably = fit.as_polynomial().y(150.0); // This is outside the range of the data, but you asked for it specifically |
There was a problem hiding this comment.
Readme is a generated file (cargo rdme), please don't directly alter it - also this instance is already gone
There was a problem hiding this comment.
I did this with cargo rdme because the PR build failed originally without it.
I think this bit of #12 is clearly worth doing, since it just makes things more flexible.
It seems obviously good to be able to
.transform(…)slices too, not justVec.