From 1dc14d51b41d895e201ddd7f2f625cfae1bcbb22 Mon Sep 17 00:00:00 2001 From: Johnnie Gray Date: Thu, 12 Dec 2024 17:56:28 -0800 Subject: [PATCH] TensorNetwork: add .backend and .dtype_name properties --- quimb/tensor/tensor_core.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/quimb/tensor/tensor_core.py b/quimb/tensor/tensor_core.py index 274be4b0..80d4af49 100644 --- a/quimb/tensor/tensor_core.py +++ b/quimb/tensor/tensor_core.py @@ -10683,8 +10683,21 @@ def dtype(self): """The dtype of this TensorNetwork, this is the minimal common type of all the tensors data. """ + # TODO: support non numpy dtypes here return get_common_dtype(*self.arrays) + @property + def dtype_name(self): + """The name of the data type of the array elements.""" + return next(iter(self.tensor_map.values())).dtype_name + + @property + def backend(self): + """Get the backend of any tensor in this network, asssuming it to be + the same for all tensors. + """ + return next(iter(self.tensor_map.values())).backend + def iscomplex(self): return iscomplex(self)