You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@cbeleites, why in some functions only validObject(), in some only chk.hy(), and in some both validObject() and chk.hy() are used? What is the pattern? How to know which combination should be used?
chk.hy() checks whether the object is of class hyperSpec, regardless of its validity.
validObject() checks whether an S4 object is valid (regardless of whether it is a hyperSpec object).
So,
chk.hy() is not needed when method dispatch guarantees that the object if of class hyperSpec.
This will mostly happen during input checking.
whenever a function does things that may make the object invalid (e.g. wrong data type inside any of the slots, wavelength vector has different length from no. of columns in $spc) it makes sense to trigger a validity check before returning.
Activity
cbeleites commentedon Jul 14, 2021
chk.hy()checks whether the object is of class hyperSpec, regardless of its validity.validObject()checks whether an S4 object is valid (regardless of whether it is a hyperSpec object).So,
chk.hy()is not needed when method dispatch guarantees that the object if of class hyperSpec.$spc) it makes sense to trigger a validity check before returning.