summaryrefslogtreecommitdiff
path: root/numpy/core/arrayprint.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-11-12 23:13:19 -0800
committerGitHub <noreply@github.com>2017-11-12 23:13:19 -0800
commitf81dfcc75483fe7489cc021f92e9fe2c0a5d0fa8 (patch)
treeb25de813cdb5704e5cc64b29d31e677671f3db9f /numpy/core/arrayprint.py
parent6789c257e2f5c1d90b9ca961dd655896c6fa9ea5 (diff)
parentdd84fc077eed7d7ac4bbc6c79d5acf3d111d21a0 (diff)
downloadnumpy-f81dfcc75483fe7489cc021f92e9fe2c0a5d0fa8.tar.gz
Merge pull request #10008 from ahaldane/dragon4_fixups
MAINT: Backcompat fixes for dragon4 changes
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r--numpy/core/arrayprint.py46
1 files changed, 43 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 21872461e..da173625e 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -305,8 +305,12 @@ def _get_formatdict(data, **opt):
'int': lambda: IntegerFormat(data),
'float': lambda:
FloatingFormat(data, prec, fmode, supp, sign, legacy=legacy),
+ 'longfloat': lambda:
+ FloatingFormat(data, prec, fmode, supp, sign, legacy=legacy),
'complexfloat': lambda:
ComplexFloatingFormat(data, prec, fmode, supp, sign, legacy=legacy),
+ 'longcomplexfloat': lambda:
+ ComplexFloatingFormat(data, prec, fmode, supp, sign, legacy=legacy),
'datetime': lambda: DatetimeFormat(data),
'timedelta': lambda: TimedeltaFormat(data),
'object': lambda: _object_format,
@@ -329,7 +333,7 @@ def _get_formatdict(data, **opt):
for key in ['int']:
formatdict[key] = indirect(formatter['int_kind'])
if 'float_kind' in fkeys:
- for key in ['half', 'float', 'longfloat']:
+ for key in ['float', 'longfloat']:
formatdict[key] = indirect(formatter['float_kind'])
if 'complex_kind' in fkeys:
for key in ['complexfloat', 'longcomplexfloat']:
@@ -361,9 +365,15 @@ def _get_format_function(data, **options):
else:
return formatdict['int']()
elif issubclass(dtypeobj, _nt.floating):
- return formatdict['float']()
+ if issubclass(dtypeobj, _nt.longfloat):
+ return formatdict['longfloat']()
+ else:
+ return formatdict['float']()
elif issubclass(dtypeobj, _nt.complexfloating):
- return formatdict['complexfloat']()
+ if issubclass(dtypeobj, _nt.clongfloat):
+ return formatdict['longcomplexfloat']()
+ else:
+ return formatdict['complexfloat']()
elif issubclass(dtypeobj, (_nt.unicode_, _nt.string_)):
return formatdict['numpystr']()
elif issubclass(dtypeobj, _nt.datetime64):
@@ -805,6 +815,20 @@ class FloatingFormat(object):
pad_left=self.pad_left,
pad_right=self.pad_right)
+# for back-compatibility, we keep the classes for each float type too
+class FloatFormat(FloatingFormat):
+ def __init__(self, *args, **kwargs):
+ warnings.warn("FloatFormat has been replaced by FloatingFormat",
+ DeprecationWarning, stacklevel=2)
+ super(FloatFormat, self).__init__(*args, **kwargs)
+
+
+class LongFloatFormat(FloatingFormat):
+ def __init__(self, *args, **kwargs):
+ warnings.warn("LongFloatFormat has been replaced by FloatingFormat",
+ DeprecationWarning, stacklevel=2)
+ super(LongFloatFormat, self).__init__(*args, **kwargs)
+
def format_float_scientific(x, precision=None, unique=True, trim='k',
sign=False, pad_left=None, exp_digits=None):
@@ -996,6 +1020,22 @@ class ComplexFloatingFormat(object):
i = self.imag_format(x.imag)
return r + i + 'j'
+# for back-compatibility, we keep the classes for each complex type too
+class ComplexFormat(ComplexFloatingFormat):
+ def __init__(self, *args, **kwargs):
+ warnings.warn(
+ "ComplexFormat has been replaced by ComplexFloatingFormat",
+ DeprecationWarning, stacklevel=2)
+ super(ComplexFormat, self).__init__(*args, **kwargs)
+
+class LongComplexFormat(ComplexFloatingFormat):
+ def __init__(self, *args, **kwargs):
+ warnings.warn(
+ "LongComplexFormat has been replaced by ComplexFloatingFormat",
+ DeprecationWarning, stacklevel=2)
+ super(LongComplexFormat, self).__init__(*args, **kwargs)
+
+
class DatetimeFormat(object):
def __init__(self, x, unit=None, timezone=None, casting='same_kind'):
# Get the unit from the dtype