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

Skip to content

DOC: AI generated examples for ma.reshape #26830

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 22, 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.reshape
I used AI Llama 3 to help create these.
@bmwoodruff and I reviewed them.
[skip azp] [skip cirrus]
  • Loading branch information
otieno-juma committed Jul 21, 2024
commit 267e44c80ed8cb54a337668be1da53ac3677b27b
31 changes: 31 additions & 0 deletions numpy/ma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7506,6 +7506,37 @@ def reshape(a, new_shape, order='C'):
--------
MaskedArray.reshape : equivalent function

Examples
--------
Reshaping a 1-D array:

>>> a = np.ma.array([1, 2, 3, 4])
>>> np.ma.reshape(a, (2, 2))
masked_array(
data=[[1, 2],
[3, 4]],
mask=False,
fill_value=999999)

Reshaping a 2-D array:

>>> b = np.ma.array([[1, 2], [3, 4]])
>>> np.ma.reshape(b, (1, 4))
masked_array(data=[[1, 2, 3, 4]],
mask=False,
fill_value=999999)

Reshaping a 1-D array with a mask:

>>> c = np.ma.array([1, 2, 3, 4], mask=[False, True, False, False])
>>> np.ma.reshape(c, (2, 2))
masked_array(
data=[[1, --],
[3, 4]],
mask=[[False, True],
[False, False]],
fill_value=999999)

"""
# We can't use 'frommethod', it whine about some parameters. Dmmit.
try:
Expand Down
Loading
0