Skip to content

Commit

Permalink
fix(deps): update dependency numpy to v2 (#9395)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Phillip Cloud <417981+cpcloud@users.noreply.github.com>
  • Loading branch information
renovate[bot] and cpcloud authored Jun 20, 2024
1 parent 560ddf6 commit 3cb39a5
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 230 deletions.
4 changes: 3 additions & 1 deletion ibis/backends/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,9 @@ def _filter_none_from_raises(kwargs):
failing_specs = []
for spec in specs:
req = Requirement(spec)
if req.specifier.contains(importlib.import_module(req.name).__version__):
if req.specifier.contains(
importlib.import_module(req.name).__version__
) and ((not req.marker) or req.marker.evaluate()):
failing_specs.append(spec)
reason = f"{backend} backend test fails with {backend}{specs}"
if provided_reason is not None:
Expand Down
24 changes: 0 additions & 24 deletions ibis/backends/pandas/tests/test_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,30 +364,6 @@ def my_wm(v, w):
tm.assert_frame_equal(result, expected)


# TODO(kszucs): revisit this, duckdb produces the same result as the pandas
# backend, but the expected result is different
# def test_udaf_window_nan():
# df = pd.DataFrame(
# {
# "a": np.arange(10, dtype=float),
# "b": [3.0, np.NaN] * 5,
# "key": list("ddeefffggh"),
# }
# )
# con = Backend().connect({"df": df})
# t = con.table("df")
# window = ibis.trailing_window(2, order_by="a", group_by="key")
# expr = t.mutate(rolled=my_mean(t.b).over(window))
# result = expr.execute().sort_values(["key", "a"])
# expected = df.sort_values(["key", "a"]).assign(
# rolled=lambda d: d.groupby("key")
# .b.rolling(3, min_periods=1)
# .apply(lambda x: x.mean(), raw=True)
# .reset_index(level=0, drop=True)
# )
# tm.assert_frame_equal(result, expected)


@pytest.fixture(params=[[0.25, 0.75], [0.01, 0.99]])
def qs(request):
return request.param
Expand Down
4 changes: 2 additions & 2 deletions ibis/backends/pyspark/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _load_data(self, **_: Any) -> None:
pd.DataFrame(
{
"a": np.arange(10, dtype=float),
"b": [3.0, np.NaN] * 5,
"b": [3.0, np.nan] * 5,
"key": list("ddeefffggh"),
}
)
Expand Down Expand Up @@ -255,7 +255,7 @@ def con(data_dir, tmp_path_factory, worker_id):

df_nulls = con._session.createDataFrame(
[
["k1", np.NaN, "Alfred", None],
["k1", np.nan, "Alfred", None],
["k1", 3.0, None, "joker"],
["k2", 27.0, "Batman", "batmobile"],
["k2", None, "Catwoman", "motorcycle"],
Expand Down
4 changes: 4 additions & 0 deletions ibis/backends/tests/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ def test_arrow_timestamp_with_time_zone(alltypes):
@pytest.mark.notimpl(
["impala"], raises=AttributeError, reason="missing `fetchmany` on the cursor"
)
@pytest.mark.xfail_version(
duckdb=["numpy>=2; platform_system == 'Windows'"],
reason="torch on windows doesn't seem to expose the _ARRAY_API symbol",
)
def test_to_torch(alltypes):
import ibis.selectors as s

Expand Down
29 changes: 12 additions & 17 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ def param(type: dt.DataType) -> ir.Scalar:
... )
>>> expr = t.filter(t.date_col >= start).value.sum()
>>> expr.execute(params={start: date(2013, 1, 1)})
6.0
np.float64(6.0)
>>> expr.execute(params={start: date(2013, 1, 2)})
5.0
np.float64(5.0)
>>> expr.execute(params={start: date(2013, 1, 3)})
3.0
np.float64(3.0)
"""
return ops.ScalarParameter(type).to_expr()

Expand Down Expand Up @@ -2376,7 +2375,6 @@ def where(cond, true_expr, false_expr) -> ir.Value:
-------
Value : ir.Value
The value of `true_expr` if `arg` is `True` else `false_expr`
"""
return ifelse(cond, true_expr, false_expr)

Expand Down Expand Up @@ -2405,10 +2403,9 @@ def coalesce(*args: Any) -> ir.Value:
>>> import ibis
>>> ibis.options.interactive = True
>>> ibis.coalesce(None, 4, 5)
┌───┐
│ 4 │
└───┘
┌────────────┐
│ np.int8(4) │
└────────────┘
"""
return ops.Coalesce(args).to_expr()

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

Expand All @@ -2459,9 +2455,8 @@ def least(*args: Any) -> ir.Value:
>>> import ibis
>>> ibis.options.interactive = True
>>> ibis.least(None, 4, 5)
┌───┐
│ 4 │
└───┘
┌────────────┐
│ np.int8(4) │
└────────────┘
"""
return ops.Least(args).to_expr()
8 changes: 4 additions & 4 deletions ibis/expr/operations/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def builtin(
>>> expr = hamming("duck", "luck")
>>> con = ibis.connect("duckdb://")
>>> con.execute(expr)
1
np.int64(1)
"""
return _wrap(
Expand Down Expand Up @@ -621,9 +621,9 @@ def builtin(
>>> t = ibis.examples.penguins.fetch()
>>> expr = favg(t.bill_length_mm)
>>> expr
┌──────────────────┐
│ 43.9219298245614 │
└──────────────────┘
┌──────────────────────────────
np.float64(43.9219298245614)
└──────────────────────────────
"""
return _wrap(
Expand Down
97 changes: 48 additions & 49 deletions ibis/expr/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,9 +1106,9 @@ def identical_to(self, other: Value) -> ir.BooleanValue:
>>> one = ibis.literal(1)
>>> two = ibis.literal(2)
>>> two.identical_to(one + one)
┌──────┐
True
└──────┘
┌──────────
np.True_
└──────────
"""
try:
return ops.IdenticalTo(self, other).to_expr()
Expand Down Expand Up @@ -1572,13 +1572,13 @@ def approx_nunique(
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.approx_nunique()
┌────┐
94
└────┘
┌──────────────
np.int64(94)
└──────────────
>>> t.body_mass_g.approx_nunique(where=t.species == "Adelie")
┌────┐
55
└────┘
┌──────────────
np.int64(55)
└──────────────
"""
return ops.ApproxCountDistinct(
self, where=self._bind_to_parent_table(where)
Expand Down Expand Up @@ -1617,13 +1617,13 @@ def approx_median(
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.approx_median()
┌──────┐
│ 4030 │
└──────┘
┌────────────────
np.int64(4030)
└────────────────
>>> t.body_mass_g.approx_median(where=t.species == "Chinstrap")
┌──────┐
│ 3700 │
└──────┘
┌────────────────
np.int64(3700)
└────────────────
"""
return ops.ApproxMedian(self, where=self._bind_to_parent_table(where)).to_expr()

Expand All @@ -1646,13 +1646,13 @@ def mode(self, where: ir.BooleanValue | None = None) -> Scalar:
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.mode()
┌──────┐
│ 3800 │
└──────┘
┌────────────────
np.int64(3800)
└────────────────
>>> t.body_mass_g.mode(where=(t.species == "Gentoo") & (t.sex == "male"))
┌──────┐
│ 5550 │
└──────┘
┌────────────────
np.int64(5550)
└────────────────
"""
return ops.Mode(self, where=self._bind_to_parent_table(where)).to_expr()

Expand All @@ -1675,13 +1675,13 @@ def max(self, where: ir.BooleanValue | None = None) -> Scalar:
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.max()
┌──────┐
│ 6300 │
└──────┘
┌────────────────
np.int64(6300)
└────────────────
>>> t.body_mass_g.max(where=t.species == "Chinstrap")
┌──────┐
│ 4800 │
└──────┘
┌────────────────
np.int64(4800)
└────────────────
"""
return ops.Max(self, where=self._bind_to_parent_table(where)).to_expr()

Expand All @@ -1704,14 +1704,13 @@ def min(self, where: ir.BooleanValue | None = None) -> Scalar:
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.min()
┌──────┐
│ 2700 │
└──────┘
┌────────────────
np.int64(2700)
└────────────────
>>> t.body_mass_g.min(where=t.species == "Adelie")
┌──────┐
│ 2850 │
└──────┘
┌────────────────┐
│ np.int64(2850) │
└────────────────┘
"""
return ops.Min(self, where=self._bind_to_parent_table(where)).to_expr()

Expand Down Expand Up @@ -1805,9 +1804,9 @@ def median(self, where: ir.BooleanValue | None = None) -> Scalar:
Compute the median of `bill_depth_mm`
>>> t.bill_depth_mm.median()
┌──────┐
│ 17.3 │
└──────┘
┌──────────────────
np.float64(17.3)
└──────────────────
>>> t.group_by(t.species).agg(median_bill_depth=t.bill_depth_mm.median()).order_by(
... ibis.desc("median_bill_depth")
... )
Expand Down Expand Up @@ -1871,9 +1870,9 @@ def quantile(
Compute the 99th percentile of `bill_depth`
>>> t.bill_depth_mm.quantile(0.99)
┌──────┐
│ 21.1 │
└──────┘
┌──────────────────
np.float64(21.1)
└──────────────────
>>> t.group_by(t.species).agg(p99_bill_depth=t.bill_depth_mm.quantile(0.99)).order_by(
... ibis.desc("p99_bill_depth")
... )
Expand Down Expand Up @@ -1930,13 +1929,13 @@ def nunique(self, where: ir.BooleanValue | None = None) -> ir.IntegerScalar:
>>> ibis.options.interactive = True
>>> t = ibis.examples.penguins.fetch()
>>> t.body_mass_g.nunique()
┌────┐
94
└────┘
┌──────────────
np.int64(94)
└──────────────
>>> t.body_mass_g.nunique(where=t.species == "Adelie")
┌────┐
55
└────┘
┌──────────────
np.int64(55)
└──────────────
"""
return ops.CountDistinct(
self, where=self._bind_to_parent_table(where)
Expand Down Expand Up @@ -2319,9 +2318,9 @@ def null(type: dt.DataType | str | None = None) -> Value:
│ None │
└──────┘
>>> ibis.null(str).upper().isnull()
┌──────┐
True
└──────┘
┌──────────
np.True_
└──────────
"""
if type is None:
type = dt.null
Expand Down
6 changes: 3 additions & 3 deletions ibis/expr/types/geospatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ def length(self) -> ir.FloatingValue:
>>> line = shapely.LineString([[0, 0], [1, 0], [1, 1]])
>>> line_lit = ibis.literal(line, type="geometry")
>>> line_lit.length()
┌─────┐
│ 2.0 │
└─────┘
┌─────────────────
np.float64(2.0)
└─────────────────
>>> t = ibis.examples.zones.fetch()
>>> t.geom.length()
┏━━━━━━━━━━━━━━━━━┓
Expand Down
Loading

0 comments on commit 3cb39a5

Please sign in to comment.