Skip to main content

Python Tensor Toolbox

Project description

Copyright 2025 National Technology & Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
U.S. Government retains certain rights in this software.

Regression tests Coverage Status pypi package image Ruff Code style: black

pyttb: Python Tensor Toolbox

Welcome to pyttb, a refactor of the Tensor Toolbox for MATLAB in Python.

This package contains data classes and methods for manipulating dense, sparse, and structured tensors, along with algorithms for computing low-rank tensor decompositions:

Quick Start

Installation

python3 -m pip install pyttb

Example

>>> import pyttb as ttb
>>> X = ttb.tenrand((2,2,2))
>>> type(X)
<class 'pyttb.tensor.tensor'>
>>> M = ttb.cp_als(X, rank=1)
CP_ALS:
 Iter 0: f = 7.367245e-01 f-delta = 7.4e-01
 Iter 1: f = 7.503069e-01 f-delta = 1.4e-02
 Iter 2: f = 7.508240e-01 f-delta = 5.2e-04
 Iter 3: f = 7.508253e-01 f-delta = 1.3e-06
 Final f = 7.508253e-01

Memory layout

For historical reasons we use Fortran memory layouts, where numpy by default uses C. This is relevant for indexing. In the future we hope to extend support for both.

>>> import numpy as np
>>> c_order = np.arange(8).reshape((2,2,2))
>>> f_order = np.arange(8).reshape((2,2,2), order="F")
>>> print(c_order[0,1,1])
3
>>> print(f_order[0,1,1])
6

Getting Help

Contributing

Citing pyttb in your work

If you use pyttb in your work, please cite it using the citation info here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyttb-1.8.5.tar.gz (189.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyttb-1.8.5-py3-none-any.whl (153.8 kB view details)

Uploaded Python 3

File details

Details for the file pyttb-1.8.5.tar.gz.

File metadata

  • Download URL: pyttb-1.8.5.tar.gz
  • Upload date:
  • Size: 189.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyttb-1.8.5.tar.gz
Algorithm Hash digest
SHA256 0a3f35489014ccfb98c424519d66c539241e2eb9c4bd3c3811aa87ae8e9319e5
MD5 766c650adba541769b40b5f83215f291
BLAKE2b-256 38ed0e68c6887da6422cbde358ce68f1c621e26fb8c0aa76aa3d6cdd574594cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyttb-1.8.5.tar.gz:

Publisher: python-publish.yml on sandialabs/pyttb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyttb-1.8.5-py3-none-any.whl.

File metadata

  • Download URL: pyttb-1.8.5-py3-none-any.whl
  • Upload date:
  • Size: 153.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyttb-1.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 617312f28d48e07a8ca7c5d36a2ea5a86d607f7c84767d958aae5cb583e9e341
MD5 20b8d7374ebf9c14ce478a506664671e
BLAKE2b-256 d5a7ffd271f7f5baf3beb42c42e43ea0fc5aa104ceeafffcd5cbfd73a78a4910

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyttb-1.8.5-py3-none-any.whl:

Publisher: python-publish.yml on sandialabs/pyttb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page