Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/source/tensor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ Dense Tensor (:class:`tensor`)

Classes and functions defined in ``tensor.py`` have been promoted to the ``pyttb`` namespace.

.. autoclass:: pyttb.tensor
For *all* examples in this document, the following module imports are assumed::

>>> import pyttb as ttb
>>> import numpy as np

.. automodule:: pyttb.tensor
:members:
:special-members:
:exclude-members: __dict__, __weakref__, __slots__
Expand Down
44 changes: 25 additions & 19 deletions pyttb/tensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Classes and functions for working with dense tensors."""
"""Classes and functions for dense tensors (hidden module)."""

# Copyright 2025 National Technology & Engineering Solutions of Sandia,
# LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
Expand Down Expand Up @@ -52,25 +52,31 @@


class tensor:
"""
TENSOR Class for dense tensors.

Contains the following data members:

``data``: :class:`numpy.ndarray` dense array containing the data elements
of the tensor.

Instances of :class:`pyttb.tensor` can be created using `__init__()` or
the following method:

* :meth:`from_function`
"""Class for dense tensors.

Examples
--------
For all examples listed below, the following module imports are assumed:

>>> import pyttb as ttb
>>> import numpy as np
Attributes
----------
data : numpy.ndarray
Data of the tensor
shape : tuple of integers
Size of the tensor

Instances of :class:`pyttb.tensor` can be created using :meth:`__init__`
or the following methods:

* :meth:`from_function` - Create a tensor from a function
* :meth:`copy` - Make a deep copy of a tensor
* :func:`tenones` - Create an all ones tensor of a specified size
* :func:`tenzeros` - Create an all zeros tensor of a specified size
* :func:`tenrand` - Create a random tensor of a specified size
* :func:`tendiag` - Create a tensor with a specified diagonal
* :func:`teneye` - Create an identity tensor
* :meth:`pyttb.sptensor.to_tensor` - Convert a sparse tensor to a dense tensor
* :meth:`pyttb.ktensor.to_tensor` - Convert a Kruskal tensor to a dense tensor
* :meth:`pyttb.ttensor.to_tensor` - Convert a Tucker tensor to a dense tensor
* :meth:`pyttb.tenmat.to_tensor` - Convert a tenmat to a dense tensor

See :doc:`/tutorial/class_tensor` for getting started with the tensor class.
"""

__slots__ = ("data", "shape")
Expand Down
Loading