Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate PauliBasis and equal_bases #39

Closed
wants to merge 2 commits into from

Conversation

akirakyle
Copy link
Member

@akirakyle akirakyle commented Dec 6, 2024

Closes #36, applies on top of #37

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 117 lines in your changes missing coverage. Please review.

Project coverage is 32.66%. Comparing base (f22adb7) to head (455e72b).

Files with missing lines Patch % Lines
src/show.jl 0.00% 43 Missing ⚠️
src/linalg.jl 48.61% 37 Missing ⚠️
src/julia_base.jl 0.00% 16 Missing ⚠️
src/deprecated.jl 0.00% 9 Missing ⚠️
src/bases.jl 0.00% 5 Missing ⚠️
src/embed_permute.jl 50.00% 4 Missing ⚠️
src/julia_linalg.jl 0.00% 2 Missing ⚠️
src/identityoperator.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #39       +/-   ##
===========================================
+ Coverage   17.08%   32.66%   +15.58%     
===========================================
  Files          12       13        +1     
  Lines         398      401        +3     
===========================================
+ Hits           68      131       +63     
+ Misses        330      270       -60     

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

@Krastanov
Copy link
Collaborator

Krastanov commented Dec 6, 2024

I am leaning more towards a deprecation for renaming, not for complete removal. Currently PauliBasis does provide something that is otherwise not available: an implicit way to define a multiqubit basis in O(1) space. That is a valuable alternative to the O(n) way of defining the same with SpinBasis(1//2).

At some point in the future, when the necessary capabilities exist we can just silently remove the struct and keep the constructor, returning the appropriate composition of SpinBasis(1//2).

The principle here being: if something was added, but it is inelegant, do not remove it, just sequester it so that it does not cause future issues. That way old code will still work -- we should not break old code purely for the sake of elegance.

@Krastanov
Copy link
Collaborator

Maybe we can call it QubitBasis or CompactQubitBasis

src/bases.jl Outdated
write(stream, "Fock(cutoff=$(x.N), offset=$(x.offset))")
Base.@deprecate equal_bases(a, b) _equal_bases(a, b) false
function _equal_bases(a, b)
Base.depwarn("`equal_bases` will be removed in next version!", :_equal_bases)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly here, do not say it will be removed, rather say what should be used instead. This will probably remain in the code base for many years to avoid breaking old code. We can just steer future users to not use it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you use @deprecated, I do not think you need to manually run depwarn.

julia> @macroexpand1 Base.@deprecate f(x) g(x)
:($(Expr(:toplevel, :(export f), :(f(x) = begin
          #= deprecated.jl:103 =#
          $(Expr(:meta, :noinline))
          #= deprecated.jl:104 =#
          Base.depwarn("`f(x)` is deprecated, use `g(x)` instead.", ((Base.Core).Typeof(f)).name.mt.name)
          #= deprecated.jl:105 =#
          g(x)
      end))))

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it! In this instance, I think the depwarn is more useful than @depricate since then the appropriate message of what should be used instead will be printed.

@akirakyle
Copy link
Member Author

I am leaning more towards a deprecation for renaming, not for complete removal. Currently PauliBasis does provide something that is otherwise not available: an implicit way to define a multiqubit basis in O(1) space.

I renamed to NQubitBasis. It would be nice for this behavior to just be part of CompositeBasis so that N of the same basis tensored together is represented by just the basis and N so that it is effectively O(1). If something like that is implemented, then I suppose we could just have const NQubitBasis(N) = SpinBasis(1//2)^N

@akirakyle akirakyle requested a review from Krastanov December 6, 2024 17:16
@akirakyle akirakyle force-pushed the deprecate branch 3 times, most recently from 0998f71 to 4b05311 Compare December 6, 2024 18:35
@akirakyle akirakyle marked this pull request as draft December 6, 2024 23:29
@akirakyle akirakyle removed the request for review from Krastanov December 6, 2024 23:29
@akirakyle
Copy link
Member Author

@Krastanov sorry for all the force pushes on this, I kept adding things to the cleanup commit. I think it's best just to review/merge that since it doesn't change any functionality. I've changed this one to draft since I'm still actually struggling with #35 and there's a chance it might be best to actually consider the actual Pauli operator basis as a subtype of Basis in which case it would be best not to do this deprecation, but just be clearer in it's docstring of how it is supposed to be interpreted.

@akirakyle
Copy link
Member Author

Closing for now, see #40 for why.

@akirakyle akirakyle closed this Dec 8, 2024
@akirakyle
Copy link
Member Author

Reopening, since the actual Pauli operator basis will have a different structure than the currently named PauliBasis. Having a deprecation warning now would be good so give users a chance to realize this. Later, when introducing the actual Pauli operator basis, this allows us the chance to use the PauliBasis name for the actual Pauli operator basis.

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.

PauliBasis is misleadingly named as it doesn't represent the operator basis of Pauli matrices+identity
2 participants