General key differences ----------------------- Python Conventions ^^^^^^^^^^^^^^^^^^ We make extensive use of NumPy throughout the library so please see their `documentation for MATLAB users `_. 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 ^^^^^^^^^^^^ +-----------------+----------------------+------------------------------------------------------------------------+ | MATLAB name | ``pyttb`` name | Calling convention | +=================+======================+========================================================================+ | ``size`` | ``shape`` | ``X.shape`` | +-----------------+----------------------+------------------------------------------------------------------------+ Methods ^^^^^^^ +-----------------+----------------------+------------------------------------------------------------------------+ | MATLAB name | ``pyttb`` name | Calling convention | +=================+======================+========================================================================+ | ``and`` | ``logical_and`` | ``X.logical_and(Y)`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``disp`` | ``__str__`` | ``X`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``display`` | ``__repr__`` | ``print(X)`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``eq`` | ``__eq__`` | ``X == Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``ge`` | ``__ge__`` | ``X >= Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``gt`` | ``__gt__`` | ``X > Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``ldivide`` | ``__truediv__`` | ``X / Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``le`` | ``__le__`` | ``X <= Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``lt`` | ``__lt__`` | ``X < Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``minus`` | ``__sub__`` | ``X - Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``mldivide`` | ``__truediv__`` | ``X / Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``mrdivide`` | ``__rtruediv__`` | ``X / Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``mtimes`` | ``__rmul__`` | ``a * X`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``ne`` | ``__ne__`` | ``X != Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``not`` | ``logical_not`` | ``X.logical_not(Y)`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``or`` | ``logical_or`` | ``X.logical_or(Y)`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``plus`` | ``__add__`` | ``X + Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``power`` | ``__pow__`` | ``X ** a`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``rdivide`` | ``__rtruediv__`` | ``X / Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``subsasgn`` | ``__setitem__`` | ``X[index] = a`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``subsref`` | ``__getitem__`` | ``X[index]`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``tenfun`` | ``tenfun`` | ``X.tenfun(lambda x: x + 1)`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``times`` | ``__mul__`` | ``X * Y`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``uminus`` | ``__neg__`` | ``-X`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``uplus`` | ``__pos__`` | ``+X`` | +-----------------+----------------------+------------------------------------------------------------------------+ | ``xor`` | ``logical_xor`` | ``X.logical_xor(Y)`` | +-----------------+----------------------+------------------------------------------------------------------------+ MATLAB methods not included in ``pyttb`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - ``datadisp`` - ``isscalar`` - ``transpose`` - ``tocell``