patrick-kidger / patrick-kidger/jaxtyping

Can dtypes of later arguments be annotated to follow the dtypes of earlier arguments?

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

Nobody has claimed this yet.

question
Dominant language
Python
Stars
1.9k
Forks
96
PR merge metrics
No merged PRs in 30d

Description

Consider the function

def fill_array(array: Shaped[Array, "N"], fill_value: Any) -> Shaped[Array, "N"]:
    return jnp.full_like(array, fill_value)

In principle, the dtypes of fill_value and the return value should be constrained to be same as that of the input array. E.g., if I pass in an array of Integers, I should not specify a Float as the fill_value. Is it possible to annotate this constraint?

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

The issue names the fill_array example and jnp.full_like, but no repository files or tests. Start by tracing how jaxtyping expresses array dtypes and whether annotations can relate fill_value and the return value to the input array. Done means establishing whether this constraint is supported and, if so, adding the corresponding implementation and coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.