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

feat: better distinguish ibis scalars from evaluated results in interactive repr #9247

Closed
jcrist opened this issue May 24, 2024 · 0 comments · Fixed by #9265
Closed

feat: better distinguish ibis scalars from evaluated results in interactive repr #9247

jcrist opened this issue May 24, 2024 · 0 comments · Fixed by #9265
Labels
feature Features or general enhancements ux User experience related issues

Comments

@jcrist
Copy link
Member

jcrist commented May 24, 2024

Currently in interactive mode, we evaluate Table, Column and Scalar expressions and display their results. For Table and Column values the repr is easily distinguishable from other python types. For scalar values it's not - they display the same as their in-memory counterparts. When working interactively (especially in a fast backend like duckdb) this can sometimes be confusing, as it makes it easy to forget that some object is an ibis scalar expression rather than its evaluated result.

In [1]: import ibis

In [2]: t = ibis.memtable({"x": [1, 2, None], "y": [3, 4, 5]})

In [3]: ibis.options.interactive = True

In [4]: t  # reprs in a unique enough way to know it's not a builtin type
Out[4]: 
┏━━━━━━━━━┳━━━━━━━┓
┃ xy     ┃
┡━━━━━━━━━╇━━━━━━━┩
│ float64int64 │
├─────────┼───────┤
│     1.03 │
│     2.04 │
│    NULL5 │
└─────────┴───────┘

In [5]: t.x  # same here
Out[5]: 
┏━━━━━━━━━┓
┃ x       ┃
┡━━━━━━━━━┩
│ float64 │
├─────────┤
│     1.0 │
│     2.0 │
│    NULL │
└─────────┘

In [6]: t.x.sum()  # reprs the same as a float. Is this a float, or an ibis expression? Hard to say from just looking at the repr.
Out[6]: 3.0

In [7]: ibis.literal(None)  # same here - is this a None or an ibis object?
Out[7]: None

This issue is partly to blame for confusion around #8833 - in this case the subexpression reprs as None, which led them to believe it would be treated the same as None if passed to a method to construct a larger expression. Better visually distinguishing these types would help here IMO.

I think it would be good to amend our interactive repr for scalars to better distinguish them still as ibis objects. I'm not sure what styling elements would be best to use here - perhaps just box it, the same as we do for columns or tables?

In [8]: t.x.sum()

Out[8]:
┌─────┐ 
│ 3.0 │
└─────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements ux User experience related issues
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant