Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hail] hl.range supports a single argument #6903

Merged
merged 4 commits into from Aug 26, 2019

Conversation

@danking
Copy link
Collaborator

commented Aug 19, 2019

This matches the semantics of Python range. See docs for example.

[hail] hl.range supports a single argument
This matches the semantics of Python `range`. See docs for example.
>>> hl.eval(hl.range(0, 10, step=3))
[0, 3, 6, 9]
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 Python's :func:`range`.

This comment has been minimized.

Copy link
@tpoterba

tpoterba Aug 19, 2019

Collaborator

this will link back to this function

This comment has been minimized.

This comment has been minimized.

Copy link
@danking

danking Aug 23, 2019

Author Collaborator

I just removed the link.

self.assertRaisesRegex(
hl.utils.HailException,
'Array range cannot have step size 0',
hl.eval(hl.range(0,1,0)

This comment has been minimized.

Copy link
@chrisvittal

chrisvittal Aug 19, 2019

Collaborator

Unclosed parens.

>>> hl.eval(hl.range(0, 10, step=3))
[0, 3, 6, 9]
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 Python's :func:`range`.

This comment has been minimized.

@@ -1910,6 +1916,9 @@ def range(start, stop, step=1) -> ArrayNumericExpression:
-------
:class:`.ArrayInt32Expression`
"""
if stop is None:
stop = start
start = 0

This comment has been minimized.

Copy link
@chrisvittal

chrisvittal Aug 19, 2019

Collaborator

Also, this isn't an expression and causes type checking errors later.

>>> hl.range(10).show()
  File "<string>", line 1, in <module>
  File "</home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/decorator.py:decorator-gen-638>", line 2, in range
  File "/home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/hail/typecheck/check.py", line 585, in wrapper
    return __original_func(*args_, **kwargs_)
  File "/home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/hail/expr/functions.py", line 1922, in range
    return apply_expr(lambda sta, sto, ste: ArrayRange(sta, sto, ste), tarray(tint32), start, stop, step)
  File "/home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/hail/expr/expressions/typed_expressions.py", line 3646, in apply_expr
    indices, aggregations = unify_all(*args)
  File "/home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/hail/expr/expressions/base_expression.py", line 225, in unify_all
    new_indices = Indices.unify(*[e._indices for e in exprs])
  File "/home/cdv/.cache/venv/hail/lib64/python3.6/site-packages/hail/expr/expressions/base_expression.py", line 225, in <listcomp>
    new_indices = Indices.unify(*[e._indices for e in exprs])
AttributeError: 'int' object has no attribute '_indices'
fix
danking added 2 commits Aug 26, 2019
fix
fix

@danking danking merged commit 599896b into hail-is:master Aug 26, 2019

1 check passed

ci-test success
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.