Skip to content

ENH: add dtype parameter for append() - #33165

Open
mhafizazh wants to merge 3 commits into
numpy:mainfrom
mhafizazh:fix-append-dtype
Open

mhafizazh wants to merge 3 commits into
numpy:mainfrom
mhafizazh:fix-append-dtype

Conversation

@mhafizazh

Copy link
Copy Markdown
Contributor

PR summary

This PR is continuing this closed PR #22429. Solving issue #22427 and #25640.

Before

import numpy as np

a = np.array([1, 2], dtype=np.float32)
print(a.dtype) # prints float32
b = np.append(a, 42)
print(b.dtype) # prints float64

After adding dtype argument

a = np.array([1, 2], dtype=np.float32)
print(a.dtype) # prints float32
b = np.append(a, 42, dtpye=np.float32)
print(b.dtype) # prints float32

I'm interested working on this PR because I did solved array type issue previously (#32555) and want to keep working on open source project. This will help me and other users have exact type for their array when using append().

I'm aware there are lot of discussion in other PR about append() method. My current implementation just continuing the closed unmerged PR. I'm open with new suggestion how the new append() should be written for future release (even totally different approach).

AI Disclosure

I use Opencode to understand the repository and create initial draft. I rewrite the code and test it manually.

@mhafizazh mhafizazh changed the title add dtype parameter for append() ENH: add dtype parameter for append() Oct 28, 2026
@ngoldbaum

Copy link
Copy Markdown
Member

I think this is probably fine?

It needs a release note though.

@mhafizazh

Copy link
Copy Markdown
Contributor Author

I think this is probably fine?

It needs a release note though.

will add release note

@ngoldbaum ngoldbaum added this to the 2.6.0 Release milestone Nov 3, 2026
@ngoldbaum ngoldbaum added the triage review Issue/PR to be discussed at the next triage meeting label Nov 3, 2026
@ngoldbaum

Copy link
Copy Markdown
Member

I milestoned and marked this to be reviewed at a triage meeting. I'm not sure if the mailing list was ever pinged for this, but API changes should generally follow a mailing list discussion about it.

Otherwise this looks fine to me and I think it does make sense to simply pass the argument to concatenate. However changing the NumPy API is a high bar and requires building consensus on the change.

@mhafizazh

Copy link
Copy Markdown
Contributor Author

Yep. It does make sense. It seems the next triage meeting will be next week. I might able to attend the meeting too.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage review Issue/PR to be discussed at the next triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants