Skip to content

Commit

Permalink
add truedivide and floordivide to MV2
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadeau4 committed Nov 15, 2017
1 parent a8eeeff commit 37b531e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Lib/MV2.py
Expand Up @@ -289,6 +289,8 @@ def compress(a, b):
subtract = var_binary_operation(numpy.ma.subtract)
multiply = var_binary_operation(numpy.ma.multiply)
divide = var_binary_operation(numpy.ma.divide)
true_divide = var_binary_operation(numpy.ma.true_divide)
floor_divide = var_binary_operation(numpy.ma.floor_divide)
equal = var_binary_operation(numpy.ma.equal)
less_equal = var_binary_operation(numpy.ma.less_equal)
greater_equal = var_binary_operation(numpy.ma.greater_equal)
Expand Down Expand Up @@ -390,6 +392,7 @@ def set_print_limit(limit=numpy.inf):
all = alltrue
logical_not = var_unary_operation(numpy.ma.logical_not)
divide.reduce = None
true_divide.reduce = None
remainder = var_binary_operation(numpy.ma.remainder)
remainder.reduce = None
fmod = var_binary_operation(numpy.ma.fmod)
Expand Down
6 changes: 6 additions & 0 deletions Lib/avariable.py
Expand Up @@ -1544,6 +1544,12 @@ def __mul__(self, other):

__rmul__ = __mul__

def __floordiv__(self, other):
return MV.floor_divide(self, other)

def __truediv__(self, other):
return MV.true_divide(self, other)

def __div__(self, other):
return MV.divide(self, other)

Expand Down
2 changes: 1 addition & 1 deletion Lib/dataset.py
Expand Up @@ -2196,7 +2196,7 @@ def getBoundsAxis(self, n, boundid=None):

def __repr__(self):
filerep = repr(self._file_)
loc = string.find(filerep, "file")
loc = filerep.find("file")
if loc == -1:
loc = 0
return "<CDMS " + filerep[loc:-1] + ", status: %s>" % self._status_
Expand Down
5 changes: 2 additions & 3 deletions Lib/grid.py
Expand Up @@ -5,9 +5,8 @@
import re
from .error import CDMSError
import numpy # , PropertiedClasses, internattr
# import regrid2._regrid
import regrid2._regrid
import copy
import string
import sys
from .cdmsobj import CdmsObj
from .axis import TransientAxis, createAxis, createUniformLatitudeAxis
Expand Down Expand Up @@ -195,7 +194,7 @@ def listall(self, all=None):
return result

def __str__(self):
return string.join(self.listall(), "\n") + "\n"
return "\n".join(self.listall())

__repr__ = __str__

Expand Down
2 changes: 2 additions & 0 deletions Lib/tvariable.py
Expand Up @@ -135,6 +135,8 @@ def __copy__(self):
__rsub__ = AbstractVariable.__rsub__
__isub__ = AbstractVariable.__isub__
__div__ = AbstractVariable.__div__
__truediv__ = AbstractVariable.__truediv__
__floordiv__ = AbstractVariable.__floordiv__
__rdiv__ = AbstractVariable.__rdiv__
__idiv__ = AbstractVariable.__idiv__
__pow__ = AbstractVariable.__pow__
Expand Down

0 comments on commit 37b531e

Please sign in to comment.