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

chore: add box to scalar expr in interactive mode #9265

Merged
merged 3 commits into from
May 31, 2024

Conversation

ncclementi
Copy link
Contributor

@ncclementi ncclementi commented May 28, 2024

This is an attempt to close #9247 and possible the discussion around #8833

I'm using rich Panel and the box.SQUARE style to wrap scalar values into a box. There are multiple styles (see https://rich.readthedocs.io/en/stable/appendix/box.html), I chose the one that looks the most similar to what we have now.

TODO:

  • Do we need a tests for this? I wasn't quite sure how to add a test for it.
  • Modify doctests accordingly if we like this change

Closes #9247

Here is how it renders in ipython.

In [1]: import ibis

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

In [3]: ibis.literal(1).nullif(1)
Out[3]: 
┌──────┐
│ None │
└──────┘

In [4]: ibis.literal(1).nullif(0)
Out[4]: 
┌───┐
│ 1 │
└───┘

In [5]: ibis.literal("abcdefghi").substr(3)
Out[5]: 
┌──────────┐
│ 'defghi' │
└──────────┘

In [6]: print(ibis.literal("abcdefghi").substr(3))
┌──────────┐
│ 'defghi' │
└──────────┘

In [7]: print(ibis.literal(True))
┌──────┐
│ True │
└──────┘

In [8]: import datetime

In [9]: date = datetime.datetime(2015, 1, 1, 12, 34, 56)

In [10]: print(ibis.literal(date))
┌──────────────────────────────────┐
│ Timestamp('2015-01-01 12:34:56') │
└──────────────────────────────────┘

@ncclementi ncclementi marked this pull request as ready for review May 28, 2024 20:01
@ncclementi ncclementi requested a review from jcrist May 28, 2024 20:05
@cpcloud cpcloud added this to the 9.1 milestone May 29, 2024
@ncclementi
Copy link
Contributor Author

After chatting in triage we are ok with the change, I will go ahead and modify the doctests to match the new repr.

@ncclementi ncclementi force-pushed the scalar-repr branch 2 times, most recently from f538922 to ea367f9 Compare May 30, 2024 20:39
ibis/expr/types/strings.py Outdated Show resolved Hide resolved
@cpcloud cpcloud enabled auto-merge (squash) May 31, 2024 16:10
@cpcloud cpcloud merged commit 067e8a7 into ibis-project:main May 31, 2024
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: better distinguish ibis scalars from evaluated results in interactive repr
2 participants