code: function validateScalarIsDtype(value, dtype) {
    var inferredDtype = inferDtype(value);
    if (inferredDtype !== null && inferredDtype !== dtype) {
      throw new Error('expected scalar to match dtype "' + dtype +
        '" but instead got ' + value + ', which has dtype "' +
        inferredDtype + '"');
    }
  }
docs: Returns undefined or throws an error if invalid