TensorNetwork icon indicating copy to clipboard operation
TensorNetwork copied to clipboard

Move towards consistent use of the term Tensor

Open alewis opened this issue 5 years ago • 2 comments

Right now there's a bit of a confusing situation going on where the term Tensor refers both to the type of a given backend array (the old use) and to tn.Tensor itself. Since this is confusing for new developers I recommend we change the former use to something more descriptive, e.g. "backend array". Using that name (subject to discussion) as a placeholder, I would recommend the following:

  1. Change convert_to_tensor to e.g. convert_to_backend_array.
  2. The type hint Tensor within the backend files should be changed to e.g. BackendArray. Ideally we'd also do something a bit more specific than just BackendArray = Any, though I understand this might be hard given how our build works.

Those are the important things, I think, but in addition:

  1. We might consider changing Node so that it wraps tn.Tensor rather than a backend array directly. (Edit: let's actually not do this)

alewis avatar Oct 05 '20 14:10 alewis

  1. The type hint Tensor within the backend files should be changed to e.g. BackendArray. Ideally we'd also do something a bit more specific than just BackendArray = Any, though I understand this might be hard given how our build works.

The type hint also appears at other places, not just in the backend files. Those need to be changed as well.

  1. We might consider changing Node so that it wraps tn.Tensor rather than a backend array directly.

I'd rather not add this dependency into Node. It doesn't by us a lot, but makes code maintenance potentially a lot harder.

mganahl avatar Oct 05 '20 14:10 mganahl

Alright, let's junk the Node thing then.

alewis avatar Oct 05 '20 14:10 alewis