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

Fix for issue #1240. #1247

Merged
merged 6 commits into from
Sep 15, 2015
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions blaze/expr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ def _str(s):
return get_callable_name(s)
elif isinstance(s, Node):
return str(s)
elif isinstance(s, (list, tuple)):
body = ", ".join(_str(x) for x in s)
return "({0})".format(body if len(s) > 1 else (body + ","))
else:
stream = StringIO()
pprint(s, stream=stream)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of unrelated, but the else clause is just return pformat(s).rstrip()

Expand Down
10 changes: 9 additions & 1 deletion blaze/tests/test_interactive.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from blaze.interactive import Data, compute, concrete_head, expr_repr, to_html

import datetime
from re import sub
from odo import into, append
from odo.backends.csv import CSV
from blaze import discover
from blaze import discover, transform
from blaze.compute.core import compute
from blaze.compute.python import compute
from blaze.expr import symbol
Expand Down Expand Up @@ -94,6 +95,13 @@ def test_repr():
assert '...' in result


def test_str_does_not_repr():
# see GH issue #1240.
d = Data([('aa', 1), ('b', 2)], dshape='2 * {a: string, b: int64}')
expr = transform(d, c=d.a.strlen() + d.b)
assert sub(r'_\d+', 'XXX', str(expr)) == "Merge(_child=XXX, children=(XXX, label(strlen(_child=XXX.a) + XXX.b, 'c')))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nitpick can you keep the re.sub call style?

i also think that even though the name of the expression is an implementation detail it should be consistently numbered and therefore it'd be okay to not do the replace and just keep _1 or whatever it happens to be

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of doing that, but my concern is that the _149 (I think that's the symbol) is not necessarily reproducible run-to-run, especially with py.test running things in parallel. Is it reproducible? If so, then I'll make the replacement and remove the re.sub call.



def test_repr_of_scalar():
assert repr(t.amount.sum()) == '300'

Expand Down