11"""
22This file contains auxiliary Ops, used during the compilation phase and Ops
3- building class (:class:`FromFunctionOp`) and decorator (:func:`as_op `) that
3+ building class (:class:`FromFunctionOp`) and decorator (:func:`wrap_py `) that
44help make new Ops more rapidly.
55
66"""
@@ -268,12 +268,12 @@ def __reduce__(self):
268268 obj = load_back (mod , name )
269269 except (ImportError , KeyError , AttributeError ):
270270 raise pickle .PicklingError (
271- f"Can't pickle as_op (), not found as { mod } .{ name } "
271+ f"Can't pickle wrap_py (), not found as { mod } .{ name } "
272272 )
273273 else :
274274 if obj is not self :
275275 raise pickle .PicklingError (
276- f"Can't pickle as_op (), not the object at { mod } .{ name } "
276+ f"Can't pickle wrap_py (), not the object at { mod } .{ name } "
277277 )
278278 return load_back , (mod , name )
279279
@@ -282,6 +282,18 @@ def _infer_shape(self, fgraph, node, input_shapes):
282282
283283
284284def as_op (itypes , otypes , infer_shape = None ):
285+ import warnings
286+
287+ warnings .warn (
288+ "pytensor.as_op is deprecated and will be removed in a future release. "
289+ "Please use pytensor.wrap_py instead." ,
290+ FutureWarning ,
291+ stacklevel = 2 ,
292+ )
293+ return wrap_py (itypes , otypes , infer_shape )
294+
295+
296+ def wrap_py (itypes , otypes , infer_shape = None ):
285297 """
286298 Decorator that converts a function into a basic PyTensor op that will call
287299 the supplied function as its implementation.
@@ -301,8 +313,8 @@ def infer_shape(fgraph, node, input_shapes):
301313
302314 Examples
303315 --------
304- @as_op (itypes=[pytensor.tensor.fmatrix, pytensor.tensor.fmatrix],
305- otypes=[pytensor.tensor.fmatrix])
316+ @wrap_py (itypes=[pytensor.tensor.fmatrix, pytensor.tensor.fmatrix],
317+ otypes=[pytensor.tensor.fmatrix])
306318 def numpy_dot(a, b):
307319 return numpy.dot(a, b)
308320
0 commit comments