Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: blegat/CondensedMatterSOS.jl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5015149089075e65ed2965b39ee613a758775489
Choose a base ref
..
head repository: blegat/CondensedMatterSOS.jl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c488c14f535a5dfc5d9dbdbcced9cf70fadabf17
Choose a head ref
Showing with 29 additions and 34 deletions.
  1. +1 −0 docs/.gitignore
  2. +11 −28 docs/make.jl
  3. +2 −0 examples/all_examples.jl
  4. +9 −0 examples/run_examples.jl
  5. +3 −3 src/monom-set.jl
  6. +3 −3 test/runtests.jl
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
src/examples/*.md
src/generated
39 changes: 11 additions & 28 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -3,30 +3,15 @@ using Literate
using CondensedMatterSOS
using Test

const _EXAMPLE_DIR = joinpath(@__DIR__, "..", "examples")
const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
const OUTPUT_DIR = joinpath(@__DIR__, "src/generated")

function link_example(content)
edit_url = match(r"EditURL = \"(.+?)\"", content)[1]
footer = match(r"^(---\n\n\*This page was generated using)"m, content)[1]
content = replace(
content, footer => "[View this file on Github]($(edit_url)).\n\n" * footer
)
return content
end
include(joinpath(EXAMPLES_DIR, "run_examples.jl"))

for file in readdir(_EXAMPLE_DIR)
if !endswith(file, ".jl")
continue
end
filename = joinpath(_EXAMPLE_DIR, file)
# `include` the file to test it before `#src` lines are removed. It is in a
# testset to isolate local variables between files.
@testset "$(file)" begin
include(filename)
end
Literate.markdown(filename, OUTPUT_DIR)
Literate.notebook(filename, OUTPUT_DIR)
for example in EXAMPLES
example_filepath = joinpath(EXAMPLES_DIR, example)
Literate.markdown(example_filepath, OUTPUT_DIR)
Literate.notebook(example_filepath, OUTPUT_DIR)
end

makedocs(
@@ -37,13 +22,11 @@ makedocs(
strict = true,
pages = [
"Introduction" => "index.md",
"Examples" => map(
file -> joinpath(OUTPUT_DIR, file),
filter(
file -> endswith(file, ".md"),
sort(readdir(OUTPUT_DIR)),
)
)
"Examples" => map(EXAMPLES) do jl_file
# Need `string` as Documenter fails if `name` is a `SubString{String}`.
name = string(split(jl_file, ".")[1])
return name => "generated/$name.md"
end
],
)

2 changes: 2 additions & 0 deletions examples/all_examples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const EXAMPLES = filter(ex -> endswith(ex, ".jl") && ex != "run_examples.jl" && ex != "all_examples.jl",
readdir(@__DIR__))
9 changes: 9 additions & 0 deletions examples/run_examples.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Test

include("all_examples.jl")

@testset "run_examples.jl" begin
@testset "$(example)" for example in EXAMPLES
include(example)
end
end
6 changes: 3 additions & 3 deletions src/monom-set.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
monomials(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int64)
monomials(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int)
This version returns all the monomials of degree deg with all the possible orders
```
@@ -9,7 +9,7 @@ E1. (sx[1],sx[2])->[sx[1]*sx[2],sx[2]*sx[1]];
E2. (sx[1],sy[1])->[sx[1]*sy[1],sy[1]*sx[1]];
```
"""
function monomials_old(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int64)
function monomials(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int)
CC = combinations(vars,deg)
BB = permutations.(collect(Iterators.take(CC,length(CC))))
AA = prod.(vcat(map(x->collect(Iterators.take(x,length(x))), vcat(BB...))...))
@@ -52,7 +52,7 @@ function MP.monomials(vars::Vector{SpinVariable}, degs::AbstractVector{Int}, fil
end

# # using CondensedMatterSOS
# # function monomials(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int64)
# # function monomials(vars::Vector{CondensedMatterSOS.SpinVariable}, deg::Int)
# #
# #
# # using CondensedMatterSOS
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -153,8 +153,8 @@ end
@testset "monomials" begin
@test monovec([1, sigmax[1], sigmax[2]]) == [sigmax[1], sigmax[2], 1]
@test monomials([sigmax[1], sigmax[2]], 0) == [1]
@test CMS.monomials_old([sigmax[1], sigmax[2]], 0) == [1]
@test CMS.monomials([sigmax[1], sigmax[2]], 0) == [1]
@test all(monomials([sigmax[1], sigmax[2]], 2) .== [CMS.SpinVariable(sigmax[1].id, i) * CMS.SpinVariable(sigmax[2].id, j) for i in 0:2 for j in 0:2])
@test all(CMS.monomials_old([sigmax[1],sigmax[2]],2) .== [sigmax[1]*sigmax[2]])
@test all(CMS.monomials_old([sigmax[1],sigmay[1]],2) .== [im*sigmaz[1],-im*sigmaz[1]])
@test all(CMS.monomials([sigmax[1],sigmax[2]],2) .== [sigmax[1]*sigmax[2]])
@test all(CMS.monomials([sigmax[1],sigmay[1]],2) .== [im*sigmaz[1],-im*sigmaz[1]])
end