Skip to content

Conversation

@Jutho
Copy link
Member

@Jutho Jutho commented Nov 10, 2024

No description provided.

@Jutho Jutho requested a review from lkdvos November 10, 2024 23:48
return t
else
return copy!(similar(t, complex(scalartype(t))), t)
return TensorMap(complex(t.data), space(t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of having TensorMap hard-coded here. I think similar, by definition, should return a mutable tensor to copy the data into, which by default returns a TensorMap, similar to how Array is the default for similar(::AbstractArray), but I need to overload this for BlockTensorMap, which is easier if everything passes through similar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like it's the second time I make this mistake. I forget that this method works on AbstractTensorMap, whereas it is in tensormap.jl. Maybe I should move it. However, I do think having the simple TensorMap specialisation around is also useful.

Comment on lines 584 to 587
# TODO: should we reformulate the old checks in terms of `sectorscalartype`
# For anyonic categories, complex numbers typically come into play only in the
# braiding and not in the fusion. Hence, it can make sense to work with real
# tensors if no braiding is required.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind having real/imag work even if the fusion data is not real. I understand that it might lead to bugs here and there, but for example for singular values, it is quite natural to allow real numbers (since there are no fusion tensors anyways).

@codecov
Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 23.07692% with 20 lines in your changes missing coverage. Please review.

Project coverage is 80.93%. Comparing base (f218222) to head (641c603).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/tensors/abstracttensor.jl 9.09% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #173      +/-   ##
==========================================
- Coverage   81.21%   80.93%   -0.29%     
==========================================
  Files          41       41              
  Lines        5005     5015      +10     
==========================================
- Hits         4065     4059       -6     
- Misses        940      956      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# that the real/imaginary part of a tensor `t` can be obtained by just taking
# real/imaginary part of the degeneracy data.
if isreal(sectortype(t))
return TensorMap(real(t.data), codomain(t), domain(t))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this one slipped through in the previous change, as it should actually also only work for TensorMap arguments. That one is not entirely straightforward to define for AbstractTensorMap.

@Jutho
Copy link
Member Author

Jutho commented Nov 11, 2024

AD CI on mac is really going nuts; not sure if this now changed more due to this PR, or whether it is a random glitch. I run the test locally, and if successful, I think this is ok to merge?

@lkdvos lkdvos merged commit 378c150 into master Nov 11, 2024
@lkdvos lkdvos deleted the jh/complexpatch branch August 26, 2025 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants