-
Notifications
You must be signed in to change notification settings - Fork 125
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
[ITensors] Make scalartype
accessible as ITensors.scalartype
#1370
Conversation
[test ITensorMPS] [test ITensorTDVP] [test ITensorGaussianMPS] |
Thanks... was just about to work on this |
By the way, I meant to ask what |
Run ITensorGaussianMPS tests from comment trigger: succeeded ✅ |
1 similar comment
Run ITensorGaussianMPS tests from comment trigger: succeeded ✅ |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1370 +/- ##
=======================================
Coverage ? 50.41%
=======================================
Files ? 113
Lines ? 8963
Branches ? 0
=======================================
Hits ? 4519
Misses ? 4444
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Run ITensorTDVP tests from comment trigger: failed ❌ |
Run ITensorMPS tests from comment trigger: succeeded ✅ |
1 similar comment
Run ITensorMPS tests from comment trigger: succeeded ✅ |
It generates a module with a random name, i.e.: julia> M1 = @eval module $(gensym())
f() = 2
end
Main.var"##226"
julia> M2 = @eval module $(gensym())
f() = 3
end
Main.var"##227"
julia> M1.f()
2
julia> M2.f()
3 I have found that it is better to wrap test files in modules, since it makes them more self contained, i.e. you can control exactly what goes into the namespace to be used by the tests in that test file. That makes sure you aren't accidentally using a variable or function that was defined in a previous test file (or even some other code you ran, if you are running the tests with Maybe it is better to make a small macro: @temp_module begin
# Test code here
end which internally is just defined as This kind of thing (wrapping test files in modules) is pretty commonly suggested for avoiding potential namespace issues in tests:
|
Nice, thanks for explaining. I do think the idea of a macro would be a good one down the road to make it more 'self documenting'. But not a big priority of course. |
For example: julia> macro temp_module(expr)
return :(@eval module $(gensym()) $expr end)
end
@temp_module (macro with 2 methods)
julia> M = @temp_module begin
f() = 2
end
Main.var"##231"
julia> M.f()
2 Probably that is less opaque than directly using |
I do like that better. And perhaps even |
Ah I see an issue with the current testing setup to test against I'm sure there is a way to fix that, probably in the workflow we have to activate the environment of using Pkg: Pkg
Pkg.activate("ITensorTDVP")
Pkg.develop("ITensors") However, if that is run within the Github Actions workflow, I'm not certain if that will checkout the PR branch or the |
I see the tests also generate a lot of warnings like: WARNING: Method definition update!(ITensors.ITensorMPS.AbstractObserver) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/update_observer.jl:3 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/update_observer.jl:4.
ERROR: Method overwriting is not permitted during Module precompilation. Use `__precompile__(false)` to opt-out of precompilation.
WARNING: Method definition update!(ITensors.ITensorMPS.AbstractObserver) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/update_observer.jl:3 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/update_observer.jl:4.
WARNING: Method definition kwcall(NamedTuple{names, T} where T<:Tuple where names, typeof(Observers.update!), ITensors.ITensorMPS.AbstractObserver) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/update_observer.jl:3 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/update_observer.jl:4.
WARNING: Method definition contract(NDTensors.AlgorithmSelection.Algorithm{:fit, Kwargs} where Kwargs<:(NamedTuple{names, T} where T<:Tuple where names), ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/contract_mpo_mps.jl:15 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/contract_mpo_mps.jl:26.
WARNING: Method definition kwcall(NamedTuple{names, T} where T<:Tuple where names, typeof(NDTensors.contract), NDTensors.AlgorithmSelection.Algorithm{:fit, Kwargs} where Kwargs<:(NamedTuple{names, T} where T<:Tuple where names), ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/contract_mpo_mps.jl:15 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/contract_mpo_mps.jl:26.
WARNING: Method definition linsolve(ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26.
WARNING: Method definition linsolve(ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS, Number) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26.
WARNING: Method definition linsolve(ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS, Number, Number) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26.
WARNING: Method definition kwcall(NamedTuple{names, T} where T<:Tuple where names, typeof(KrylovKit.linsolve), ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26.
WARNING: Method definition kwcall(NamedTuple{names, T} where T<:Tuple where names, typeof(KrylovKit.linsolve), ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS, Number) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26.
WARNING: Method definition kwcall(NamedTuple{names, T} where T<:Tuple where names, typeof(KrylovKit.linsolve), ITensors.ITensorMPS.MPO, ITensors.ITensorMPS.MPS, ITensors.ITensorMPS.MPS, Number, Number) in module ITensorMPS at /Users/mfishman/.julia/dev/ITensors/src/ITensorMPS/linsolve.jl:25 overwritten in module ITensorTDVP at /Users/mfishman/.julia/packages/ITensorTDVP/OmMNj/src/linsolve.jl:26. We should fix those (say by just not overloading those functions from |
I tested this fix locally and it fixes |
scalartype
accessible with ITensors.scalartype
scalartype
accessible as ITensors.scalartype
@emstoudenmire a reference point for fixing the downstream testing of Some other references for testing a PR against dependencies are: |
Perhaps we can just use one of those instead. I think they don't support optionally running the test based on a comment trigger but it may be better to just run the test every time anyway. |
Sounds good & I'll fix the warnings in another PR. |
ITensorTDVP.jl
appears to rely on the functionscalartype
(which is defined inNDTensors
) being available asITensors.scalartype
.It seems like that was dropped during the
ITensorMPS
reorganization, since now onlyITensorMPS
usesscalartype
. This fixes that by addingusing NDTensors: scalartype
inside of theITensors
module, and adds a test that it is accessible asITensors.scalartype
.I also made some namespace improvements in some tests.
EDIT: I also added a test file that tests what names are exported by
ITensors
, which I think is good practice to do from now on for any package/module. Before we were implicitly testing what got exported by typingusing ITensors
and then using a function in a test, which is both finicky and we are moving away from that import/using style.