Skip to content

Commit

Permalink
depr(api): deprecate ibis.negate in favor of negate method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored and cpcloud committed Sep 28, 2023
1 parent 1918aac commit 47cdbe8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 61 deletions.
2 changes: 0 additions & 2 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ quartodoc:
- name: or_
dynamic: true
package: ibis
- name: negate
package: ibis.expr.api
- name: random
dynamic: true
package: ibis
Expand Down
113 changes: 56 additions & 57 deletions ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@
True
"""

negate = ir.NumericValue.negate


def param(type: dt.DataType) -> ir.Scalar:
"""Create a deferred parameter of a given type.
Expand Down Expand Up @@ -1696,7 +1694,7 @@ def watermark(time_col: str, allowed_delay: ir.IntervalScalar) -> Watermark:
pi = ops.Pi().to_expr()


def _geo_deprecated(fn):
def _wrap_deprecated(fn, prefix=""):
"""Deprecate the top-level geo function."""

@functools.wraps(fn)
Expand All @@ -1707,66 +1705,67 @@ def wrapper(self, *args, **kwargs):
return fn(self, *args, **kwargs)

wrapper.__module__ = "ibis.expr.api"
wrapper.__qualname__ = wrapper.__name__ = f"geo_{fn.__name__}"
wrapper.__qualname__ = wrapper.__name__ = prefix + fn.__name__
dec = util.deprecated(
instead=f"use the `{fn.__qualname__}` method instead", as_of="7.0"
)
return dec(wrapper)


geo_area = _geo_deprecated(ir.GeoSpatialValue.area)
geo_as_binary = _geo_deprecated(ir.GeoSpatialValue.as_binary)
geo_as_ewkb = _geo_deprecated(ir.GeoSpatialValue.as_ewkb)
geo_as_ewkt = _geo_deprecated(ir.GeoSpatialValue.as_ewkt)
geo_as_text = _geo_deprecated(ir.GeoSpatialValue.as_text)
geo_azimuth = _geo_deprecated(ir.GeoSpatialValue.azimuth)
geo_buffer = _geo_deprecated(ir.GeoSpatialValue.buffer)
geo_centroid = _geo_deprecated(ir.GeoSpatialValue.centroid)
geo_contains = _geo_deprecated(ir.GeoSpatialValue.contains)
geo_contains_properly = _geo_deprecated(ir.GeoSpatialValue.contains_properly)
geo_covers = _geo_deprecated(ir.GeoSpatialValue.covers)
geo_covered_by = _geo_deprecated(ir.GeoSpatialValue.covered_by)
geo_crosses = _geo_deprecated(ir.GeoSpatialValue.crosses)
geo_d_fully_within = _geo_deprecated(ir.GeoSpatialValue.d_fully_within)
geo_difference = _geo_deprecated(ir.GeoSpatialValue.difference)
geo_disjoint = _geo_deprecated(ir.GeoSpatialValue.disjoint)
geo_distance = _geo_deprecated(ir.GeoSpatialValue.distance)
geo_d_within = _geo_deprecated(ir.GeoSpatialValue.d_within)
geo_end_point = _geo_deprecated(ir.GeoSpatialValue.end_point)
geo_envelope = _geo_deprecated(ir.GeoSpatialValue.envelope)
geo_equals = _geo_deprecated(ir.GeoSpatialValue.geo_equals)
geo_geometry_n = _geo_deprecated(ir.GeoSpatialValue.geometry_n)
geo_geometry_type = _geo_deprecated(ir.GeoSpatialValue.geometry_type)
geo_intersection = _geo_deprecated(ir.GeoSpatialValue.intersection)
geo_intersects = _geo_deprecated(ir.GeoSpatialValue.intersects)
geo_is_valid = _geo_deprecated(ir.GeoSpatialValue.is_valid)
geo_line_locate_point = _geo_deprecated(ir.GeoSpatialValue.line_locate_point)
geo_line_merge = _geo_deprecated(ir.GeoSpatialValue.line_merge)
geo_line_substring = _geo_deprecated(ir.GeoSpatialValue.line_substring)
geo_length = _geo_deprecated(ir.GeoSpatialValue.length)
geo_max_distance = _geo_deprecated(ir.GeoSpatialValue.max_distance)
geo_n_points = _geo_deprecated(ir.GeoSpatialValue.n_points)
geo_n_rings = _geo_deprecated(ir.GeoSpatialValue.n_rings)
geo_ordering_equals = _geo_deprecated(ir.GeoSpatialValue.ordering_equals)
geo_overlaps = _geo_deprecated(ir.GeoSpatialValue.overlaps)
geo_perimeter = _geo_deprecated(ir.GeoSpatialValue.perimeter)
geo_point = _geo_deprecated(ir.NumericValue.point)
geo_point_n = _geo_deprecated(ir.GeoSpatialValue.point_n)
geo_set_srid = _geo_deprecated(ir.GeoSpatialValue.set_srid)
geo_simplify = _geo_deprecated(ir.GeoSpatialValue.simplify)
geo_srid = _geo_deprecated(ir.GeoSpatialValue.srid)
geo_start_point = _geo_deprecated(ir.GeoSpatialValue.start_point)
geo_touches = _geo_deprecated(ir.GeoSpatialValue.touches)
geo_transform = _geo_deprecated(ir.GeoSpatialValue.transform)
geo_union = _geo_deprecated(ir.GeoSpatialValue.union)
geo_within = _geo_deprecated(ir.GeoSpatialValue.within)
geo_x = _geo_deprecated(ir.GeoSpatialValue.x)
geo_x_max = _geo_deprecated(ir.GeoSpatialValue.x_max)
geo_x_min = _geo_deprecated(ir.GeoSpatialValue.x_min)
geo_y = _geo_deprecated(ir.GeoSpatialValue.y)
geo_y_max = _geo_deprecated(ir.GeoSpatialValue.y_max)
geo_y_min = _geo_deprecated(ir.GeoSpatialValue.y_min)
geo_unary_union = _geo_deprecated(ir.GeoSpatialColumn.unary_union)
geo_area = _wrap_deprecated(ir.GeoSpatialValue.area, "geo_")
geo_as_binary = _wrap_deprecated(ir.GeoSpatialValue.as_binary, "geo_")
geo_as_ewkb = _wrap_deprecated(ir.GeoSpatialValue.as_ewkb, "geo_")
geo_as_ewkt = _wrap_deprecated(ir.GeoSpatialValue.as_ewkt, "geo_")
geo_as_text = _wrap_deprecated(ir.GeoSpatialValue.as_text, "geo_")
geo_azimuth = _wrap_deprecated(ir.GeoSpatialValue.azimuth, "geo_")
geo_buffer = _wrap_deprecated(ir.GeoSpatialValue.buffer, "geo_")
geo_centroid = _wrap_deprecated(ir.GeoSpatialValue.centroid, "geo_")
geo_contains = _wrap_deprecated(ir.GeoSpatialValue.contains, "geo_")
geo_contains_properly = _wrap_deprecated(ir.GeoSpatialValue.contains_properly, "geo_")
geo_covers = _wrap_deprecated(ir.GeoSpatialValue.covers, "geo_")
geo_covered_by = _wrap_deprecated(ir.GeoSpatialValue.covered_by, "geo_")
geo_crosses = _wrap_deprecated(ir.GeoSpatialValue.crosses, "geo_")
geo_d_fully_within = _wrap_deprecated(ir.GeoSpatialValue.d_fully_within, "geo_")
geo_difference = _wrap_deprecated(ir.GeoSpatialValue.difference, "geo_")
geo_disjoint = _wrap_deprecated(ir.GeoSpatialValue.disjoint, "geo_")
geo_distance = _wrap_deprecated(ir.GeoSpatialValue.distance, "geo_")
geo_d_within = _wrap_deprecated(ir.GeoSpatialValue.d_within, "geo_")
geo_end_point = _wrap_deprecated(ir.GeoSpatialValue.end_point, "geo_")
geo_envelope = _wrap_deprecated(ir.GeoSpatialValue.envelope, "geo_")
geo_equals = _wrap_deprecated(ir.GeoSpatialValue.geo_equals, "geo_")
geo_geometry_n = _wrap_deprecated(ir.GeoSpatialValue.geometry_n, "geo_")
geo_geometry_type = _wrap_deprecated(ir.GeoSpatialValue.geometry_type, "geo_")
geo_intersection = _wrap_deprecated(ir.GeoSpatialValue.intersection, "geo_")
geo_intersects = _wrap_deprecated(ir.GeoSpatialValue.intersects, "geo_")
geo_is_valid = _wrap_deprecated(ir.GeoSpatialValue.is_valid, "geo_")
geo_line_locate_point = _wrap_deprecated(ir.GeoSpatialValue.line_locate_point, "geo_")
geo_line_merge = _wrap_deprecated(ir.GeoSpatialValue.line_merge, "geo_")
geo_line_substring = _wrap_deprecated(ir.GeoSpatialValue.line_substring, "geo_")
geo_length = _wrap_deprecated(ir.GeoSpatialValue.length, "geo_")
geo_max_distance = _wrap_deprecated(ir.GeoSpatialValue.max_distance, "geo_")
geo_n_points = _wrap_deprecated(ir.GeoSpatialValue.n_points, "geo_")
geo_n_rings = _wrap_deprecated(ir.GeoSpatialValue.n_rings, "geo_")
geo_ordering_equals = _wrap_deprecated(ir.GeoSpatialValue.ordering_equals, "geo_")
geo_overlaps = _wrap_deprecated(ir.GeoSpatialValue.overlaps, "geo_")
geo_perimeter = _wrap_deprecated(ir.GeoSpatialValue.perimeter, "geo_")
geo_point = _wrap_deprecated(ir.NumericValue.point, "geo_")
geo_point_n = _wrap_deprecated(ir.GeoSpatialValue.point_n, "geo_")
geo_set_srid = _wrap_deprecated(ir.GeoSpatialValue.set_srid, "geo_")
geo_simplify = _wrap_deprecated(ir.GeoSpatialValue.simplify, "geo_")
geo_srid = _wrap_deprecated(ir.GeoSpatialValue.srid, "geo_")
geo_start_point = _wrap_deprecated(ir.GeoSpatialValue.start_point, "geo_")
geo_touches = _wrap_deprecated(ir.GeoSpatialValue.touches, "geo_")
geo_transform = _wrap_deprecated(ir.GeoSpatialValue.transform, "geo_")
geo_union = _wrap_deprecated(ir.GeoSpatialValue.union, "geo_")
geo_within = _wrap_deprecated(ir.GeoSpatialValue.within, "geo_")
geo_x = _wrap_deprecated(ir.GeoSpatialValue.x, "geo_")
geo_x_max = _wrap_deprecated(ir.GeoSpatialValue.x_max, "geo_")
geo_x_min = _wrap_deprecated(ir.GeoSpatialValue.x_min, "geo_")
geo_y = _wrap_deprecated(ir.GeoSpatialValue.y, "geo_")
geo_y_max = _wrap_deprecated(ir.GeoSpatialValue.y_max, "geo_")
geo_y_min = _wrap_deprecated(ir.GeoSpatialValue.y_min, "geo_")
geo_unary_union = _wrap_deprecated(ir.GeoSpatialColumn.unary_union, "geo_")
negate = _wrap_deprecated(ir.NumericValue.negate)


@deferrable
Expand Down
2 changes: 0 additions & 2 deletions ibis/tests/expr/test_value_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,8 @@ def test_nullable_column_propagated():
def test_interval_negate(base_expr):
expr = -base_expr
expr2 = base_expr.negate()
expr3 = ibis.negate(base_expr)
assert isinstance(expr.op(), ops.Negate)
assert expr.equals(expr2)
assert expr.equals(expr3)


def test_large_timestamp():
Expand Down

0 comments on commit 47cdbe8

Please sign in to comment.