MCPcopy Create free account
hub / github.com/numpy/numpy / dot

Function dot

numpy/ma/core.py:7843–7922  ·  view source on GitHub ↗

Return the dot product of two arrays. This function is the equivalent of `numpy.dot` that takes masked values into account. Note that `strict` and `out` are in different position than in the method version. In order to maintain compatibility with the corresponding method, it is

(a, b, strict=False, out=None)

Source from the content-addressed store, hash-verified

7841# extras.py. Note that it is not included in __all__, but rather exported
7842# from extras in order to avoid backward compatibility problems.
7843def dot(a, b, strict=False, out=None):
7844 """
7845 Return the dot product of two arrays.
7846
7847 This function is the equivalent of `numpy.dot` that takes masked values
7848 into account. Note that `strict` and `out` are in different position
7849 than in the method version. In order to maintain compatibility with the
7850 corresponding method, it is recommended that the optional arguments be
7851 treated as keyword only. At some point that may be mandatory.
7852
7853 Parameters
7854 ----------
7855 a, b : masked_array_like
7856 Inputs arrays.
7857 strict : bool, optional
7858 Whether masked data are propagated (True) or set to 0 (False) for
7859 the computation. Default is False. Propagating the mask means that
7860 if a masked value appears in a row or column, the whole row or
7861 column is considered masked.
7862 out : masked_array, optional
7863 Output argument. This must have the exact kind that would be returned
7864 if it was not used. In particular, it must have the right type, must be
7865 C-contiguous, and its dtype must be the dtype that would be returned
7866 for `dot(a,b)`. This is a performance feature. Therefore, if these
7867 conditions are not met, an exception is raised, instead of attempting
7868 to be flexible.
7869
7870 .. versionadded:: 1.10.2
7871
7872 See Also
7873 --------
7874 numpy.dot : Equivalent function for ndarrays.
7875
7876 Examples
7877 --------
7878 >>> a = np.ma.array([[1, 2, 3], [4, 5, 6]], mask=[[1, 0, 0], [0, 0, 0]])
7879 >>> b = np.ma.array([[1, 2], [3, 4], [5, 6]], mask=[[1, 0], [0, 0], [0, 0]])
7880 >>> np.ma.dot(a, b)
7881 masked_array(
7882 data=[[21, 26],
7883 [45, 64]],
7884 mask=[[False, False],
7885 [False, False]],
7886 fill_value=999999)
7887 >>> np.ma.dot(a, b, strict=True)
7888 masked_array(
7889 data=[[--, --],
7890 [--, 64]],
7891 mask=[[ True, True],
7892 [ True, False]],
7893 fill_value=999999)
7894
7895 """
7896 if strict is True:
7897 if np.ndim(a) == 0 or np.ndim(b) == 0:
7898 pass
7899 elif b.ndim == 1:
7900 a = _mask_propagate(a, a.ndim - 1)

Callers 15

polyfitFunction · 0.90
multi_dotFunction · 0.90
_multi_dot_threeFunction · 0.90
_multi_dotFunction · 0.90
test_svd_buildMethod · 0.90
dot_generalizedFunction · 0.90
doMethod · 0.90
doMethod · 0.90
doMethod · 0.90
check_qrMethod · 0.90
dotMethod · 0.70
covFunction · 0.70

Calls 8

_mask_propagateFunction · 0.85
getmaskarrayFunction · 0.85
filledFunction · 0.85
get_masked_subclassFunction · 0.85
ndimMethod · 0.80
dotMethod · 0.80
__setmask__Method · 0.80
viewMethod · 0.45

Tested by 9

test_svd_buildMethod · 0.72
dot_generalizedFunction · 0.72
doMethod · 0.72
doMethod · 0.72
doMethod · 0.72
check_qrMethod · 0.72
test_dotMethod · 0.40
test_dot_outMethod · 0.40