Skip to content

Commit

Permalink
Start adding some more details to the coming from matlab docs (#352)
Browse files Browse the repository at this point in the history
* Start adding some more details to the coming from matlab docs

* MATLAB: Move the copying details to the top of the doc
* This is a python detail so prefer referring outwards for more details.

* DOCS: Generate docs for the pyttb_utils. They are mostly internal but it couldn't hurt to have them visible on the web hosted docs.

---------

Co-authored-by: Danny Dunlavy <[email protected]>
  • Loading branch information
ntjohnson1 and dmdunla authored Dec 13, 2024
1 parent 605dd28 commit ab5ac5c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ algorithms for computing low-rank tensor models.

pyttb supports multiple tensor types, including
dense and sparse, as well as specially structured tensors, such as
the Krusal format (stored as factor matrices).
the Kruskal format (stored as factor matrices).

- `Algorithms`_

Expand Down
24 changes: 16 additions & 8 deletions docs/source/matlab/common.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
General key differences
-----------------------

Python Conventions
^^^^^^^^^^^^^^^^^^
We make extensive use of NumPy throughout the library so please see their
`documentation for MATLAB users <https://numpy.org/doc/stable/user/numpy-for-matlab-users.html>`_.
Otherwise some highlights are:

* 0-indexing in python vs 1-indexing in MATLAB

Copying
^^^^^^^^^^^^^^^^^^^^
Copying a ``pyttb`` tensor works differently than MATLAB. For example in MATLAB, copying a tensor ``Y``
as ``Y = X`` returns a tensor ``Y`` that is independent of ``X``. Changing the value of ``Y`` does not
change the value of ``X``. However, the same syntax in ``pyttb``, ``Y = X``, returns a *shallow copy* of ``X``;
the shallow copy ``Y`` is a *reference* to ``X``. For that reason, each ``pyttb`` tensor class provides a ``copy()``
method that returns a *deep copy* ``Y`` that is independent of ``X``, which is called as ``Y = X.copy()``.

Data members
^^^^^^^^^^^^
+-----------------+----------------------+------------------------------------------------------------------------+
Expand Down Expand Up @@ -67,14 +83,6 @@ Methods
| ``xor`` | ``logical_xor`` | ``X.logical_xor(Y)`` |
+-----------------+----------------------+------------------------------------------------------------------------+

Copying
^^^^^^^^^^^^^^^^^^^^
Copying a ``pyttb`` tensor works differently than MATLAB. For example in MATLAB, copying a tensor ``Y``
as ``Y = X`` returns a tensor ``Y`` that is independent of ``X``. Changing the value of ``Y`` does not
change the value of ``X``. However, the same syntax in ``pyttb``, ``Y = X``, returns a *shallow copy* of ``X``;
the shallow copy ``Y`` is a *reference* to ``X``. For that reason, each ``pyttb`` tensor class provides a ``copy()``
method that returns a *deep copy* ``Y`` that is independent of ``X``, which is called as ``Y = X.copy()``.

MATLAB methods not included in ``pyttb``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- ``datadisp``
Expand Down
8 changes: 8 additions & 0 deletions docs/source/pyttb_utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pyttb.pyttb_utils
--------------------

.. automodule:: pyttb.pyttb_utils
:members:
:special-members:
:exclude-members: __dict__, __weakref__, __slots__, __init__
:show-inheritance:
1 change: 1 addition & 0 deletions docs/source/tensor_classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Tensor Classes
tensor.rst
ttensor.rst
tenmat.rst
pyttb_utils.rst

0 comments on commit ab5ac5c

Please sign in to comment.