Пример #1
0
    def __call__(self, func):
        # if key errors occur, fail silently
        try:
            self._add_url(func)
            np.add_docstring(func, self.doc)
            return func

        except KeyError:
            return func
Пример #2
0
    def __call__(self, func):
        # if key errors occur, fail silently
        try:
            self._add_url(func)
            np.add_docstring(func, self.doc)
            return func

        except KeyError:
            return func
Пример #3
0
np.can_cast(AR_f8, 1)  # E: incompatible type

np.vdot(AR_M, AR_M)  # E: incompatible type

np.copyto(AR_LIKE_f, AR_f8)  # E: incompatible type

np.putmask(AR_LIKE_f, [True, True, False], 1.5)  # E: incompatible type

np.packbits(AR_f8)  # E: incompatible type
np.packbits(AR_u1, bitorder=">")  # E: incompatible type

np.unpackbits(AR_i8)  # E: incompatible type
np.unpackbits(AR_u1, bitorder=">")  # E: incompatible type

np.shares_memory(1, 1, max_work=i8)  # E: incompatible type
np.may_share_memory(1, 1, max_work=i8)  # E: incompatible type

np.arange(M)  # E: No overload variant
np.arange(stop=10)  # E: No overload variant

np.datetime_data(int)  # E: incompatible type

np.busday_offset("2012", 10)  # E: incompatible type

np.datetime_as_string("2012")  # E: incompatible type

np.compare_chararrays("a", b"a", "==", False)  # E: No overload variant

np.add_docstring(func, None)  # E: incompatible type
Пример #4
0
 def test_add_docstring(self):
     import numpy as np
     foo = lambda: None
     np.add_docstring(foo, "Does a thing")
     assert foo.__doc__ == "Does a thing"
Пример #5
0
# -*- coding: utf-8 -*-
"""
Created on Thu Nov  2 16:07:17 2017

@author: user
"""

from sklearn import tree

features = [[140, 1], [130, 1], [150, 0], [170, 0]]
labels = [0, 0, 1, 1]
clf = tree.DecisionTreeClassifier()
clf = clf.fit(features, labels)

print(clf.predict([[140, 1]]))

import numpy as np

a = np.array([[0, 1, 2, 3, 4], [9, 8, 7, 6, 5]])
a.shape

import numpy as np

a = np.array([[0, 1, 2, 3, 4], [9, 8, 7, 6, 5]])
a.itemsize

b = np.random.shuffle(a)
print(b)

a = np.add_docstring((3, 4), dtype='int32')
Пример #6
0
def yu_ye_wang(shape, **kargs):
    return phantom(shape, yu_ye_wang_parameters, **kargs)


# add docstrings to specific phantoms
common_docstring = '''Generates a %(name)s phantom with a given shape and dtype

    Parameters
    ----------
    shape: 3-tuple of ints
        Shape of the 3d output cube.
    dtype: data-type
        Data type of the output cube.

    Returns
    -------
    cube: ndarray
        3-dimensional phantom.
'''

modified_shepp_logan_docstring = common_docstring % {
    'name': 'Modified Shepp-Logan'
}
shepp_logan_docstring = common_docstring % {'name': 'Shepp-Logan'}
yu_ye_wang_docstring = common_docstring % {'name': 'Yu Ye Wang'}

np.add_docstring(modified_shepp_logan, modified_shepp_logan_docstring)
np.add_docstring(shepp_logan, shepp_logan_docstring)
np.add_docstring(yu_ye_wang, yu_ye_wang_docstring)
Пример #7
0
 def test_add_docstring(self):
     import numpy as np
     foo = lambda: None
     np.add_docstring(foo, "Does a thing")
     assert foo.__doc__ == "Does a thing"
Пример #8
0
    ["2011-01"], "2011-02",
    roll="forward"))  # E: numpy.ndarray[Any, numpy.dtype[numpy.datetime64]]

reveal_type(np.is_busday("2012"))  # E: numpy.bool_
reveal_type(np.is_busday(
    ["2012"]))  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]

reveal_type(np.datetime_as_string(M))  # E: numpy.str_
reveal_type(np.datetime_as_string(
    AR_M))  # E: numpy.ndarray[Any, numpy.dtype[numpy.str_]]

reveal_type(np.compare_chararrays(
    "a", "b", "!=",
    rstrip=False))  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]
reveal_type(np.compare_chararrays(
    b"a", b"a", "==", True))  # E: numpy.ndarray[Any, numpy.dtype[numpy.bool_]]

reveal_type(np.add_docstring(func, "test"))  # E: None

reveal_type(np.nested_iters([AR_i8, AR_i8], [[0], [1]],
                            flags=["c_index"]))  # E: tuple[numpy.nditer]
reveal_type(
    np.nested_iters([AR_i8, AR_i8], [[0], [1]],
                    op_flags=[["readonly",
                               "readonly"]]))  # E: tuple[numpy.nditer]
reveal_type(np.nested_iters([AR_i8, AR_i8], [[0], [1]],
                            op_dtypes=np.int_))  # E: tuple[numpy.nditer]
reveal_type(
    np.nested_iters([AR_i8, AR_i8], [[0], [1]], order="C",
                    casting="no"))  # E: tuple[numpy.nditer]