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] Teach Expressions to HTML Show #6089
Changes from 6 commits
0593157
b88d3ab
b07c47c
4895201
87a8faa
a426db6
5f06db5
a9878f2
8fb1dce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1396,8 +1396,8 @@ def format_line(values): | |
|
||
return s | ||
|
||
@typecheck_method(n=nullable(int), width=nullable(int), truncate=nullable(int), types=bool, handler=nullable(anyfunc)) | ||
def show(self, n=None, width=None, truncate=None, types=True, handler=None): | ||
@typecheck_method(n=nullable(int), width=nullable(int), truncate=nullable(int), types=bool, handler=nullable(anyfunc), n_rows=nullable(int)) | ||
def show(self, n=None, width=None, truncate=None, types=True, handler=None, n_rows=None): | ||
"""Print the first few rows of the table to the console. | ||
|
||
Examples | ||
|
@@ -1418,7 +1418,7 @@ def show(self, n=None, width=None, truncate=None, types=True, handler=None): | |
|
||
Parameters | ||
---------- | ||
n : :obj:`int` | ||
n or n_rows : :obj:`int` | ||
Maximum number of rows to show. | ||
width : :obj:`int` | ||
Horizontal width at which to break fields. | ||
|
@@ -1430,6 +1430,11 @@ def show(self, n=None, width=None, truncate=None, types=True, handler=None): | |
handler : Callable[[str], Any] | ||
Handler function for data string. | ||
""" | ||
if n_rows is not None and n is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit confused about this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's also not typechecked which will create an error. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did modify the type check annotation. In There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I see. OK, sure |
||
raise ValueError(f'specify one of n_rows or n, recieved {n_rows} and {n}') | ||
if n_rows is not None: | ||
n = n_rows | ||
del n_rows | ||
if handler is None: | ||
try: | ||
from IPython.display import display | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from ..helpers import startTestHailContext, stopTestHailContext | ||
import unittest.TestCase | ||
|
||
import hail as hl | ||
|
||
setUpModule = startTestHailContext | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name error? needs to be imported There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
tearDownModule = stopTestHailContext | ||
|
||
class Tests(unittest.TestCase): | ||
def test(): | ||
mt = hl.balding_nichols_model(3, 10, 10) | ||
t = mt.rows() | ||
mt.GT.show() | ||
mt.locus.show() | ||
mt.af.show() | ||
mt.pop.show() | ||
mt.sample_idx.show() | ||
mt.bn.show() | ||
mt.bn.fst.show() | ||
mt.GT.n_alt_alleles().show() | ||
(mt.GT.n_alt_alleles() * mt.GT.n_alt_alleles()).show() | ||
(mt.af * mt.GT.n_alt_alleles()).show() | ||
t.af.show() | ||
(t.af * 3).show() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this change to handlers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d'oh, this is the html fix 🤦♂