Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated methods that duplicate NumPy ufuncs #454

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 1 addition & 46 deletions fipy/tools/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
import sys
import warnings

__all__ = ["getsetDeprecated", "mathMethodDeprecated"]
__all__ = ["getsetDeprecated"]

# Stolen from `numpy.lib.utils`
if sys.version_info < (2, 4):
Expand Down Expand Up @@ -264,51 +264,6 @@ def getsetDeprecated(*args, **kwargs):
else:
return _GetSetDeprecated(*args, **kwargs)

class _MathMethodDeprecated(_Deprecate):
def __init__(self, version="3.0", *args, **kwargs):
_Deprecate.__init__(self, *args, version=version, **kwargs)

def new_name_old_name(self, old_name):
new_name = self.new_name
if new_name is None:
new_name = "numerix.%s() <numpy.%s>" % (old_name, old_name)
return new_name

def mathMethodDeprecated(*args, **kwargs):
"""Issues a `DeprecationWarning` to use the appropriate ufunc from
`numerix`, rather than the method of the same name

This function may also be used as a decorator.

Parameters
----------
func : function
The function to be deprecated.
old_name : str, optional
The name of the function to be deprecated. Default is None, in which
case the name of `func` is used.
new_name : str, optional
The new name for the function. Default is None, in which case
the deprecation message is that `old_name` is deprecated. If given,
the deprecation message is that `old_name` is deprecated and `new_name`
should be used instead.
message : str, optional
Additional explanation of the deprecation. Displayed in the docstring
after the warning.

Returns
-------
old_func : function
The deprecated function.
"""
if args:
fn = args[0]
args = args[1:]

return _MathMethodDeprecated(*args, **kwargs)(fn)
else:
return _MathMethodDeprecated(*args, **kwargs)

def _test():
import fipy.tests.doctestPlus
return fipy.tests.doctestPlus.testmod()
Expand Down
101 changes: 1 addition & 100 deletions fipy/variables/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
from fipy.tools import numerix
from fipy.tools import parser
from fipy.tools import inline
from fipy.tools.decorators import getsetDeprecated, mathMethodDeprecated
from fipy.tools.decorators import getsetDeprecated

__all__ = ["Variable"]

Expand Down Expand Up @@ -1400,101 +1400,6 @@ def all(self, axis=None):
opShape=(),
canInline=False)

@mathMethodDeprecated
def arccos(self):
return self._UnaryOperatorVariable(lambda a: numerix.arccos(a))

@mathMethodDeprecated
def arccosh(self):
return self._UnaryOperatorVariable(lambda a: numerix.arccosh(a))

@mathMethodDeprecated
def arcsin(self):
return self._UnaryOperatorVariable(lambda a: numerix.arcsin(a))

@mathMethodDeprecated
def arcsinh(self):
return self._UnaryOperatorVariable(lambda a: numerix.arcsinh(a))

@mathMethodDeprecated
def sqrt(self):
"""

>>> from fipy.meshes import Grid1D
>>> mesh= Grid1D(nx=3)

>>> from fipy.variables.cellVariable import CellVariable
>>> var = CellVariable(mesh=mesh, value=((0., 2., 3.),), rank=1)
>>> print (var.dot(var)).sqrt()
[ 0. 2. 3.]

"""
return self._UnaryOperatorVariable(lambda a: numerix.sqrt(a))

@mathMethodDeprecated
def tan(self):
return self._UnaryOperatorVariable(lambda a: numerix.tan(a))

@mathMethodDeprecated
def tanh(self):
return self._UnaryOperatorVariable(lambda a: numerix.tanh(a))

@mathMethodDeprecated
def arctan(self):
return self._UnaryOperatorVariable(lambda a: numerix.arctan(a))

@mathMethodDeprecated
def arctanh(self):
return self._UnaryOperatorVariable(lambda a: numerix.arctanh(a))

@mathMethodDeprecated
def exp(self):
return self._UnaryOperatorVariable(lambda a: numerix.exp(a))

@mathMethodDeprecated
def log(self):
return self._UnaryOperatorVariable(lambda a: numerix.log(a))

@mathMethodDeprecated
def log10(self):
return self._UnaryOperatorVariable(lambda a: numerix.log10(a))

@mathMethodDeprecated
def sin(self):
return self._UnaryOperatorVariable(lambda a: numerix.sin(a))

@mathMethodDeprecated
def sinh(self):
return self._UnaryOperatorVariable(lambda a: numerix.sinh(a))

@mathMethodDeprecated
def cos(self):
return self._UnaryOperatorVariable(lambda a: numerix.cos(a))

@mathMethodDeprecated
def cosh(self):
return self._UnaryOperatorVariable(lambda a: numerix.cosh(a))

@mathMethodDeprecated
def floor(self):
return self._UnaryOperatorVariable(lambda a: numerix.floor(a))

@mathMethodDeprecated
def ceil(self):
return self._UnaryOperatorVariable(lambda a: numerix.ceil(a))

@mathMethodDeprecated
def sign(self):
return self._UnaryOperatorVariable(lambda a: numerix.sign(a), canInline=False)

@mathMethodDeprecated
def conjugate(self):
return self._UnaryOperatorVariable(lambda a: numerix.conjugate(a), canInline=False)

@mathMethodDeprecated
def arctan2(self, other):
return self._BinaryOperatorVariable(lambda a,b: numerix.arctan2(a,b), other)

def dot(self, other, opShape=None, operatorClass=None, axis=0):
if not isinstance(other, Variable):
from fipy.variables.constant import _Constant
Expand All @@ -1507,10 +1412,6 @@ def dot(self, other, opShape=None, operatorClass=None, axis=0):
operatorClass=operatorClass,
canInline=False)

@mathMethodDeprecated
def reshape(self, shape):
return self._BinaryOperatorVariable(lambda a,b: numerix.reshape(a,b), shape, opShape=shape, canInline=False)

def ravel(self):
return self.value.ravel()

Expand Down