-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathdeprecated.jl
356 lines (311 loc) · 14.9 KB
/
deprecated.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
macro deprecate(old,new)
if isa(old,Symbol)
oldname = Expr(:quote,old)
newname = Expr(:quote,new)
Expr(:toplevel,
Expr(:export,esc(old)),
:(function $(esc(old))(args...)
depwarn(string($oldname," is deprecated, use ",$newname," instead."),
$oldname)
$(esc(new))(args...)
end))
elseif isa(old,Expr) && old.head == :call
oldcall = sprint(io->show_unquoted(io,old))
newcall = sprint(io->show_unquoted(io,new))
oldname = Expr(:quote, old.args[1])
Expr(:toplevel,
Expr(:export,esc(old.args[1])),
:($(esc(old)) = begin
depwarn(string($oldcall," is deprecated, use ",$newcall," instead."),
$oldname)
$(esc(new))
end))
else
error("invalid usage of @deprecate")
end
end
function depwarn(msg, funcsym)
bt = backtrace()
caller = firstcaller(bt, funcsym)
warn(msg, once=(caller!=C_NULL), key=caller, bt=bt)
end
function firstcaller(bt::Array{Ptr{None},1}, funcsym::Symbol)
# Identify the calling line
i = 1
while i <= length(bt)
lkup = ccall(:jl_lookup_code_address, Any, (Ptr{Void}, Int32), bt[i], 0)
i += 1
if lkup === ()
continue
end
fname, file, line = lkup
if fname == funcsym
break
end
end
if i <= length(bt)
return bt[i]
end
return C_NULL
end
# 0.1
const IOString = IOBuffer
export IOString
const PipeString = PipeBuffer
export PipeString
# 0.2
@deprecate A_mul_B(A,B,C) A_mul_B!(A,B,C)
@deprecate A_mul_Bt(A,B,C) A_mul_Bt!(A,B,C)
@deprecate At_mul_B(A,B,C) At_mul_B!(A,B,C)
@deprecate At_mul_Bt(A,B,C) At_mul_Bt!(A,B,C)
@deprecate Ac_mul_B(A,B,C) Ac_mul_B!(A,B,C)
@deprecate A_mul_Bc(A,B,C) A_mul_Bc!(A,B,C)
@deprecate Ac_mul_Bc(A,B,C) Ac_mul_Bc!(A,B,C)
@deprecate Ac_mul_Bt(A,B,C) Ac_mul_Bt!(A,B,C)
@deprecate strchr search
@deprecate iswriteable iswritable
@deprecate localize localpart
@deprecate logb exponent
@deprecate ilogb exponent
@deprecate ref_shape index_shape
@deprecate assign_shape_check setindex_shape_check
@deprecate quote_string repr
@deprecate safe_char(c) (is_valid_char(char(c))||error())&&char(c)
@deprecate check_ascii(x) (is_valid_ascii(x)?x:error())
@deprecate check_utf8(x) (is_valid_utf8(x)?x:error())
@deprecate each_line eachline
@deprecate each_match eachmatch
@deprecate function_loc functionloc
@deprecate compile_hint precompile
@deprecate begins_with beginswith
@deprecate ends_with endswith
@deprecate parse_float parsefloat
@deprecate parse_int parseint
@deprecate parse_bin(T,s) parseint(T,s,2)
@deprecate parse_bin(s) parseint(s,2)
@deprecate parse_oct(T,s) parseint(T,s,8)
@deprecate parse_oct(s) parseint(s,8)
@deprecate parse_hex(T,s) parseint(T,s,16)
@deprecate parse_hex(s) parseint(s,16)
@deprecate wait_accept accept
@deprecate findn_nzs findnz
@deprecate DivideByZeroError DivideError
@deprecate cartesian_map cartesianmap
@deprecate check_bounds checkbounds
@deprecate system_error systemerror
@deprecate seek_end seekend
@deprecate addprocs_ssh_tunnel(m) addprocs(m, tunnel=true)
@deprecate addprocs_ssh addprocs
@deprecate addprocs_local addprocs
@deprecate remote_call remotecall
@deprecate remote_call_fetch remotecall_fetch
@deprecate remote_call_wait remotecall_wait
@deprecate has(s::Set, x) contains(s, x)
@deprecate has(s::IntSet, x) contains(s, x)
@deprecate has(d,k) haskey(d,k)
@deprecate diagmm scale
@deprecate diagmm! scale!
@deprecate unsafe_ref unsafe_load
@deprecate unsafe_assign unsafe_store!
@deprecate add_each! union!
@deprecate del_each! setdiff!
@deprecate real_valued isreal
@deprecate integer_valued isinteger
@deprecate isdenormal issubnormal
@deprecate get_precision precision
@deprecate expr(hd, a...) Expr(hd, a...)
@deprecate expr(hd, a::Array{Any,1}) Expr(hd, a...)
@deprecate readdir(cmd::Cmd) readdir(string(cmd)[2:end-1])
@deprecate isbool(x) iseltype(x,Bool)
@deprecate iscomplex(x) iseltype(x,Complex)
@deprecate lstrip(a::String, b::String) lstrip(a, collect(b))
@deprecate rstrip(a::String, b::String) rstrip(a, collect(b))
@deprecate delete!(a::Vector, x) splice!(a, x)
@deprecate delete!(a::BitVector, x) splice!(a, x)
@deprecate |(s::Set...) union(s...)
@deprecate (&)(s::Set...) intersect(s...)
@deprecate -(a::Set, b::Set) setdiff(a,b)
@deprecate ($)(s1::IntSet, s2::IntSet) symdiff(s1,s2)
@deprecate |(s::IntSet, s2::IntSet) union(s, s2)
@deprecate (&)(s::IntSet, s2::IntSet) intersect(s, s2)
@deprecate -(a::IntSet, b::IntSet) setdiff(a,b)
@deprecate ~(s::IntSet) complement(s)
@deprecate openblas_set_num_threads blas_set_num_threads
@deprecate check_openblas check_blas
@deprecate msync(A::Array, flags::Int) msync(A)
@deprecate msync(A::BitArray, flags::Int) msync(A)
@deprecate square(x::Number) x*x
@deprecate finfer code_typed
@deprecate disassemble(f::Function,t::Tuple) code_llvm(f,t)
@deprecate disassemble(f::Function,t::Tuple,asm::Bool) (asm ? code_native(f,t) : code_llvm(f,t))
@deprecate add(s::Set, x) push!(s,x)
@deprecate add!(s::Set, x) push!(s,x)
@deprecate add(s::IntSet, x) push!(s,x)
@deprecate add!(s::IntSet, x) push!(s,x)
@deprecate delete!(d::Dict, key, default) pop!(d, key, default)
@deprecate get(A::Array, B::Array, I, default) get!(A, B, I, default)
@deprecate repl_show(io, x) writemime(io, MIME"text/plain"(), x)
@deprecate error_show showerror
@deprecate eatwspace(io) skipchars(io, isspace)
@deprecate eatwspace_comment(io, cmt) skipchars(io, isspace, linecomment=cmt)
@deprecate open_any_tcp_port listenany
@deprecate subtype issubtype
@deprecate bsxfun broadcast
@deprecate max(x) maximum(x)
@deprecate min(x) minimum(x)
@deprecate max(f::Function,x) maximum(f,x)
@deprecate min(f::Function,x) minimum(f,x)
@deprecate max(x,_::(),d) maximum(x,d)
@deprecate min(x,_::(),d) minimum(x,d)
@deprecate assert(x,y) (@assert x y)
# NOTE: when this deprecation is removed, also remove
# copy!(dest::AbstractArray, doffs::Integer, src::Integer)
# in abstractarray.jl
@deprecate copy!(dest::AbstractArray, src, doffs::Integer) copy!(dest, doffs, src)
deprecated_ls() = run(`ls -l`)
deprecated_ls(args::Cmd) = run(`ls -l $args`)
deprecated_ls(args::String...) = run(`ls -l $args`)
function ls(args...)
depwarn("ls() is deprecated, use readdir() instead. If you are at the repl prompt, consider `;ls`.", :ls)
deprecated_ls(args...)
end
export ls
function start_timer(timer::Timer, timeout::Int, repeat::Int)
depwarn("start_timer now expects arguments in units of seconds. you may need to update your code", :start_timer)
invoke(start_timer, (Timer,Real,Real), timer, timeout, repeat)
end
# redirection operators
@deprecate |(a::AbstractCmd,b::AbstractCmd) (a|>b)
@deprecate >(a::Redirectable,b::AbstractCmd) (a|>b)
@deprecate >(a::String,b::AbstractCmd) (a|>b)
@deprecate >(a::AbstractCmd,b::Redirectable) (a|>b)
@deprecate >(a::AbstractCmd,b::String) (a|>b)
@deprecate <(a::AbstractCmd,b::String) (b|>a)
@deprecate |(x, f::Function) (x|>f)
@deprecate SpawnNullStream() DevNull
@deprecate memio(args...) IOBuffer()
@deprecate user_homedir homedir
@deprecate user_prefdir homedir
@deprecate user_documentsdir homedir
# note removed macros: str, B_str, I_str, E_str, L_str, L_mstr, I_mstr, E_mstr
const ref = getindex
export ref
const assign = setindex!
export assign
const TimeoutAsyncWork = Timer
export TimeoutAsyncWork
# will be removed from exports (moved into Base.Sys): OS_NAME, WORD_SIZE, CPU_CORES
typealias ComplexPair Complex
export ComplexPair
# superseded sorting API
@deprecate select(v::AbstractVector,k::Union(Int,Range1),o::Ordering) select(v,k,order=o)
@deprecate select(v::AbstractVector,k::Union(Int,Range1),f::Function) select(v,k,lt=f)
@deprecate select(f::Function,v::AbstractVector,k::Union(Int,Range1)) select(v,k,lt=f)
# @deprecate select!(v::AbstractVector,k::Union(Int,Range1),o::Ordering) select!(v,k,order=o)
@deprecate select!(v::AbstractVector,k::Union(Int,Range1),f::Function) select!(v,k,lt=f)
@deprecate select!(f::Function,v::AbstractVector,k::k::Union(Int,Range1)) select!(v,k,lt=f)
@deprecate sort(v::AbstractVector,o::Ordering) sort(v,order=o)
@deprecate sort(v::AbstractVector,a::Algorithm) sort(v,alg=a)
@deprecate sort(v::AbstractVector,a::Algorithm,o::Ordering) sort(v,alg=a,order=o)
@deprecate sort(v::AbstractVector,o::Ordering,a::Algorithm) sort(v,alg=a,order=o)
@deprecate sort(v::AbstractVector,f::Function) sort(v,lt=f)
@deprecate sort(f::Function,v::AbstractVector) sort(v,lt=f)
@deprecate sort(v::AbstractVector,a::Algorithm,f::Function) sort(v,alg=a,lt=f)
@deprecate sort(v::AbstractVector,f::Function,a::Algorithm) sort(v,alg=a,lt=f)
@deprecate sort(f::Function,v::AbstractVector,a::Algorithm) sort(v,alg=a,lt=f)
@deprecate sort!(v::AbstractVector,o::Ordering) sort!(v,order=o)
@deprecate sort!(v::AbstractVector,a::Algorithm) sort!(v,alg=a)
# @deprecate sort!(v::AbstractVector,a::Algorithm,o::Ordering) sort!(v,alg=a,order=o)
@deprecate sort!(v::AbstractVector,o::Ordering,a::Algorithm) sort!(v,alg=a,order=o)
@deprecate sort!(v::AbstractVector,f::Function) sort!(v,lt=f)
@deprecate sort!(f::Function,v::AbstractVector) sort!(v,lt=f)
@deprecate sort!(v::AbstractVector,a::Algorithm,f::Function) sort!(v,alg=a,lt=f)
@deprecate sort!(v::AbstractVector,f::Function,a::Algorithm) sort!(v,alg=a,lt=f)
@deprecate sort!(f::Function,v::AbstractVector,a::Algorithm) sort!(v,alg=a,lt=f)
@deprecate sortperm(v::AbstractVector,o::Ordering) sortperm(v,order=o)
@deprecate sortperm(v::AbstractVector,a::Algorithm) sortperm(v,alg=a)
@deprecate sortperm(v::AbstractVector,a::Algorithm,o::Ordering) sortperm(v,alg=a,order=o)
@deprecate sortperm(v::AbstractVector,o::Ordering,a::Algorithm) sortperm(v,alg=a,order=o)
@deprecate sortperm(v::AbstractVector,f::Function) sortperm(v,lt=f)
@deprecate sortperm(f::Function,v::AbstractVector) sortperm(v,lt=f)
@deprecate sortperm(v::AbstractVector,a::Algorithm,f::Function) sortperm(v,alg=a,lt=f)
@deprecate sortperm(v::AbstractVector,f::Function,a::Algorithm) sortperm(v,alg=a,lt=f)
@deprecate sortperm(f::Function,v::AbstractVector,a::Algorithm) sortperm(v,alg=a,lt=f)
@deprecate sort(v::AbstractVector,d::Integer,o::Ordering) sort(v,d,order=o)
@deprecate sort(v::AbstractVector,d::Integer,a::Algorithm) sort(v,d,alg=a)
@deprecate sort(v::AbstractVector,d::Integer,a::Algorithm,o::Ordering) sort(v,d,alg=a,order=o)
@deprecate sort(v::AbstractVector,d::Integer,o::Ordering,a::Algorithm) sort(v,d,alg=a,order=o)
@deprecate sort!(v::AbstractVector,d::Integer,o::Ordering) sort!(v,d,order=o)
@deprecate sort!(v::AbstractVector,d::Integer,a::Algorithm) sort!(v,d,alg=a)
@deprecate sort!(v::AbstractVector,d::Integer,a::Algorithm,o::Ordering) sort!(v,d,alg=a,order=o)
@deprecate sort!(v::AbstractVector,d::Integer,o::Ordering,a::Algorithm) sort!(v,d,alg=a,order=o)
@deprecate sortby(v::AbstractVector,f::Function) sort(v,by=f)
@deprecate sortby(f::Function,v::AbstractVector) sort(v,by=f)
@deprecate sortby(v::AbstractVector,a::Algorithm,f::Function) sort(v,alg=a,by=f)
@deprecate sortby(v::AbstractVector,f::Function,a::Algorithm) sort(v,alg=a,by=f)
@deprecate sortby(f::Function,v::AbstractVector,a::Algorithm) sort(v,alg=a,by=f)
@deprecate sortby!(v::AbstractVector,f::Function) sort!(v,by=f)
@deprecate sortby!(f::Function,v::AbstractVector) sort!(v,by=f)
@deprecate sortby!(v::AbstractVector,a::Algorithm,f::Function) sort!(v,alg=a,by=f)
@deprecate sortby!(v::AbstractVector,f::Function,a::Algorithm) sort!(v,alg=a,by=f)
@deprecate sortby!(f::Function,v::AbstractVector,a::Algorithm) sort!(v,alg=a,by=f)
@deprecate sortrows(v::AbstractMatrix,o::Ordering) sortrows(v,order=o)
@deprecate sortrows(v::AbstractMatrix,a::Algorithm) sortrows(v,alg=a)
@deprecate sortrows(v::AbstractMatrix,a::Algorithm,o::Ordering) sortrows(v,alg=a,order=o)
@deprecate sortrows(v::AbstractMatrix,o::Ordering,a::Algorithm) sortrows(v,alg=a,order=o)
@deprecate sortcols(v::AbstractMatrix,o::Ordering) sortcols(v,order=o)
@deprecate sortcols(v::AbstractMatrix,a::Algorithm) sortcols(v,alg=a)
@deprecate sortcols(v::AbstractMatrix,a::Algorithm,o::Ordering) sortcols(v,alg=a,order=o)
@deprecate sortcols(v::AbstractMatrix,o::Ordering,a::Algorithm) sortcols(v,alg=a,order=o)
@deprecate parse(str::String, pos::Int, greedy::Bool, raise::Bool) parse(str,pos,greedy=greedy,raise=raise)
@deprecate parse(str::String, pos::Int, greedy::Bool) parse(str,pos,greedy=greedy)
function amap(f::Function, A::AbstractArray, axis::Integer)
depwarn("amap is deprecated, use mapslices(f, A, dims) instead", :amap)
dimsA = size(A)
ndimsA = ndims(A)
axis_size = dimsA[axis]
if axis_size == 0
return f(A)
end
idx = ntuple(ndimsA, j -> j == axis ? 1 : 1:dimsA[j])
r = f(sub(A, idx))
R = Array(typeof(r), axis_size)
R[1] = r
for i = 2:axis_size
idx = ntuple(ndimsA, j -> j == axis ? i : 1:dimsA[j])
R[i] = f(sub(A, idx))
end
return R
end
# Conditional usage of packages and modules
function usingmodule(names::Symbol...)
depwarn("usingmodule is deprecated, use using instead", :usingmodule)
eval(current_module(), Expr(:toplevel, Expr(:using, names...)))
end
function usingmodule(names::String)
depwarn("usingmodule is deprecated, use using instead", :usingmodule)
usingmodule([symbol(name) for name in split(names,".")]...)
end
export usingmodule
# 0.2 discontinued functions
function addprocs_scyld(np::Integer)
error("Base.addprocs_scyld is discontinued - add package ClusterManagers and then use ClusterManagers.addprocs_scyld instead.")
end
export addprocs_scyld
function addprocs_sge(np::Integer)
error("Base.addprocs_sge is discontinued - add package ClusterManagers and then use ClusterManagers.addprocs_sge instead.")
end
export addprocs_sge
function integer_partitions(n,m)
error("integer_partitions(n,m) has been renamed to partitions(n,m), and is now an iterator. Please update your code.")
end
export integer_partitions
function mmread(file)
error("mmread(file) is discontinued - add package MatrixMarket and use MatrixMarket.mmread instead.")
end
function mmread(file, infoonly)
error("mmread(file, infoonly) is discontinued - add package MatrixMarket and use MatrixMarket.mmread instead.")
end
export mmread
# 0.3 deprecations
# 0.3 discontinued functions