Python numpy.issctype() Examples

The following are 7 code examples of numpy.issctype(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: test_numerictypes.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_issctype(rep, expected):
    # ensure proper identification of scalar
    # data-types by issctype()
    actual = np.issctype(rep)
    assert_equal(actual, expected) 
Example #2
Source File: test_numerictypes.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def test_issctype(rep, expected):
    # ensure proper identification of scalar
    # data-types by issctype()
    actual = np.issctype(rep)
    assert_equal(actual, expected) 
Example #3
Source File: test_numerictypes.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_issctype(rep, expected):
    # ensure proper identification of scalar
    # data-types by issctype()
    actual = np.issctype(rep)
    assert_equal(actual, expected) 
Example #4
Source File: symbolic.py    From coremltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def num_symbolic(val):
    """
    Return the number of symbols in val
    """
    if is_symbolic(val):
        return 1
    elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
        return 0
    elif hasattr(val, "__iter__"):
        return sum(any_symbolic(i) for i in val)
    return 0 
Example #5
Source File: symbolic.py    From coremltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def any_symbolic(val):
    if is_symbolic(val):
        return True
    if isinstance(val, np.ndarray) and val.ndim == 0:
        return is_symbolic(val[()])
    elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
        return False
    elif isinstance(val, six.string_types):  # string is iterable
        return False
    elif hasattr(val, "__iter__"):
        return any(any_symbolic(i) for i in val)
    return False 
Example #6
Source File: symbolic.py    From coremltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def any_variadic(val):
    if is_variadic(val):
        return True
    elif isinstance(val, np.ndarray) and np.issctype(val.dtype):
        return False
    elif isinstance(val, six.string_types):  # string is iterable
        return False
    elif hasattr(val, "__iter__"):
        return any(any_variadic(i) for i in val)
    return False 
Example #7
Source File: test_numerictypes.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_issctype(rep, expected):
    # ensure proper identification of scalar
    # data-types by issctype()
    actual = np.issctype(rep)
    assert_equal(actual, expected)