Skip to content

Commit

Permalink
depr(api): mark ibis.sequence() for removal
Browse files Browse the repository at this point in the history
not required anymore, the API methods should automatically convert coerce to the right types
  • Loading branch information
kszucs authored and cpcloud committed Feb 18, 2023
1 parent 183af2c commit 3589f80
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
11 changes: 5 additions & 6 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
null,
struct,
)
from ibis.util import experimental
from ibis.util import deprecated, experimental

if TYPE_CHECKING:
import pandas as pd
Expand Down Expand Up @@ -148,8 +148,8 @@
'sequence',
'set_backend',
'show_sql',
'to_sql',
'struct',
'to_sql',
'table',
'time',
'timestamp',
Expand Down Expand Up @@ -227,21 +227,20 @@ def param(type: dt.DataType) -> ir.Scalar:
return ops.ScalarParameter(type).to_expr()


# TODO(kszucs): should be deprecated
@deprecated(as_of='5.0', removed_in='6.0', instead='use tuple or list instead')
def sequence(values: Sequence[T | None]) -> ir.List:
"""Wrap a list of Python values as an Ibis sequence type.
Parameters
----------
values
Should all be None or the same type
Returns
-------
List
A list expression
A list expression.
"""
return rlz.tuple_of(rlz.any, values)
return [op.to_expr() for op in rlz.tuple_of(rlz.any, values)]


def schema(
Expand Down
25 changes: 15 additions & 10 deletions ibis/expr/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,37 @@ def test_invalid_isin(values, value, expected):
param(
rlz.tuple_of(rlz.integer),
(3, 2),
ibis.sequence([3, 2]),
id="list_int",
(ibis.literal(3), ibis.literal(2)),
id="tuple_int",
),
param(
rlz.tuple_of(rlz.integer),
(3, None),
ibis.sequence([3, ibis.NA]),
id="list_int_null",
(ibis.literal(3), ibis.NA),
id="tuple_int_null",
),
param(
rlz.tuple_of(rlz.string),
('a',),
ibis.sequence(['a']),
id="list_string_one",
(ibis.literal('a'),),
id="tuple_string_one",
),
param(
rlz.tuple_of(rlz.string),
['a', 'b'],
ibis.sequence(['a', 'b']),
id="list_string_two",
(ibis.literal('a'), ibis.literal('b')),
id="tuple_string_two",
),
param(
rlz.tuple_of(rlz.boolean, min_length=2),
[True, False],
ibis.sequence([True, False]),
id="boolean",
(ibis.literal(True), ibis.literal(False)),
id="tuple_boolean",
),
param(
rlz.tuple_of(rlz.string),
["bar", table.string_col, "foo"],
(ibis.literal("bar"), table.string_col, ibis.literal("foo")),
),
],
)
Expand Down
19 changes: 8 additions & 11 deletions ibis/tests/expr/test_value_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,17 +269,6 @@ def test_literal_array():
assert expr.type().equals(dt.Array(dt.null))


def test_mixed_arity(table):
what = ["bar", table.g, "foo"]
expr = api.sequence(what)

assert isinstance(expr, tuple)
assert isinstance(expr[1], ops.TableColumn)

# it works!
repr(expr)


@pytest.mark.parametrize('container', [list, tuple, set, frozenset])
def test_isin_notin_list(table, container):
values = container([1, 2, 3, 4])
Expand Down Expand Up @@ -1678,3 +1667,11 @@ def test_quantile_shape():
(b1,) = expr.op().selections

assert b1.output_shape.is_columnar()


def test_sequence():
with pytest.warns(FutureWarning):
exprs = ibis.sequence([3, 2])

for expr in exprs:
assert isinstance(expr, ir.ScalarExpr)

0 comments on commit 3589f80

Please sign in to comment.