Skip to content

Commit ff6a871

Browse files
authored
[ITensors] Start organizing into submodules (#1400)
1 parent 7329ffe commit ff6a871

File tree

110 files changed

+1661
-1478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1661
-1478
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensors"
22
uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5"
33
authors = ["Matthew Fishman <[email protected]>", "Miles Stoudenmire <[email protected]>"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
module ITensorsHDF5Ext
2-
32
include("index.jl")
43
include("itensor.jl")
54
include("qnindex.jl")
@@ -8,5 +7,4 @@ include("qn.jl")
87
include("tagset.jl")
98
include("ITensorMPS/mps.jl")
109
include("ITensorMPS/mpo.jl")
11-
1210
end

ext/ITensorsHDF5Ext/tagset.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using HDF5: HDF5, attributes, create_group, open_group, read, write
2-
using ITensors: TagSet, tagstring
2+
using ITensors.TagSets: TagSet, tagstring
33

44
function HDF5.write(parent::Union{HDF5.File,HDF5.Group}, name::AbstractString, T::TagSet)
55
g = create_group(parent, name)

src/ITensors.jl

Lines changed: 98 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,65 +51,136 @@ Documentation: https://itensor.github.io/ITensors.jl/stable/
5151
module ITensors
5252
include("usings.jl")
5353
include("utils.jl")
54-
include("lib/ContractionSequenceOptimization/ContractionSequenceOptimization.jl")
54+
include("lib/ContractionSequenceOptimization/src/ContractionSequenceOptimization.jl")
55+
# TODO: `using .ContractionSequenceOptimization: ContractionSequenceOptimization, ...`.
5556
using .ContractionSequenceOptimization
56-
include("lib/LazyApply/LazyApply.jl")
57+
include("lib/LazyApply/src/LazyApply.jl")
58+
# TODO: `using .LazyApply: LazyApply, ...`.
5759
using .LazyApply
58-
include("lib/Ops/Ops.jl")
60+
using .LazyApply: Prod, Scaled, Sum, coefficient
61+
export Prod, Scaled, Sum, coefficient
62+
include("lib/Ops/src/Ops.jl")
63+
# TODO: `using .Ops: Ops, ...`.
5964
using .Ops
65+
using .Ops: Ops, Op, Trotter
6066
import .Ops: sites, name
67+
export Ops, Op, Trotter
6168
include("exports.jl")
6269
include("imports.jl")
6370
include("global_variables.jl")
71+
# TODO: Move to `lib/LastVals/src/LastVals.jl`.
6472
include("lastval.jl")
65-
include("smallstring.jl")
73+
include("lib/SmallStrings/src/SmallStrings.jl")
74+
using .SmallStrings: SmallStrings, IntChar, SmallString, Tag, isint, isnull
6675
include("readwrite.jl")
76+
export readcpp
77+
# TODO: Move to `lib/Nots/src/Nots.jl`.
6778
include("not.jl")
68-
include("tagset.jl")
69-
include("arrow.jl")
79+
export not
80+
include("lib/TagSets/src/TagSets.jl")
81+
using .TagSets: TagSets, set_strict_tags!, using_strict_tags
82+
# TODO: Move to `lib/Names/src/Names.jl`.
83+
include("name.jl")
84+
# TODO: Move to `lib/Vals/src/Vals.jl`.
85+
include("val.jl")
86+
export val
87+
include("lib/QuantumNumbers/src/QuantumNumbers.jl")
88+
using .QuantumNumbers:
89+
Arrow,
90+
In,
91+
Neither,
92+
Out,
93+
QN,
94+
QNVal,
95+
hasname,
96+
have_same_mods,
97+
have_same_qns,
98+
isactive,
99+
maxQNs,
100+
modulus,
101+
nactive
102+
export QN, isactive, modulus
70103
include("symmetrystyle.jl")
71104
include("index.jl")
72105
include("set_operations.jl")
73106
include("indexset.jl")
74107
include("itensor.jl")
108+
include("qn/flux.jl")
75109
include("oneitensor.jl")
76110
include("tensor_operations/tensor_algebra.jl")
77111
include("tensor_operations/matrix_algebra.jl")
78112
include("tensor_operations/permutations.jl")
113+
include("lib/SiteTypes/src/SiteTypes.jl")
114+
using .SiteTypes:
115+
SiteTypes,
116+
OpName,
117+
SiteType,
118+
StateName,
119+
TagType,
120+
ValName,
121+
@OpName_str,
122+
@SiteType_str,
123+
@StateName_str,
124+
@TagType_str,
125+
@ValName_str,
126+
alias,
127+
has_fermion_string,
128+
op,
129+
op!,
130+
ops,
131+
state
132+
export OpName,
133+
SiteType,
134+
StateName,
135+
TagType,
136+
ValName,
137+
@OpName_str,
138+
@SiteType_str,
139+
@StateName_str,
140+
@TagType_str,
141+
@ValName_str,
142+
has_fermion_string,
143+
op,
144+
ops,
145+
state,
146+
val
147+
include("lib/ITensorsSiteTypesExt/src/ITensorsSiteTypesExt.jl")
79148
include("broadcast.jl")
80149
include("tensor_operations/matrix_decomposition.jl")
81150
include("adapt.jl")
82151
include("set_types.jl")
83152
include("tensor_operations/itensor_combiner.jl")
84-
include("qn/flux.jl")
85-
include("qn/qn.jl")
86153
include("qn/qnindex.jl")
87154
include("qn/qnindexset.jl")
88155
include("qn/qnitensor.jl")
89156
include("nullspace.jl")
90-
include("lib/Ops/ops_itensor.jl")
91-
include("physics/sitetype.jl")
92-
include("physics/lattices.jl")
93-
include("physics/site_types/aliases.jl")
94-
include("physics/site_types/generic_sites.jl")
95-
include("physics/site_types/qubit.jl")
96-
include("physics/site_types/spinhalf.jl")
97-
include("physics/site_types/spinone.jl")
98-
include("physics/site_types/fermion.jl")
99-
include("physics/site_types/electron.jl")
100-
include("physics/site_types/tj.jl")
101-
include("physics/site_types/qudit.jl")
102-
include("physics/site_types/boson.jl")
103-
include("physics/fermions.jl")
104-
include("lib/ITensorMPS/ITensorMPS.jl")
157+
include("lib/ITensorsOpsExt/src/ITensorsOpsExt.jl")
158+
include("fermions/fermions.jl")
159+
export fparity, isfermionic
160+
include("lib/ITensorMPS/src/ITensorMPS.jl")
161+
# TODO: `using .ITensorMPS: ITensorMPS, ...` and
162+
# explicit export list.
105163
@reexport using .ITensorMPS
106164
include("lib/ITensorsNamedDimsArraysExt/src/ITensorsNamedDimsArraysExt.jl")
107165
using .ITensorsNamedDimsArraysExt: ITensorsNamedDimsArraysExt
108-
include("lib/Ops/trotter.jl")
109-
include("lib/ITensorChainRules/ITensorChainRules.jl")
110-
include("lib/ITensorNetworkMaps/ITensorNetworkMaps.jl")
111-
include("lib/ITensorVisualizationCore/ITensorVisualizationCore.jl")
166+
include("lib/ITensorChainRules/src/ITensorChainRules.jl")
167+
include("lib/ITensorNetworkMaps/src/ITensorNetworkMaps.jl")
168+
include("lib/ITensorVisualizationCore/src/ITensorVisualizationCore.jl")
169+
# TODO: `using .ITensorVisualizationCore: ITensorVisualizationCore, ...`.
112170
using .ITensorVisualizationCore
171+
using .ITensorVisualizationCore:
172+
@visualize,
173+
@visualize!,
174+
@visualize_noeval,
175+
@visualize_noeval!,
176+
@visualize_sequence,
177+
@visualize_sequence_noeval
178+
export @visualize,
179+
@visualize!,
180+
@visualize_noeval,
181+
@visualize_noeval!,
182+
@visualize_sequence,
183+
@visualize_sequence_noeval
113184
include("deprecated.jl")
114185
include("argsdict/argsdict.jl")
115186
include("packagecompile/compile.jl")

src/exports.jl

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ export
33
# LinearAlgebra
44
nullspace,
55
tr,
6-
76
# Modules
87
LinearAlgebra,
98
NDTensors,
10-
119
# NDTensors module
1210
# Types
1311
Block,
@@ -19,22 +17,10 @@ export
1917
truncerror,
2018
# Deprecated
2119
addblock!,
22-
23-
# ITensorVisualizationCore module
24-
# Macros
25-
@visualize,
26-
@visualize!,
27-
@visualize_noeval,
28-
@visualize_noeval!,
29-
@visualize_sequence,
30-
@visualize_sequence_noeval,
31-
3220
# ITensors.jl
3321
index_id_rng,
34-
3522
# argsdict/argsdict.jl
3623
argsdict,
37-
3824
# tensor_operations/matrix_decomposition.jl
3925
eigen,
4026
factorize,
@@ -45,18 +31,14 @@ export
4531
ql,
4632
svd,
4733
diag,
48-
4934
# tensor_operations/tensor_algebra.jl
5035
contract,
51-
5236
# global_variables.jl
5337
# Methods
54-
5538
# Macros
5639
@disable_warn_order,
5740
@reset_warn_order,
5841
@set_warn_order,
59-
6042
# index.jl
6143
# Types
6244
Index,
@@ -90,8 +72,6 @@ export
9072
space,
9173
splitblocks,
9274
tags,
93-
val,
94-
9575
# indexset.jl
9676
# Types
9777
IndexSet,
@@ -118,7 +98,6 @@ export
11898
swapinds,
11999
swapprime,
120100
swaptags,
121-
122101
# itensor.jl
123102
# Types
124103
ITensor,
@@ -199,13 +178,6 @@ export
199178
unionind,
200179
vector,
201180
emptyITensor,
202-
203-
# not.jl
204-
not,
205-
206-
# readwrite.jl
207-
readcpp,
208-
209181
# tagset.jl
210182
# Types
211183
TagSet,
@@ -214,60 +186,10 @@ export
214186
# Methods
215187
addtags,
216188
hastags,
217-
218-
# LazyApply/LazyApply.jl
219-
Scaled,
220-
Sum,
221-
Prod,
222-
coefficient,
223-
224-
# Ops/Ops.jl
225-
Ops,
226-
Op,
227-
228-
# Ops/trotter.jl
229-
Trotter,
230-
231189
# physics/autompo.jl
232190
AutoMPO,
233191
OpSum,
234192
add!,
235-
236-
# physics/fermions.jl
237-
fparity,
238-
isfermionic,
239-
240-
# physics/lattices.jl
241-
Lattice,
242-
LatticeBond,
243-
square_lattice,
244-
triangular_lattice,
245-
246-
# physics/sitetype.jl
247-
SiteType,
248-
@SiteType_str,
249-
StateName,
250-
@StateName_str,
251-
op,
252-
ops,
253-
OpName,
254-
@OpName_str,
255-
ValName,
256-
@ValName_str,
257-
state,
258-
TagType,
259-
@TagType_str,
260-
has_fermion_string,
261-
262-
# qn/qn.jl
263-
# Types
264-
QN,
265-
# Methods
266-
isactive,
267-
isfermionic,
268-
modulus,
269-
val,
270-
271193
# qn/qnindex.jl
272194
blockdim,
273195
flux,

src/physics/fermions.jl renamed to src/fermions/fermions.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using .QuantumNumbers: QuantumNumbers, QN
12

23
"""
34
parity_sign(P)
@@ -19,7 +20,7 @@ function parity_sign(P)::Int
1920
return s
2021
end
2122

22-
isfermionic(qv::QNVal) = (modulus(qv) < 0)
23+
isfermionic(qv::QuantumNumbers.QNVal) = (QuantumNumbers.modulus(qv) < 0)
2324

2425
isfermionic(qn::QN) = any(isfermionic, qn)
2526

@@ -326,7 +327,7 @@ function NDTensors.before_combiner_signs(
326327
end
327328

328329
return T
329-
end #NDTensors.before_combiner_signs
330+
end
330331

331332
function NDTensors.after_combiner_signs(
332333
R, labelsR, indsR::NTuple{NR,QNIndex}, C, labelsC, indsC::NTuple{NC,QNIndex}
@@ -374,4 +375,4 @@ function NDTensors.after_combiner_signs(
374375
end
375376

376377
return R
377-
end #NDTensors.after_combiner_signs
378+
end

0 commit comments

Comments
 (0)