Metadata-Version: 2.5
Name: pyrefly-einops-stubs
Version: 1.5.0
Summary: Einops type stubs with tensor-shape tracking, maintained by Pyrefly
Project-URL: homepage, https://pyrefly.org
Project-URL: documentation, https://pyrefly.org/en/docs/
License: MIT License
        
        Copyright (c) Meta Platforms, Inc. and affiliates.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: einops,stubs,typechecker,typechecking
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Stubs Only
Requires-Python: >=3.12
Requires-Dist: pyrefly-shape-extensions==1.5.0
Provides-Extra: jax
Requires-Dist: jax-pyrefly-stubs==1.5.0; extra == 'jax'
Provides-Extra: numpy
Requires-Dist: pyrefly-numpy-stubs==1.5.0; extra == 'numpy'
Provides-Extra: torch
Requires-Dist: pyrefly-torch-stubs==1.5.0; extra == 'torch'
Description-Content-Type: text/markdown

# Pyrefly einops shape stubs

This package installs `einops-shape-stubs`, a Pyrefly-specific stub package for
runtime `einops`. Pyrefly discovers it by default; set
`use-shape-comments-and-stubs = false` to opt out. Other type checkers ignore these
stubs and continue using einops's ordinary types.

It provides shape-aware annotations for `rearrange`, `reduce`, `repeat`, and
`einsum` using Pyrefly's type-level shape DSL. The `einops.layers.torch` `Rearrange` and `Reduce`
modules preserve the constructor pattern and axis lengths across calls.

The precise annotations target PyTorch, NumPy, and JAX. Shape computations are
shared; backend overloads describe their different result types. NumPy `rearrange`
and `repeat` preserve `ndarray` and its dtype. NumPy reductions and `einsum` may
return array scalars, so their result protocol preserves shape and array conversion
without promising `ndarray` or a dtype that reductions may promote. The precise
NumPy reduction and `einsum` overloads cover numeric and boolean dtypes; object-dtype
operations can return arbitrary Python objects and use the gradual fallback.

Backend shape stubs are optional dependencies: install the `torch`, `numpy`, or
`jax` extra, or combine them as `[torch,numpy,jax]`. The base package does not
install an array library. Install matching shape stubs for each of these backends
present in your environment. Existing Torch users upgrading from the base package
must add `[torch]` to retain Torch shape stubs.

Shape precision with optional backends requires Pyrefly's missing-import overload
preference. It favors resolved input contracts without adding call warnings,
while preserving return-only recovery and ordinary ambiguity for gradual arguments.
Do not configure `replace-imports-with-any` or `ignore-missing-imports` for absent
backends: those settings erase the provenance of unavailable annotations.

Literal `axes_lengths` keyword arguments are carried into the shape rules, so named
input splits and repeated output axes remain tracked. Dynamically unpacked mappings
preserve the known rank but use gradual dimensions for unknown axis lengths.

Run the static tests with:

```bash
python3 tensor-shapes/pyrefly-einops-stubs/run_pyrefly.py --buck
python3 tensor-shapes/pyrefly-einops-stubs/run_optional_backends.py --pyrefly /path/to/pyrefly
```
