-
Notifications
You must be signed in to change notification settings - Fork 17
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
summary.rspec rewrite #250
Conversation
Current state Slower when computing full suite of variables (as expected, owing to duplication of calcs)
Faster when computing subset (as expected, since that's all it's calculating)
Some further refactoring can probably bring down that difference for the full set |
Alright, I think I've gone as far as I can & have the patience for at the moment. So it now only calculates the specified variable(s) (and any dependent variables), which I think is good news just from a design perspective. E.g. it shouldn't matter if you don't have the wavelength range for 'green chroma' if you just want B3. It also means some changes to its speed. It's now slower when calculating all variables — about ~half the speed:
But ~10x faster when calculating only a subset:
I didn't think it'd be quite so slow for the full-variable-set use case, but I might be missing something obvious. I'm sure there's more tweaking & tightening which can be done - feel free to shout if anything obvious leaps out at you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! I don't have any major comments on code.
I feel like the structure and design is slightly more complex though. Is it okay if I push directly some code comments on this branch to make sure the intent and possible next steps are recorded?
R/summary.rspec.R
Outdated
if (lambdamin > lim[1]) { | ||
stop("Minimum specified wavelength is smaller than the range of spectral data. Check the lim() argument.") | ||
} | ||
if (lambdamax < lim[2]) { | ||
stop("Maximum specified wavelength is larger than the range of spectral data. Check the lim() argument.") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (lambdamin > lim[1]) { | |
stop("Minimum specified wavelength is smaller than the range of spectral data. Check the lim() argument.") | |
} | |
if (lambdamax < lim[2]) { | |
stop("Maximum specified wavelength is larger than the range of spectral data. Check the lim() argument.") | |
} | |
if (lambdamin > lim[1]) { | |
stop("Minimum specified wavelength is smaller than the range of spectral data. Check the lim argument.") | |
} | |
if (lambdamax < lim[2]) { | |
stop("Maximum specified wavelength is larger than the range of spectral data. Check the lim argument.") | |
} |
tests/testthat/test-S3rspec.R
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be useful to add tests for the deprecation warnings as well.
Absolutely — feel free to push/tweak anything. Thanks! |
I had another, in-depth, look and I'm now not sure more comments are needed. I've pushed a minor update but I think it already looks very good as it is 👍. One problematic edge case I've found while trying to add deprecation tests: summary(sicalis, wlmin = 400)
|
Thanks! Should be fixed with that next commit. I'll merge this in shortly then, and start prepping a release soon too. |
summary.rspec rejig (fixes #165)
wlmin
,wlmax
, in favour oflim = c()
argument.subset
.