Skip to content

Commit 6a393b8

Browse files
committed
deprecate at-SArray, at-SMatrix, at-MArray and at-MMatrix
1 parent 7277f28 commit 6a393b8

File tree

9 files changed

+26
-31
lines changed

9 files changed

+26
-31
lines changed

src/MArray.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,29 +271,33 @@ macro MArray(ex)
271271
$(esc(ex.args[1]))($(esc(ex.args[2])), MArray{$(esc(Expr(:curly, Tuple, ex.args[3:end]...)))})
272272
end
273273
end
274-
elseif ex.args[1] == :eye
274+
elseif ex.args[1] == :eye # deprecated
275275
if length(ex.args) == 2
276276
return quote
277+
Base.depwarn("`@MArray eye(m)` is deprecated, use `MArray{m,m}(1.0I)` instead", :eye)
277278
MArray{Tuple{$(esc(ex.args[2])), $(esc(ex.args[2]))},Float64}(I)
278279
end
279280
elseif length(ex.args) == 3
280281
# We need a branch, depending if the first argument is a type or a size.
281282
return quote
282283
if isa($(esc(ex.args[2])), DataType)
284+
Base.depwarn("`@MArray eye(T, m)` is deprecated, use `MArray{m,m,T}(I)` instead", :eye)
283285
MArray{Tuple{$(esc(ex.args[3])), $(esc(ex.args[3]))}, $(esc(ex.args[2]))}(I)
284286
else
287+
Base.depwarn("`@MArray eye(m, n)` is deprecated, use `MArray{m,n}(1.0I)` instead", :eye)
285288
MArray{Tuple{$(esc(ex.args[2])), $(esc(ex.args[3]))}, Float64}(I)
286289
end
287290
end
288291
elseif length(ex.args) == 4
289292
return quote
293+
Base.depwarn("`@MArray eye(T, m, n)` is deprecated, use `MArray{m,n,T}(I)` instead", :eye)
290294
MArray{Tuple{$(esc(ex.args[3])), $(esc(ex.args[4]))}, $(esc(ex.args[2]))}(I)
291295
end
292296
else
293297
error("Bad eye() expression for @MArray")
294298
end
295299
else
296-
error("@MArray only supports the zeros(), ones(), rand(), randn(), randexp(), and eye() functions.")
300+
error("@MArray only supports the zeros(), ones(), rand(), randn(), and randexp() functions.")
297301
end
298302
else
299303
error("Bad input for @MArray")

src/MMatrix.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,29 +209,33 @@ macro MMatrix(ex)
209209
else
210210
error("@MMatrix expected a 2-dimensional array expression")
211211
end
212-
elseif ex.args[1] == :eye
212+
elseif ex.args[1] == :eye # deprecated
213213
if length(ex.args) == 2
214214
return quote
215+
Base.depwarn("`@MMatrix eye(m)` is deprecated, use `MMatrix{m,m}(1.0I)` instead", :eye)
215216
MMatrix{$(esc(ex.args[2])),$(esc(ex.args[2])),Float64}(I)
216217
end
217218
elseif length(ex.args) == 3
218219
# We need a branch, depending if the first argument is a type or a size.
219220
return quote
220221
if isa($(esc(ex.args[2])), DataType)
222+
Base.depwarn("`@MMatrix eye(T, m)` is deprecated, use `MMatrix{m,m,T}(I)` instead", :eye)
221223
MMatrix{$(esc(ex.args[3])), $(esc(ex.args[3])), $(esc(ex.args[2]))}(I)
222224
else
225+
Base.depwarn("`@MMatrix eye(m, n)` is deprecated, use `MMatrix{m,n}(1.0I)` instead", :eye)
223226
MMatrix{$(esc(ex.args[2])), $(esc(ex.args[3])), Float64}(I)
224227
end
225228
end
226229
elseif length(ex.args) == 4
227230
return quote
231+
Base.depwarn("`@MMatrix eye(T, m, n)` is deprecated, use `MMatrix{m,n,T}(I)` instead", :eye)
228232
MMatrix{$(esc(ex.args[3])), $(esc(ex.args[4])), $(esc(ex.args[2]))}(I)
229233
end
230234
else
231235
error("Bad eye() expression for @MMatrix")
232236
end
233237
else
234-
error("@MMatrix only supports the zeros(), ones(), rand(), randn(), randexp(), and eye() functions.")
238+
error("@MMatrix only supports the zeros(), ones(), rand(), randn(), and randexp() functions.")
235239
end
236240
else
237241
error("Bad input for @MMatrix")

src/SArray.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,29 +234,33 @@ macro SArray(ex)
234234
$(esc(ex.args[1]))($(esc(ex.args[2])), SArray{$(esc(Expr(:curly, Tuple, ex.args[3:end]...)))})
235235
end
236236
end
237-
elseif ex.args[1] == :eye
237+
elseif ex.args[1] == :eye # deprecated
238238
if length(ex.args) == 2
239239
return quote
240+
Base.depwarn("`@SArray eye(m)` is deprecated, use `SArray{m,m}(1.0I)` instead", :eye)
240241
SArray{Tuple{$(esc(ex.args[2])), $(esc(ex.args[2]))},Float64}(I)
241242
end
242243
elseif length(ex.args) == 3
243244
# We need a branch, depending if the first argument is a type or a size.
244245
return quote
245246
if isa($(esc(ex.args[2])), DataType)
247+
Base.depwarn("`@SArray eye(T, m)` is deprecated, use `SArray{m,m,T}(I)` instead", :eye)
246248
SArray{Tuple{$(esc(ex.args[3])), $(esc(ex.args[3]))}, $(esc(ex.args[2]))}(I)
247249
else
250+
Base.depwarn("`@SArray eye(m, n)` is deprecated, use `SArray{m,n}(1.0I)` instead", :eye)
248251
SArray{Tuple{$(esc(ex.args[2])), $(esc(ex.args[3]))}, Float64}(I)
249252
end
250253
end
251254
elseif length(ex.args) == 4
252255
return quote
256+
Base.depwarn("`@SArray eye(T, m, n)` is deprecated, use `SArray{m,n,T}(I)` instead", :eye)
253257
SArray{Tuple{$(esc(ex.args[3])), $(esc(ex.args[4]))}, $(esc(ex.args[2]))}(I)
254258
end
255259
else
256260
error("Bad eye() expression for @SArray")
257261
end
258262
else
259-
error("@SArray only supports the zeros(), ones(), rand(), randn(), randexp(), and eye() functions.")
263+
error("@SArray only supports the zeros(), ones(), rand(), randn(), and randexp() functions.")
260264
end
261265
else
262266
error("Bad input for @SArray")

src/SMatrix.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,33 @@ macro SMatrix(ex)
183183
else
184184
error("@SMatrix expected a 2-dimensional array expression")
185185
end
186-
elseif ex.args[1] == :eye
186+
elseif ex.args[1] == :eye # deprecated
187187
if length(ex.args) == 2
188188
return quote
189+
Base.depwarn("`@SMatrix eye(m)` is deprecated, use `SMatrix{m,m}(1.0I)` instead", :eye)
189190
SMatrix{$(esc(ex.args[2])),$(esc(ex.args[2])),Float64}(I)
190191
end
191192
elseif length(ex.args) == 3
192193
# We need a branch, depending if the first argument is a type or a size.
193194
return quote
194195
if isa($(esc(ex.args[2])), DataType)
196+
Base.depwarn("`@SMatrix eye(T, m)` is deprecated, use `SMatrix{m,m,T}(I)` instead", :eye)
195197
SMatrix{$(esc(ex.args[3])), $(esc(ex.args[3])), $(esc(ex.args[2]))}(I)
196198
else
199+
Base.depwarn("`@SMatrix eye(m, n)` is deprecated, use `SMatrix{m,n}(1.0I)` instead", :eye)
197200
SMatrix{$(esc(ex.args[2])), $(esc(ex.args[3])), Float64}(I)
198201
end
199202
end
200203
elseif length(ex.args) == 4
201204
return quote
205+
Base.depwarn("`@SMatrix eye(T, m, n)` is deprecated, use `SMatrix{m,n,T}(I)` instead", :eye)
202206
SMatrix{$(esc(ex.args[3])), $(esc(ex.args[4])), $(esc(ex.args[2]))}(I)
203207
end
204208
else
205209
error("Bad eye() expression for @SMatrix")
206210
end
207211
else
208-
error("@SMatrix only supports the zeros(), ones(), rand(), randn(), randexp(), and eye() functions.")
212+
error("@SMatrix only supports the zeros(), ones(), rand(), randn(), and randexp() functions.")
209213
end
210214
else
211215
error("Bad input for @SMatrix")

test/MArray.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@
8787
@test isa(@MArray(randn(Float32, 2, 2, 1)), MArray{Tuple{2,2,1}, Float32})
8888
@test isa(@MArray(randexp(Float32, 2, 2, 1)), MArray{Tuple{2,2,1}, Float32})
8989

90-
test_expand_error(:(@MArray eye(5,6,7,8,9)))
91-
@test ((@MArray eye(Float32, 2))::MArray{Tuple{2,2}, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
92-
@test ((@MArray eye(Float32, 2, 2))::MArray{Tuple{2,2}, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
93-
@test ((@MArray eye(2))::MArray{Tuple{2,2}, Float64}).data === (1.0, 0.0, 0.0, 1.0)
94-
@test ((@MArray eye(2,2))::MArray{Tuple{2,2}, Float64}).data === (1.0, 0.0, 0.0, 1.0)
95-
9690
m = [1 2; 3 4]
9791
@test MArray{Tuple{2,2}}(m) == @MArray [1 2; 3 4]
9892
end

test/MMatrix.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,17 @@
4747
test_expand_error(:(@MMatrix ones(4, 5, 6, 7)))
4848
test_expand_error(:(@MMatrix ones))
4949
test_expand_error(:(@MMatrix sin(1:5)))
50-
test_expand_error(:(@MMatrix eye(4, 5, 6, 7)))
5150
test_expand_error(:(@MMatrix [1; 2; 3; 4]...))
5251

5352
@test ((@MMatrix zeros(2,2))::MMatrix{2, 2, Float64}).data === (0.0, 0.0, 0.0, 0.0)
5453
@test ((@MMatrix fill(3.4, 2,2))::MMatrix{2, 2, Float64}).data === (3.4, 3.4, 3.4, 3.4)
5554
@test ((@MMatrix ones(2,2))::MMatrix{2, 2, Float64}).data === (1.0, 1.0, 1.0, 1.0)
56-
@test ((@MMatrix eye(2))::MMatrix{2, 2, Float64}).data === (1.0, 0.0, 0.0, 1.0)
57-
@test ((@MMatrix eye(2,2))::MMatrix{2, 2, Float64}).data === (1.0, 0.0, 0.0, 1.0)
5855
@test isa(@MMatrix(rand(2,2)), MMatrix{2, 2, Float64})
5956
@test isa(@MMatrix(randn(2,2)), MMatrix{2, 2, Float64})
6057
@test isa(@MMatrix(randexp(2,2)), MMatrix{2, 2, Float64})
6158

6259
@test ((@MMatrix zeros(Float32, 2, 2))::MMatrix{2,2,Float32}).data === (0.0f0, 0.0f0, 0.0f0, 0.0f0)
6360
@test ((@MMatrix ones(Float32, 2, 2))::MMatrix{2,2,Float32}).data === (1.0f0, 1.0f0, 1.0f0, 1.0f0)
64-
@test ((@MMatrix eye(Float32, 2))::MMatrix{2, 2, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
65-
@test ((@MMatrix eye(Float32, 2, 2))::MMatrix{2, 2, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
6661
@test isa(@MMatrix(rand(Float32, 2, 2)), MMatrix{2, 2, Float32})
6762
@test isa(@MMatrix(randn(Float32, 2, 2)), MMatrix{2, 2, Float32})
6863
@test isa(@MMatrix(randexp(Float32, 2, 2)), MMatrix{2, 2, Float32})

test/SArray.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,17 @@
6464
test_expand_error(:(@SArray sin(1:5)))
6565
test_expand_error(:(@SArray fill()))
6666
test_expand_error(:(@SArray fill(1)))
67-
test_expand_error(:(@SArray eye(5,6,7,8,9)))
6867
test_expand_error(:(@SArray [1; 2; 3; 4]...))
6968

7069
@test ((@SArray fill(3.,2,2,1))::SArray{Tuple{2,2,1}, Float64}).data === (3.0, 3.0, 3.0, 3.0)
7170
@test ((@SArray zeros(2,2,1))::SArray{Tuple{2,2,1}, Float64}).data === (0.0, 0.0, 0.0, 0.0)
7271
@test ((@SArray ones(2,2,1))::SArray{Tuple{2,2,1}, Float64}).data === (1.0, 1.0, 1.0, 1.0)
73-
@test ((@SArray eye(2))::SArray{Tuple{2,2}, Float64}).data === (1.0, 0.0, 0.0, 1.0)
74-
@test ((@SArray eye(2,2))::SArray{Tuple{2,2}, Float64}).data === (1.0, 0.0, 0.0, 1.0)
7572
@test isa(@SArray(rand(2,2,1)), SArray{Tuple{2,2,1}, Float64})
7673
@test isa(@SArray(randn(2,2,1)), SArray{Tuple{2,2,1}, Float64})
7774
@test isa(@SArray(randexp(2,2,1)), SArray{Tuple{2,2,1}, Float64})
7875

7976
@test ((@SArray zeros(Float32, 2, 2, 1))::SArray{Tuple{2,2,1},Float32}).data === (0.0f0, 0.0f0, 0.0f0, 0.0f0)
8077
@test ((@SArray ones(Float32, 2, 2, 1))::SArray{Tuple{2,2,1},Float32}).data === (1.0f0, 1.0f0, 1.0f0, 1.0f0)
81-
@test ((@SArray eye(Float32, 2))::SArray{Tuple{2,2}, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
82-
@test ((@SArray eye(Float32, 2, 2))::SArray{Tuple{2,2}, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
8378
@test isa(@SArray(rand(Float32, 2, 2, 1)), SArray{Tuple{2,2,1}, Float32})
8479
@test isa(@SArray(randn(Float32, 2, 2, 1)), SArray{Tuple{2,2,1}, Float32})
8580
@test isa(@SArray(randexp(Float32, 2, 2, 1)), SArray{Tuple{2,2,1}, Float32})

test/SMatrix.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,17 @@
4646
test_expand_error(:(@SMatrix ones(2, 3, 4, 5)))
4747
test_expand_error(:(@SMatrix ones))
4848
test_expand_error(:(@SMatrix sin(1:5)))
49-
test_expand_error(:(@SMatrix eye(2, 3, 4, 5)))
5049
test_expand_error(:(@SMatrix [1; 2; 3; 4]...))
5150

5251
@test ((@SMatrix fill(1.3, 2,2))::SMatrix{2, 2, Float64}).data === (1.3, 1.3, 1.3, 1.3)
5352
@test ((@SMatrix zeros(2,2))::SMatrix{2, 2, Float64}).data === (0.0, 0.0, 0.0, 0.0)
5453
@test ((@SMatrix ones(2,2))::SMatrix{2, 2, Float64}).data === (1.0, 1.0, 1.0, 1.0)
55-
@test ((@SMatrix eye(2))::SMatrix{2, 2, Float64}).data === (1.0, 0.0, 0.0, 1.0)
56-
@test ((@SMatrix eye(2,2))::SMatrix{2, 2, Float64}).data === (1.0, 0.0, 0.0, 1.0)
5754
@test isa(@SMatrix(rand(2,2)), SMatrix{2, 2, Float64})
5855
@test isa(@SMatrix(randn(2,2)), SMatrix{2, 2, Float64})
5956
@test isa(@SMatrix(randexp(2,2)), SMatrix{2, 2, Float64})
6057

6158
@test ((@SMatrix zeros(Float32, 2, 2))::SMatrix{2,2,Float32}).data === (0.0f0, 0.0f0, 0.0f0, 0.0f0)
6259
@test ((@SMatrix ones(Float32, 2, 2))::SMatrix{2,2,Float32}).data === (1.0f0, 1.0f0, 1.0f0, 1.0f0)
63-
@test ((@SMatrix eye(Float32, 2))::SMatrix{2, 2, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
64-
@test ((@SMatrix eye(Float32, 2, 2))::SMatrix{2, 2, Float32}).data === (1.0f0, 0.0f0, 0.0f0, 1.0f0)
6560
@test isa(@SMatrix(rand(Float32, 2, 2)), SMatrix{2, 2, Float32})
6661
@test isa(@SMatrix(randn(Float32, 2, 2)), SMatrix{2, 2, Float32})
6762
@test isa(@SMatrix(randexp(Float32, 2, 2)), SMatrix{2, 2, Float32})

test/solve.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ using StaticArrays, Test, LinearAlgebra
1010
@test m(A)\v(b) A\b
1111
end
1212

13-
m1 = @SMatrix eye(5)
14-
m2 = @SMatrix eye(2)
13+
m1 = SMatrix{5,5}(1.0I)
14+
m2 = SMatrix{2,2}(1.0I)
1515
v = @SVector ones(4)
1616
@test_throws DimensionMismatch m1\v
1717
@test_throws DimensionMismatch m1\m2

0 commit comments

Comments
 (0)