def array(input_array): """Construct an :class:`.NDArrayExpression` Examples -------- >>> hl.eval(hl.nd.array([1, 2, 3, 4])) array([1, 2, 3, 4], dtype=int32) >>> hl.eval(hl.nd.array([[1, 2, 3], [4, 5, 6]])) array([[1, 2, 3], [4, 5, 6]], dtype=int32) >>> hl.eval(hl.nd.array(np.identity(3))) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) >>> hl.eval(hl.nd.array(hl.range(10, 20))) array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], dtype=int32) Parameters ---------- input_array : :class:`.ArrayExpression` or numpy ndarray or nested python lists Returns ------- :class:`.NDArrayExpression` An ndarray based on the input array. """ return _ndarray(input_array)
def array(input_array, dtype=None): """Construct an :class:`.NDArrayExpression` Examples -------- >>> hl.eval(hl.nd.array([1, 2, 3, 4])) array([1, 2, 3, 4], dtype=int32) >>> hl.eval(hl.nd.array([[1, 2, 3], [4, 5, 6]])) array([[1, 2, 3], [4, 5, 6]], dtype=int32) >>> hl.eval(hl.nd.array(np.identity(3))) array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]) >>> hl.eval(hl.nd.array(hl.range(10, 20))) array([10, 11, 12, 13, 14, 15, 16, 17, 18, 19], dtype=int32) Parameters ---------- input_array : :class:`.ArrayExpression`, numpy ndarray, or nested python lists/tuples dtype : :class:`.HailType` Desired hail type. Default: `float64`. Returns ------- :class:`.NDArrayExpression` An ndarray based on the input array. """ return _ndarray(input_array, dtype=dtype)
def arange(start, stop=None, step=1) -> NDArrayNumericExpression: """Returns a 1-dimensions ndarray of integers from `start` to `stop` by `step`. Examples -------- >>> hl.eval(hl.nd.arange(10)) array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32) >>> hl.eval(hl.nd.arange(3, 10)) array([3, 4, 5, 6, 7, 8, 9], dtype=int32) >>> hl.eval(hl.nd.arange(0, 10, step=3)) array([0, 3, 6, 9], dtype=int32) Notes ----- The range includes `start`, but excludes `stop`. If provided exactly one argument, the argument is interpreted as `stop` and `start` is set to zero. This matches the behavior of Python's ``range``. Parameters ---------- start : int or :class:`.Expression` of type :py:data:`.tint32` Start of range. stop : int or :class:`.Expression` of type :py:data:`.tint32` End of range. step : int or :class:`.Expression` of type :py:data:`.tint32` Step of range. Returns ------- :class:`.NDArrayNumericExpression` A 1-dimensional ndarray from `start` to `stop` by `step`. """ return _ndarray(hl.range(start, stop, step))
def array(input_array): return _ndarray(input_array)