Skip to content

Commit e370eb0

Browse files
committed
Runic format
1 parent f50f00e commit e370eb0

File tree

7 files changed

+219
-215
lines changed

7 files changed

+219
-215
lines changed

NDTensors/src/vendored/TypeParameterAccessors/src/base/abstractarray.jl

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ struct Self end
22
position(a, ::Self) = Position(0)
33
position(::Type, ::Self) = Position(0)
44
function set_type_parameters(type::Type, ::Self, param)
5-
return error("Can't set the parent type of an unwrapped array type.")
5+
return error("Can't set the parent type of an unwrapped array type.")
66
end
77

88
position(::Type{AbstractArray}, ::typeof(eltype)) = Position(1)
@@ -17,15 +17,15 @@ position(::Type{<:BitArray}, ::typeof(ndims)) = Position(1)
1717
default_type_parameters(::Type{<:BitArray}) = (1,)
1818

1919
function set_eltype(array::AbstractArray, param)
20-
return convert(set_eltype(typeof(array), param), array)
20+
return convert(set_eltype(typeof(array), param), array)
2121
end
2222

2323
## This will fail if position of `ndims` is not defined for `type`
2424
function set_ndims(type::Type{<:AbstractArray}, param)
25-
return set_type_parameters(type, ndims, param)
25+
return set_type_parameters(type, ndims, param)
2626
end
2727
function set_ndims(type::Type{<:AbstractArray}, param::NDims)
28-
return set_type_parameters(type, ndims, ndims(param))
28+
return set_type_parameters(type, ndims, ndims(param))
2929
end
3030

3131
# Trait indicating if the AbstractArray type is an array wrapper.
@@ -47,48 +47,48 @@ is_wrapped_array(arraytype::Type{<:AbstractArray}) = (parenttype(arraytype) ≠
4747
using SimpleTraits: Not, @traitfn
4848

4949
@traitfn function unwrap_array_type(
50-
arraytype::Type{ArrayType}
51-
) where {ArrayType;IsWrappedArray{ArrayType}}
52-
return unwrap_array_type(parenttype(arraytype))
50+
arraytype::Type{ArrayType}
51+
) where {{ArrayType; IsWrappedArray{ArrayType}}}
52+
return unwrap_array_type(parenttype(arraytype))
5353
end
5454

5555
@traitfn function unwrap_array_type(
56-
arraytype::Type{ArrayType}
57-
) where {ArrayType;!IsWrappedArray{ArrayType}}
58-
return arraytype
56+
arraytype::Type{ArrayType}
57+
) where {{ArrayType; !IsWrappedArray{ArrayType}}}
58+
return arraytype
5959
end
6060

6161
# For working with instances.
6262
unwrap_array_type(array::AbstractArray) = unwrap_array_type(typeof(array))
6363

6464
function set_parenttype(t::Type, param)
65-
return set_type_parameters(t, parenttype, param)
65+
return set_type_parameters(t, parenttype, param)
6666
end
6767

6868
@traitfn function set_eltype(
69-
type::Type{ArrayType}, param
70-
) where {ArrayType<:AbstractArray;IsWrappedArray{ArrayType}}
71-
new_parenttype = set_eltype(parenttype(type), param)
72-
# Need to set both in one `set_type_parameters` call to avoid
73-
# conflicts in type parameter constraints of certain wrapper types.
74-
return set_type_parameters(type, (eltype, parenttype), (param, new_parenttype))
69+
type::Type{ArrayType}, param
70+
) where {{ArrayType <: AbstractArray; IsWrappedArray{ArrayType}}}
71+
new_parenttype = set_eltype(parenttype(type), param)
72+
# Need to set both in one `set_type_parameters` call to avoid
73+
# conflicts in type parameter constraints of certain wrapper types.
74+
return set_type_parameters(type, (eltype, parenttype), (param, new_parenttype))
7575
end
7676

7777
@traitfn function set_eltype(
78-
type::Type{ArrayType}, param
79-
) where {ArrayType<:AbstractArray;!IsWrappedArray{ArrayType}}
80-
return set_type_parameters(type, eltype, param)
78+
type::Type{ArrayType}, param
79+
) where {{ArrayType <: AbstractArray; !IsWrappedArray{ArrayType}}}
80+
return set_type_parameters(type, eltype, param)
8181
end
8282

8383
for wrapper in [:PermutedDimsArray, :(Base.ReshapedArray), :SubArray]
84-
@eval begin
85-
position(type::Type{<:$wrapper}, ::typeof(eltype)) = Position(1)
86-
position(type::Type{<:$wrapper}, ::typeof(ndims)) = Position(2)
87-
end
84+
@eval begin
85+
position(type::Type{<:$wrapper}, ::typeof(eltype)) = Position(1)
86+
position(type::Type{<:$wrapper}, ::typeof(ndims)) = Position(2)
87+
end
8888
end
8989
for wrapper in [:(Base.ReshapedArray), :SubArray]
90-
@eval position(type::Type{<:$wrapper}, ::typeof(parenttype)) = Position(3)
90+
@eval position(type::Type{<:$wrapper}, ::typeof(parenttype)) = Position(3)
9191
end
9292
for wrapper in [:PermutedDimsArray]
93-
@eval position(type::Type{<:$wrapper}, ::typeof(parenttype)) = Position(5)
93+
@eval position(type::Type{<:$wrapper}, ::typeof(parenttype)) = Position(5)
9494
end
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
using LinearAlgebra:
2-
Adjoint,
3-
Diagonal,
4-
Hermitian,
5-
LowerTriangular,
6-
Symmetric,
7-
Transpose,
8-
UnitLowerTriangular,
9-
UnitUpperTriangular,
10-
UpperTriangular
2+
Adjoint,
3+
Diagonal,
4+
Hermitian,
5+
LowerTriangular,
6+
Symmetric,
7+
Transpose,
8+
UnitLowerTriangular,
9+
UnitUpperTriangular,
10+
UpperTriangular
1111

1212
for wrapper in [
13-
:Transpose,
14-
:Adjoint,
15-
:Symmetric,
16-
:Hermitian,
17-
:UpperTriangular,
18-
:LowerTriangular,
19-
:UnitUpperTriangular,
20-
:UnitLowerTriangular,
21-
:Diagonal,
22-
]
23-
@eval position(::Type{<:$wrapper}, ::typeof(eltype)) = Position(1)
24-
@eval position(::Type{<:$wrapper}, ::typeof(parenttype)) = Position(2)
13+
:Transpose,
14+
:Adjoint,
15+
:Symmetric,
16+
:Hermitian,
17+
:UpperTriangular,
18+
:LowerTriangular,
19+
:UnitUpperTriangular,
20+
:UnitLowerTriangular,
21+
:Diagonal,
22+
]
23+
@eval position(::Type{<:$wrapper}, ::typeof(eltype)) = Position(1)
24+
@eval position(::Type{<:$wrapper}, ::typeof(parenttype)) = Position(2)
2525
end

NDTensors/src/vendored/TypeParameterAccessors/src/base/similartype.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,75 +5,75 @@ like `OffsetArrays` or named indices
55
(such as ITensors).
66
"""
77
function set_indstype(arraytype::Type{<:AbstractArray}, dims::Tuple)
8-
return set_ndims(arraytype, NDims(length(dims)))
8+
return set_ndims(arraytype, NDims(length(dims)))
99
end
1010

1111
function similartype(arraytype::Type{<:AbstractArray}, eltype::Type, ndims::NDims)
12-
return similartype(similartype(arraytype, eltype), ndims)
12+
return similartype(similartype(arraytype, eltype), ndims)
1313
end
1414

1515
function similartype(arraytype::Type{<:AbstractArray}, eltype::Type, dims::Tuple)
16-
return similartype(similartype(arraytype, eltype), dims)
16+
return similartype(similartype(arraytype, eltype), dims)
1717
end
1818

1919
@traitfn function similartype(
20-
arraytype::Type{ArrayT}
21-
) where {ArrayT;!IsWrappedArray{ArrayT}}
22-
return arraytype
20+
arraytype::Type{ArrayT}
21+
) where {{ArrayT; !IsWrappedArray{ArrayT}}}
22+
return arraytype
2323
end
2424

2525
@traitfn function similartype(
26-
arraytype::Type{ArrayT}, eltype::Type
27-
) where {ArrayT;!IsWrappedArray{ArrayT}}
28-
return set_eltype(arraytype, eltype)
26+
arraytype::Type{ArrayT}, eltype::Type
27+
) where {{ArrayT; !IsWrappedArray{ArrayT}}}
28+
return set_eltype(arraytype, eltype)
2929
end
3030

3131
function similartype(arraytype::Type{<:BitArray}, elt::Type)
32-
if is_parameter_specified(arraytype, ndims)
33-
return Array{elt,ndims(arraytype)}
34-
end
35-
return Array{elt}
32+
if is_parameter_specified(arraytype, ndims)
33+
return Array{elt, ndims(arraytype)}
34+
end
35+
return Array{elt}
3636
end
3737

3838
@traitfn function similartype(
39-
arraytype::Type{ArrayT}, dims::Tuple
40-
) where {ArrayT;!IsWrappedArray{ArrayT}}
41-
return set_indstype(arraytype, dims)
39+
arraytype::Type{ArrayT}, dims::Tuple
40+
) where {{ArrayT; !IsWrappedArray{ArrayT}}}
41+
return set_indstype(arraytype, dims)
4242
end
4343

4444
@traitfn function similartype(
45-
arraytype::Type{ArrayT}, ndims::NDims
46-
) where {ArrayT;!IsWrappedArray{ArrayT}}
47-
return set_ndims(arraytype, ndims)
45+
arraytype::Type{ArrayT}, ndims::NDims
46+
) where {{ArrayT; !IsWrappedArray{ArrayT}}}
47+
return set_ndims(arraytype, ndims)
4848
end
4949

5050
function similartype(
51-
arraytype::Type{<:AbstractArray}, dim1::Base.DimOrInd, dim_rest::Base.DimOrInd...
52-
)
53-
return similartype(arraytype, (dim1, dim_rest...))
51+
arraytype::Type{<:AbstractArray}, dim1::Base.DimOrInd, dim_rest::Base.DimOrInd...
52+
)
53+
return similartype(arraytype, (dim1, dim_rest...))
5454
end
5555

5656
## Wrapped arrays
57-
@traitfn function similartype(arraytype::Type{ArrayT}) where {ArrayT;IsWrappedArray{ArrayT}}
58-
return similartype(unwrap_array_type(arraytype), NDims(arraytype))
57+
@traitfn function similartype(arraytype::Type{ArrayT}) where {{ArrayT; IsWrappedArray{ArrayT}}}
58+
return similartype(unwrap_array_type(arraytype), NDims(arraytype))
5959
end
6060

6161
@traitfn function similartype(
62-
arraytype::Type{ArrayT}, eltype::Type
63-
) where {ArrayT;IsWrappedArray{ArrayT}}
64-
return similartype(unwrap_array_type(arraytype), eltype, NDims(arraytype))
62+
arraytype::Type{ArrayT}, eltype::Type
63+
) where {{ArrayT; IsWrappedArray{ArrayT}}}
64+
return similartype(unwrap_array_type(arraytype), eltype, NDims(arraytype))
6565
end
6666

6767
@traitfn function similartype(
68-
arraytype::Type{ArrayT}, dims::Tuple
69-
) where {ArrayT;IsWrappedArray{ArrayT}}
70-
return similartype(unwrap_array_type(arraytype), dims)
68+
arraytype::Type{ArrayT}, dims::Tuple
69+
) where {{ArrayT; IsWrappedArray{ArrayT}}}
70+
return similartype(unwrap_array_type(arraytype), dims)
7171
end
7272

7373
@traitfn function similartype(
74-
arraytype::Type{ArrayT}, ndims::NDims
75-
) where {ArrayT;IsWrappedArray{ArrayT}}
76-
return similartype(unwrap_array_type(arraytype), ndims)
74+
arraytype::Type{ArrayT}, ndims::NDims
75+
) where {{ArrayT; IsWrappedArray{ArrayT}}}
76+
return similartype(unwrap_array_type(arraytype), ndims)
7777
end
7878

7979
# This is for uniform `Diag` storage which uses
@@ -82,12 +82,12 @@ end
8282
# `FillArray` instead. This is a stand-in
8383
# to make things work with the current design.
8484
function similartype(numbertype::Type{<:Number})
85-
return numbertype
85+
return numbertype
8686
end
8787

8888
# Instances
8989
function similartype(array::AbstractArray, eltype::Type, dims...)
90-
return similartype(typeof(array), eltype, dims...)
90+
return similartype(typeof(array), eltype, dims...)
9191
end
9292
similartype(array::AbstractArray, eltype::Type) = similartype(typeof(array), eltype)
9393
similartype(array::AbstractArray, dims...) = similartype(typeof(array), dims...)

0 commit comments

Comments
 (0)