Skip to content

How to use validObject() and chk.hy() #343

Closed

Description

@GegznaV

@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?

Activity

  1. added
    Type: question ❔
    on Jul 14, 2021
  2. cbeleites commented on Jul 14, 2021

    @cbeleites
    Owner
    • 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.
      • This will mostly happen just before returning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: question ❔

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions