![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/local/lib/python3.6/dist-packages/sympy/tensor/tests/ |
Upload File : |
from sympy.tensor.tensor import (Tensor, TensorIndexType, TensorSymmetry, tensor_indices, TensorHead, TensorElement) from sympy.tensor import Array from sympy import Symbol def test_tensor_element(): L = TensorIndexType("L") i, j, k, l, m, n = tensor_indices("i j k l m n", L) A = TensorHead("A", [L, L], TensorSymmetry.no_symmetry(2)) a = A(i, j) assert isinstance(TensorElement(a, {}), Tensor) assert isinstance(TensorElement(a, {k: 1}), Tensor) te1 = TensorElement(a, {Symbol("i"): 1}) assert te1.free == [(j, 0)] assert te1.get_free_indices() == [j] assert te1.dum == [] te2 = TensorElement(a, {i: 1}) assert te2.free == [(j, 0)] assert te2.get_free_indices() == [j] assert te2.dum == [] assert te1 == te2 array = Array([[1, 2], [3, 4]]) assert te1.replace_with_arrays({A(i, j): array}, [j]) == array[1, :]