8000 DOC: AI generated examples for ma.correlate. by otieno-juma · Pull Request #26831 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: AI generated examples for ma.correlate. #26831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
  • Loading branch information
otieno-juma committed Jul 2, 2024
commit 4389fa70333d8f67f01acac26e5c9c40268badd2
31 changes: 31 additions & 0 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8144,6 +8144,37 @@ def correlate(a, v, mode='valid', propagate_mask=True):
See Also
--------
numpy.correlate : Equivalent function in the top-level NumPy module.

Examples
--------
Basic correlation:

>>> a = np.ma.array([1, 2, 3])
>>> v = np.ma.array([0, 1, 0])
>>> np.ma.correlate(a, v, mode='valid')
masked_array(data=[2],
mask=[False],
fill_value=999999)

Correlation with masked elements:

>>> a = np.ma.array([1, 2, 3], mask=[False, True, False])
>>> v = np.ma.array([0, 1, 0])
>>> np.ma.correlate(a, v, mode='valid', propagate_mask=True)
masked_array(data=[--],
mask=[ True],
fill_value=999999,
dtype=int64)

Correlation with different modes and mixed array types:

>>> a = np.ma.array([1, 2, 3])
>>> v = np.ma.array([0, 1, 0])
>>> np.ma.correlate(a, v, mode='full')
masked_array(data=[0, 1, 2, 3, 0],
mask=[False, False, False, False, False],
fill_value=999999)

"""
return _convolve_or_correlate(np.correlate, a, v, mode, propagate_mask)

Expand Down
Loading
0