Skip to content

High-value type hints for Quantity #35

@Yoshanuikabundi

Description

@Yoshanuikabundi

It would be amazing to be able to specify the shape and units of a Quantity[Array] in type hints, does anyone know if that's possible? I know they're both part of the value and not the type but the two concepts are kinda fungible in Python. I vaguely remember that people somewhere somewhen were working on it.

It would be great to have some really high-quality type hints for Quantity. Ideally, we'd be able to express the dimensions of the quantity, as well as the enclosed type. This would allow units to be checked statically, which would be huge. In a perfect world, NumPy would support type hints on arrays that specify their dtype and shape, but maybe if they drag on that we can do something for Quantity[Array]

This all probably requires PEP 646, which is to be implemented in Python 3.11, so won't be safe for us to use for another couple of years unless someone develops a back-port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions