Skip to content

Commit 4389fa7

Browse files
committed
DOC: AI generated examples for ma.correlate.
I adapted the AI generated examples. I removed the default parameters. First example shows how ma.correlate adds a mask to regular arrays. Second example shows basic usage with defaults. Third example introduces mixed arrays and other options. [skip actions] [skip azp] [skip cirrus] added text
1 parent c21ac10 commit 4389fa7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

numpy/ma/core.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8144,6 +8144,37 @@ def correlate(a, v, mode='valid', propagate_mask=True):
81448144
See Also
81458145
--------
81468146
numpy.correlate : Equivalent function in the top-level NumPy module.
8147+
8148+
Examples
8149+
--------
8150+
Basic correlation:
8151+
8152+
>>> a = np.ma.array([1, 2, 3])
8153+
>>> v = np.ma.array([0, 1, 0])
8154+
>>> np.ma.correlate(a, v, mode='valid')
8155+
masked_array(data=[2],
8156+
mask=[False],
8157+
fill_value=999999)
8158+
8159+
Correlation with masked elements:
8160+
8161+
>>> a = np.ma.array([1, 2, 3], mask=[False, True, False])
8162+
>>> v = np.ma.array([0, 1, 0])
8163+
>>> np.ma.correlate(a, v, mode='valid', propagate_mask=True)
8164+
masked_array(data=[--],
8165+
mask=[ True],
8166+
fill_value=999999,
8167+
dtype=int64)
8168+
8169+
Correlation with different modes and mixed array types:
8170+
8171+
>>> a = np.ma.array([1, 2, 3])
8172+
>>> v = np.ma.array([0, 1, 0])
8173+
>>> np.ma.correlate(a, v, mode='full')
8174+
masked_array(data=[0, 1, 2, 3, 0],
8175+
mask=[False, False, False, False, False],
8176+
fill_value=999999)
8177+
81478178
"""
81488179
return _convolve_or_correlate(np.correlate, a, v, mode, propagate_mask)
81498180

0 commit comments

Comments
 (0)