Skip to content

Bonds() returns reference - intended? #743

@manuschneider

Description

@manuschneider

The behavior of the UniTensor methods bond and bonds seems inconsistent:
bond(idx) returns a copy of the bond
bond_(idx) returns a reference to the bond
bonds() returns references to the bonds
bonds_() does not exist

I was wondering if this is intended, and methods with return type vector always return a shared view. But this seems not generally true, e.g.:
UniTensor::labels() returns references
Tensor::shape() returns references, but
UniTensor::shape() returns cloned values

The shape should never be changed directly by the user anyway. But for methods such as bonds() and labels(), this matters. I would suggest defining the behavior and documenting it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions