jax_and_decorators

A detailed reference for decorators, NumPy and JAX backends, and custom array types in the PyAutoGalaxy and PyAutoLens codebases. JAX is a Python library for numerical computing and automatic differentiation.

In plain words
What is it for?
Understanding grid decorators, choosing between NumPy and JAX behavior, and handling custom array types across JAX's compiled-function boundary.
Why use it?
It keeps the detailed rules for these systems in one place, so repository instructions can stay shorter while linking to the full explanation.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/pyautolabs/pyautoarray/jax_and_decorators
Clone the repo
git clone --depth 1 https://github.com/PyAutoLabs/PyAutoArray
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,124 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.03124
Opus 5 $0.00000 $0.01562
Sonnet 5 $0.00000 $0.00625
Haiku 4.5 $0.00000 $0.00312

Measured 2d ago against content hash 3480ae24b144, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

jax_and_decorators scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/agents/jax_and_decorators.md · 270 lines

How it starts

The opening of the file, as written. The whole thing — 270 lines — stays where its author put it; the contents beside it link to each section on GitHub.

JAX & the decorator system — deep dive

Long-form reference for the grid decorators, the xp (NumPy/JAX) backend pattern, and how autoarray types cross the jax.jit boundary. The per-repo AGENTS.md files keep only a short summary and link here. This is the single canonical source for the detail — PyAutoGalaxy and PyAutoLens point at it rather than re-explaining.

Everything below is grounded in the installed source under autoarray/, autogalaxy/, and autolens/. Where a class or function is named, it exists in the current tree.


1. The decorator system

autoarray/structures/decorators/ contains the output-wrapping decorators used on all grid-consuming functions. They ensure the type of the output structure matches the type of the input grid.

Import them as aa.decorators.*. (aa.grid_dec still resolves as a deprecated aliasautoarray/__init__.py defines from .structures import decorators as grid_dec # deprecated alias — but every shipped profile uses aa.decorators.*, so write that form.)

Decorator Grid2D input → Grid2DIrregular input →
@aa.decorators.to_array Array2D ArrayIrregular
@aa.decorators.to_grid Grid2D Grid2DIrregular
@aa.decorators.to_vector_yx VectorYX2D VectorYX2DIrregular

How they work

All three share AbstractMaker (decorators/abstract.py). The decorator:

  1. Wraps the function in a wrapper(obj, grid, xp=np, *args, **kwargs) signature.
  2. Instantiates the relevant *Maker class with the function, object, grid, and xp.
  3. AbstractMaker.result checks the grid type and calls the appropriate via_grid_2d / via_grid_2d_irr method to wrap the raw result.

The function body receives the grid as-is and must return a raw array (not an autoarray wrapper). The decorator does the wrapping:

@aa.decorators.to_array
def convergence_2d_from(self, grid, xp=np, **kwargs):
    # grid is Grid2D or Grid2DIrregular — access raw values via grid.array[:, 0]
    y = grid.array[:, 0]
    x = grid.array[:, 1]
    return xp.sqrt(y**2 + x**2)   # return raw array; decorator wraps it

Read the full file on GitHub · 270 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 270 lines · 0 tokens per session scan A 3480ae24b144

Subscribe to this mod's changes

jax_and_decorators is an agent published in the GitHub repository PyAutoLabs/PyAutoArray (10 stars, last pushed 3d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,124 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories