Metadata-Version: 2.4
Name: xact-py
Version: 0.7.2
Summary: Python wrapper for XAct.jl — tensor algebra for general relativity
Project-URL: Homepage, https://github.com/sashakile/XAct.jl
Project-URL: Repository, https://github.com/sashakile/XAct.jl
Project-URL: Documentation, https://saxa.xyz/XAct.jl
Project-URL: Changelog, https://github.com/sashakile/XAct.jl/releases
Author-email: sashakile <saxa.kile@gmail.com>
License-Expression: GPL-3.0-or-later
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Requires-Dist: juliacall>=0.9.31
Requires-Dist: juliapkg>=0.1.14
Provides-Extra: translate
Description-Content-Type: text/markdown

# xact-py

[![PyPI](https://img.shields.io/pypi/v/xact-py)](https://pypi.org/project/xact-py/)
[![Build Status](https://github.com/sashakile/XAct.jl/actions/workflows/test.yml/badge.svg)](https://github.com/sashakile/XAct.jl/actions/workflows/test.yml)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Python wrapper for [XAct.jl](https://github.com/sashakile/XAct.jl) — a native Julia port of the Wolfram [xAct](http://xact.es/) tensor algebra library for general relativity.

> **Note:** All code in this repository is generated by AI. It was built under strict engineering practices but is not warranted to be absolutely correct. See the [full disclaimer](https://github.com/sashakile/XAct.jl#ai-attribution).

## Installation

Install the latest published release from PyPI:

```bash
pip install xact-py
```

On first import, `xact-py` resolves the Julia package `XAct` from the Julia registries via `juliapkg`/`juliacall`.

If you need unreleased changes from this repository, install from a local checkout in editable mode and point `juliapkg` at a shared Julia project that develops the local `XAct.jl` checkout:

```bash
git clone https://github.com/sashakile/XAct.jl.git
cd XAct.jl
uv pip install -e packages/xact-py
export PYTHON_JULIAPKG_PROJECT="$PWD/.juliapkg-xact"
julia --project="$PYTHON_JULIAPKG_PROJECT" -e 'using Pkg; Pkg.develop(path=pwd()); Pkg.instantiate()'
```

Julia is managed automatically via [juliacall](https://github.com/JuliaPy/PythonCall.jl).

## Quick Start

```python
import xact

xact.reset()
M = xact.Manifold("M", 4, ["a", "b", "c", "d"])
T = xact.Tensor("T", ["-a", "-b"], M, symmetry="Symmetric[{-a,-b}]")
xact.canonicalize("T[-b,-a] - T[-a,-b]")  # returns "0"
```

## Features

- **Canonicalization** — Butler-Portugal algorithm for tensor index canonicalization
- **Contraction & Simplification** — metric contraction, iterative simplification
- **Covariant Derivatives** — commutation, sorting, Riemann identities
- **Perturbation Theory** — multinomial Leibniz expansion, curvature perturbations
- **Coordinate Components (xCoba)** — basis changes, Christoffel symbols, CTensor
- **Riemann Invariants (xInvar)** — classification and database of Riemann polynomial invariants
- **Variational Calculus** — Euler-Lagrange operator, integration by parts

## Example: Metric and Curvature

```python
import xact

xact.reset()
M = xact.Manifold("M", 4, ["a", "b", "c", "d", "e", "f"])
g = xact.Metric("g", ["-a", "-b"], M)

# Riemann symmetry: R_abcd + R_abdc = 0
xact.canonicalize("RiemannCD[-a,-b,-c,-d] + RiemannCD[-a,-b,-d,-c]")
# returns "0"

# Simplify a contracted Riemann expression
xact.simplify("RicciCD[-a,-b] - RiemannCD[-a,-c,-b,-d] * g[c,d]")
# returns "0"
```

## Documentation

Full documentation at [saxa.xyz/XAct.jl](https://saxa.xyz/XAct.jl).

## License

GPL-3.0 — see [LICENSE](https://github.com/sashakile/XAct.jl/blob/main/LICENSE).
