Skip to content

Commit

Permalink
fix(repr): format scalar values with same logic as columnar values
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist committed Aug 13, 2024
1 parent 31295dd commit 5cd58fa
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 209 deletions.
54 changes: 27 additions & 27 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,16 +825,16 @@ def timestamp(
Create a timestamp scalar from a string
>>> ibis.timestamp("2023-01-02T03:04:05")
┌──────────────────────────────────
Timestamp('2023-01-02 03:04:05')
└──────────────────────────────────
┌─────────────────────┐
│ 2023-01-02 03:04:05 │
└─────────────────────┘
Create a timestamp scalar from components
>>> ibis.timestamp(2023, 1, 2, 3, 4, 5)
┌──────────────────────────────────
Timestamp('2023-01-02 03:04:05')
└──────────────────────────────────
┌─────────────────────┐
│ 2023-01-02 03:04:05 │
└─────────────────────┘
Create a timestamp column from components
Expand Down Expand Up @@ -910,16 +910,16 @@ def date(value_or_year, month=None, day=None, /):
Create a date scalar from a string
>>> ibis.date("2023-01-02")
┌───────────────────────────
datetime.date(2023, 1, 2)
└───────────────────────────
┌────────────┐
│ 2023-01-02
└────────────┘
Create a date scalar from year, month, and day
>>> ibis.date(2023, 1, 2)
┌───────────────────────────
datetime.date(2023, 1, 2)
└───────────────────────────
┌────────────┐
│ 2023-01-02
└────────────┘
Create a date column from year, month, and day
Expand Down Expand Up @@ -983,16 +983,16 @@ def time(value_or_hour, minute=None, second=None, /):
Create a time scalar from a string
>>> ibis.time("01:02:03")
┌────────────────────────
datetime.time(1, 2, 3)
└────────────────────────
┌──────────┐
01:02:03
└──────────┘
Create a time scalar from hour, minute, and second
>>> ibis.time(1, 2, 3)
┌────────────────────────
datetime.time(1, 2, 3)
└────────────────────────
┌──────────┐
01:02:03
└──────────┘
Create a time column from hour, minute, and second
Expand Down Expand Up @@ -2409,9 +2409,9 @@ def coalesce(*args: Any) -> ir.Value:
>>> import ibis
>>> ibis.options.interactive = True
>>> ibis.coalesce(None, 4, 5)
┌────────────
np.int8(4)
└────────────
┌───┐
4
└───┘
"""
return ops.Coalesce(args).to_expr()

Expand All @@ -2435,9 +2435,9 @@ def greatest(*args: Any) -> ir.Value:
>>> import ibis
>>> ibis.options.interactive = True
>>> ibis.greatest(None, 4, 5)
┌────────────
np.int8(5)
└────────────
┌───┐
5
└───┘
"""
return ops.Greatest(args).to_expr()

Expand All @@ -2461,8 +2461,8 @@ def least(*args: Any) -> ir.Value:
>>> import ibis
>>> ibis.options.interactive = True
>>> ibis.least(None, 4, 5)
┌────────────
np.int8(4)
└────────────
┌───┐
4
└───┘
"""
return ops.Least(args).to_expr()
10 changes: 4 additions & 6 deletions ibis/expr/operations/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,10 @@ def builtin(
... def favg(a: float) -> float:
... '''Compute the average of a column using Kahan summation.'''
>>> t = ibis.examples.penguins.fetch()
>>> expr = favg(t.bill_length_mm)
>>> expr
┌──────────────────────────────┐
│ np.float64(43.9219298245614) │
└──────────────────────────────┘
>>> favg(t.bill_length_mm)
┌──────────┐
│ 43.92193 │
└──────────┘
"""
return _wrap(
cls._make_wrapper,
Expand Down
Loading

0 comments on commit 5cd58fa

Please sign in to comment.