MINOR: sample: provide a generic var-to-sample conversion function

We're using variable-to-sample conversion at least 4 times in the code,
two of which are bogus. Let's introduce a generic conversion function
that performs the required checks.
2 files changed