numpy / numpy/numtype

Shape-typing and narrower dtypes for `{lin,log,geom}space`

Open
#130 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stubs: Enhancement topic: shape-typing
Dominant language
Python
Stars
79
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Currently,np.linspace(0, 1) is inferred as npt.NDArray[np.floating]. This should be narrowed to np.ndarray[tuple[int], np.dtype[np.float64]].

These three functions live in numpy._core.function_base

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in numpy._core.function_base and inspect the typing for linspace, logspace, and geomspace. Update their inferred return types to use the requested one-dimensional shape and narrower dtype, then verify that the example np.linspace(0, 1) is inferred as np.ndarray[tuple[int], np.dtype[np.float64]].

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.