Skip to content

Commit 8c98198

Browse files
authored
Merge pull request #8 from lkdvos/master
bump TensorKit compat
2 parents 62bb230 + 08bce53 commit 8c98198

File tree

10 files changed

+382
-322
lines changed

10 files changed

+382
-322
lines changed

.JuliaFormatter.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
style = "yas"

.github/workflows/ci.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
version:
14-
# - '1.0'
15-
- '1.4'
16-
- '1.5'
14+
- '1.6'
15+
- '1'
1716
- 'nightly'
1817
os:
1918
- ubuntu-latest
@@ -22,15 +21,17 @@ jobs:
2221
arch:
2322
- x64
2423
steps:
25-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2625
- uses: julia-actions/setup-julia@v1
2726
with:
2827
version: ${{ matrix.version }}
2928
arch: ${{ matrix.arch }}
29+
- uses: julia-actions/cache@v1
3030
- uses: julia-actions/julia-buildpkg@latest
3131
- uses: julia-actions/julia-runtest@latest
3232
env:
3333
JULIA_NUM_THREADS: 4
34-
- uses: julia-actions/julia-uploadcodecov@latest
35-
env:
36-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
34+
- uses: julia-actions/julia-processcoverage@v1
35+
- uses: codecov/codecov-action@v3
36+
with:
37+
file: lcov.info

.github/workflows/format_check.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags: '*'
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
julia-version: [1]
16+
julia-arch: [x86]
17+
os: [ubuntu-latest]
18+
steps:
19+
- uses: julia-actions/setup-julia@latest
20+
with:
21+
version: ${{ matrix.julia-version }}
22+
23+
- uses: actions/checkout@v1
24+
- name: Install JuliaFormatter and format
25+
# This will use the latest version by default but you can set the version like so:
26+
#
27+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
28+
run: |
29+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
30+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
31+
- name: Format check
32+
run: |
33+
julia -e '
34+
out = Cmd(`git diff --name-only`) |> read |> String
35+
if out == ""
36+
exit(0)
37+
else
38+
@error "Some files have not been formatted !!!"
39+
write(stdout, out)
40+
exit(1)
41+
end'

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name = "TensorKitManifolds"
22
uuid = "11fa318c-39cb-4a83-b1ed-cdc7ba1e3684"
33
authors = ["Jutho Haegeman <[email protected]>", "Markus Hauru <[email protected]>"]
4-
version = "0.6.0"
4+
version = "0.6.1"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
88
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
99

1010
[compat]
11-
TensorKit = "0.6,0.7,0.8,0.9,1"
12-
julia = "1"
11+
TensorKit = "0.11"
12+
julia = "1.6"
1313

1414
[extras]
1515
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/TensorKitManifolds.jl

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,53 @@ function checkbase end
2626
checkbase(x, y, z, args...) = checkbase(checkbase(x, y), z, args...)
2727

2828
# the machine epsilon for the elements of an object X, name inspired from eltype
29-
eleps(X) = eps(real(eltype(X)))
29+
scalareps(X) = eps(real(scalartype(X)))
3030

31-
function isisometry(W::AbstractTensorMap; tol = 10*eleps(W))
32-
WdW = W'*W
33-
s = zero(float(real(eltype(W))))
34-
for (c,b) in blocks(WdW)
31+
function isisometry(W::AbstractTensorMap; tol=10 * scalareps(W))
32+
WdW = W' * W
33+
s = zero(float(real(scalartype(W))))
34+
for (c, b) in blocks(WdW)
3535
_subtractone!(b)
36-
s += dim(c)*length(b)
36+
s += dim(c) * length(b)
3737
end
38-
return norm(WdW) <= tol*sqrt(s)
38+
return norm(WdW) <= tol * sqrt(s)
3939
end
4040
41-
isunitary(W::AbstractTensorMap; tol = 10*eleps(W)) =
42-
isisometry(W; tol = tol) && isisometry(W'; tol = tol)
41+
function isunitary(W::AbstractTensorMap; tol=10 * scalareps(W))
42+
return isisometry(W; tol=tol) && isisometry(W'; tol=tol)
43+
end
4344

4445
function projecthermitian!(W::AbstractTensorMap)
4546
codomain(W) == domain(W) ||
4647
throw(DomainError("Tensor with distinct domain and codomain cannot be hermitian."))
47-
for (c,b) in blocks(W)
48+
for (c, b) in blocks(W)
4849
_projecthermitian!(b)
4950
end
5051
return W
5152
end
5253
function projectantihermitian!(W::AbstractTensorMap)
5354
codomain(W) == domain(W) ||
5455
throw(DomainError("Tensor with distinct domain and codomain cannot be anithermitian."))
55-
for (c,b) in blocks(W)
56+
for (c, b) in blocks(W)
5657
_projectantihermitian!(b)
5758
end
5859
return W
5960
end
6061

6162
struct PolarNewton <: TensorKit.OrthogonalFactorizationAlgorithm
6263
end
63-
function projectisometric!(W::AbstractTensorMap; alg = Polar())
64+
function projectisometric!(W::AbstractTensorMap; alg=Polar())
6465
if alg isa TensorKit.Polar || alg isa TensorKit.SDD
65-
foreach(blocks(W)) do (c,b)
66-
_polarsdd!(b)
66+
foreach(blocks(W)) do (c, b)
67+
return _polarsdd!(b)
6768
end
6869
elseif alg isa TensorKit.SVD
69-
foreach(blocks(W)) do (c,b)
70-
_polarsvd!(b)
70+
foreach(blocks(W)) do (c, b)
71+
return _polarsvd!(b)
7172
end
7273
elseif alg isa PolarNewton
73-
foreach(blocks(W)) do (c,b)
74-
_polarnewton!(b)
74+
foreach(blocks(W)) do (c, b)
75+
return _polarnewton!(b)
7576
end
7677
else
7778
throw(ArgumentError("unkown algorithm for projectisometric!: alg = $alg"))
@@ -80,14 +81,14 @@ function projectisometric!(W::AbstractTensorMap; alg = Polar())
8081
end
8182

8283
function projectcomplement!(X::AbstractTensorMap, W::AbstractTensorMap;
83-
tol = 10*eleps(X))
84-
P = W'*X
84+
tol=10 * scalareps(X))
85+
P = W' * X
8586
nP = norm(P)
8687
nX = norm(X)
8788
dP = dim(P)
88-
while nP > tol*max(dP, nX)
89+
while nP > tol * max(dP, nX)
8990
X = mul!(X, W, P, -1, 1)
90-
P = W'*X
91+
P = W' * X
9192
nP = norm(P)
9293
end
9394
return X
@@ -97,11 +98,11 @@ projecthermitian(W::AbstractTensorMap) = projecthermitian!(copy(W))
9798
projectantihermitian(W::AbstractTensorMap) = projectantihermitian!(copy(W))
9899

99100
function projectisometric(W::AbstractTensorMap;
100-
alg::TensorKit.OrthogonalFactorizationAlgorithm = Polar())
101+
alg::TensorKit.OrthogonalFactorizationAlgorithm=Polar())
101102
return projectisometric!(copy(W); alg=alg)
102103
end
103104
function projectcomplement(X::AbstractTensorMap, W::AbstractTensorMap,
104-
tol = 10*eleps(X))
105+
tol=10 * scalareps(X))
105106
return projectcomplement!(copy(X), W; tol=tol)
106107
end
107108

0 commit comments

Comments
 (0)