-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add missing kwargs...
in evolve
-related functions
#267
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally prefer using kwargs...
more often, but keep in mind that due to its nature it can affect many levels of calls of methods.
The changes I propose in the review are mainly the following:
- If
threshold
,maxdim
andnormalize
are not directly used, but just passed, then remove them and let's pass them as part ofkwargs
. - If you just need to know if
threshold
andmaxdim
are defined (i.e. the are notnothing
), then use!isnothing(get(kwargs, :threshold, nothing))
- What do you think about moving this check to
truncate!
? like makethreshold=nothing
andmaxdim=nothing
by default intruncate!
and do the check also there. If I recall correctly, we don't do the check there and that's why we must do it here. I think it will look cleaner that way.
- What do you think about moving this check to
- If you need to override values from
kwargs
and ensure some kwarg configuration, then call dokwargs...
first and then do the override.
Co-authored-by: Sergio Sánchez Ramírez <[email protected]>
I agree, this makes sense! I will do that. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #267 +/- ##
==========================================
- Coverage 79.59% 0.04% -79.55%
==========================================
Files 32 32
Lines 2068 2150 +82
==========================================
- Hits 1646 1 -1645
- Misses 422 2149 +1727 ☔ View full report in Codecov by Sentry. |
Okay @mofeing let's merge this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super, just some lil suggestions and we're done
src/Ansatz.jl
Outdated
return tn | ||
else | ||
return truncate!(form(tn), tn, bond; threshold, maxdim, kwargs...) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just an aesthetic recommendation
return tn | |
else | |
return truncate!(form(tn), tn, bond; threshold, maxdim, kwargs...) | |
end | |
return tn | |
end | |
return truncate!(form(tn), tn, bond; threshold, maxdim, kwargs...) |
src/MPS.jl
Outdated
if any(!isnothing, get.(Ref(kwargs), [:threshold, :maxdim], nothing)) | ||
truncate_sweep!(form(ψ), ψ; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably better if you move this check to truncate_sweep!
as you've done with truncate!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well okay, but I still need to check that is some way to normalize
if it is not truncated.
src/MPS.jl
Outdated
initial_form = form(ψ) | ||
mixed_canonize!(ψ, Site(nsites(ψ))) # We convert all the tensors to left-canonical form | ||
|
||
normalize = get(kwargs, :normalize, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here the default is false
but NonCanonical
is true
?
we must keep consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well okay, but this does not change anything, since we send normalize
with default=true
in evolve(ψ::AbstractAnsatz, mpo::AbstractMPO; reset_index=true, kwargs...)
.
src/MPS.jl
Outdated
if any(!isnothing, get.(Ref(kwargs), [:threshold, :maxdim], nothing)) | ||
truncate_sweep!(Canonical(), ψ; kwargs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
This PR includes changes to
evolve
-related functions to add support for additional keyword arguments (kwargs...
) in several functions. This enhancement allows for more flexible function calls by passing extra parameters as needed.This is useful for example when we want to pass a
kwarg
intotruncate
.