ENH: check dim in _FilterInt

This commit is contained in:
Yan Facai (颜发才) 2017-08-26 06:33:27 +08:00 committed by Martin Wicke
parent 200dc87de3
commit 52e43b4fcd
2 changed files with 4 additions and 3 deletions

View File

@ -236,7 +236,9 @@ def _FilterTuple(v):
def _FilterInt(v):
if isinstance(v, (list, tuple)):
return _FirstNotNone([_FilterInt(x) for x in v])
return None if isinstance(v, compat.integral_types) else _NotNone(v)
return None if isinstance(
v,
compat.integral_types, tensor_shape.Dimension) else _NotNone(v)
def _FilterFloat(v):

View File

@ -40,7 +40,6 @@ import numbers as _numbers
import numpy as _np
import six as _six
from tensorflow.python.framework import tensor_shape
from tensorflow.python.util.all_util import remove_undocumented
@ -111,7 +110,7 @@ def as_str_any(value):
# Numpy 1.8 scalars don't inherit from numbers.Integral in Python 3, so we
# need to check them specifically. The same goes from Real and Complex.
integral_types = (_numbers.Integral, _np.integer, tensor_shape.Dimension)
integral_types = (_numbers.Integral, _np.integer)
real_types = (_numbers.Real, _np.integer, _np.floating)
complex_types = (_numbers.Complex, _np.number)