Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit 81520a4

Browse files
committed
Move array to deprecated.
1 parent a9e9186 commit 81520a4

File tree

3 files changed

+112
-112
lines changed

3 files changed

+112
-112
lines changed

src/dataarray.jl

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -326,40 +326,6 @@ function Base.find(da::DataArray{Bool}) # -> Array{Int}
326326
return res
327327
end
328328

329-
#' @description
330-
#'
331-
#' Turn a DataArray into an Array. Raises an error if NA's are encountered.
332-
#'
333-
#' @param da::DataArray{T} DataArray that will be converted to an Array.
334-
#'
335-
#' @returns a::Array{T} Array containing values of `da`.
336-
#'
337-
#' @examples
338-
#'
339-
#' dv = @data [1, 2, 3, 4]
340-
#' v = convert(Vector, dv)
341-
#'
342-
#' dm = @data [1 2; 3 4]
343-
#' m = convert(Matrix, dm)
344-
function array{T}(da::DataArray{T}) # -> Array{T}
345-
Base.depwarn(
346-
"""
347-
array(da::DataArray{T}) is deprecated.
348-
Use convert(Array, da).
349-
""",
350-
:array
351-
)
352-
res = Array(T, size(da))
353-
for i in 1:length(da)
354-
if da.na[i]
355-
throw(NAException())
356-
else
357-
res[i] = da.data[i]
358-
end
359-
end
360-
return res
361-
end
362-
363329
#' @description
364330
#'
365331
#' Convert a DataArray{T} to an Array{S}. Throws an `NAException`
@@ -403,43 +369,6 @@ function Base.convert{T, N}(::Type{Array}, da::DataArray{T, N})
403369
return convert(Array{T, N}, da)
404370
end
405371

406-
#' @description
407-
#'
408-
#' Turn a DataArray into an Array. Replace any NA's with the value
409-
#' of second argument, `replacement`.
410-
#'
411-
#' @param da::DataArray{T} DataArray that will be converted to an Array.
412-
#' @param replacement::T Value that will replace NA's in `da`.
413-
#'
414-
#' @returns a::Array{T} Array containing values of `da` plus replacements.
415-
#'
416-
#' @examples
417-
#'
418-
#' dv = @data [1, 2, NA, 4]
419-
#' v = convert(Vector, dv, 3)
420-
#'
421-
#' dm = @data [1 2; NA 4]
422-
#' m = convert(Matrix, dm, 3)
423-
function array{T}(da::DataArray{T}, replacement::Any) # -> Array{T}
424-
Base.depwarn(
425-
"""
426-
array(da::DataArray{T}, replacement::Any) is deprecated.
427-
Use convert(Array, da, replacement) instead.
428-
""",
429-
:array
430-
)
431-
res = Array(T, size(da))
432-
replacementT = convert(T, replacement)
433-
for i in 1:length(da)
434-
if da.na[i]
435-
res[i] = replacementT
436-
else
437-
res[i] = da.data[i]
438-
end
439-
end
440-
return res
441-
end
442-
443372
function Base.convert{S, T, N}(
444373
::Type{Array{S, N}},
445374
da::DataArray{T, N},

src/deprecated.jl

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,115 @@
22
# when the deprecation is removed
33
import Base.@deprecate
44
@deprecate (/)(x::Union(NAtype,Number),A::AbstractDataArray) x ./ A
5+
6+
#' @description
7+
#'
8+
#' Turn a DataArray into an Array. Raises an error if NA's are encountered.
9+
#'
10+
#' @param da::DataArray{T} DataArray that will be converted to an Array.
11+
#'
12+
#' @returns a::Array{T} Array containing values of `da`.
13+
#'
14+
#' @examples
15+
#'
16+
#' dv = @data [1, 2, 3, 4]
17+
#' v = convert(Vector, dv)
18+
#'
19+
#' dm = @data [1 2; 3 4]
20+
#' m = convert(Matrix, dm)
21+
function array{T}(da::DataArray{T}) # -> Array{T}
22+
Base.depwarn(
23+
"""
24+
array(da::DataArray{T}) is deprecated.
25+
Use convert(Array, da).
26+
""",
27+
:array
28+
)
29+
res = Array(T, size(da))
30+
for i in 1:length(da)
31+
if da.na[i]
32+
throw(NAException())
33+
else
34+
res[i] = da.data[i]
35+
end
36+
end
37+
return res
38+
end
39+
40+
#' @description
41+
#'
42+
#' Turn a DataArray into an Array. Replace any NA's with the value
43+
#' of second argument, `replacement`.
44+
#'
45+
#' @param da::DataArray{T} DataArray that will be converted to an Array.
46+
#' @param replacement::T Value that will replace NA's in `da`.
47+
#'
48+
#' @returns a::Array{T} Array containing values of `da` plus replacements.
49+
#'
50+
#' @examples
51+
#'
52+
#' dv = @data [1, 2, NA, 4]
53+
#' v = convert(Vector, dv, 3)
54+
#'
55+
#' dm = @data [1 2; NA 4]
56+
#' m = convert(Matrix, dm, 3)
57+
function array{T}(da::DataArray{T}, replacement::Any) # -> Array{T}
58+
Base.depwarn(
59+
"""
60+
array(da::DataArray{T}, replacement::Any) is deprecated.
61+
Use convert(Array, da, replacement) instead.
62+
""",
63+
:array
64+
)
65+
res = Array(T, size(da))
66+
replacementT = convert(T, replacement)
67+
for i in 1:length(da)
68+
if da.na[i]
69+
res[i] = replacementT
70+
else
71+
res[i] = da.data[i]
72+
end
73+
end
74+
return res
75+
end
76+
77+
# Turn a PooledDataArray into an Array. Fail on NA
78+
function array{T, R}(da::PooledDataArray{T, R})
79+
Base.depwarn(
80+
"""
81+
array(pda::PooledDataArray{T, R}) is deprecated.
82+
Use convert(Array, pda) instead.
83+
""",
84+
:array
85+
)
86+
n = length(da)
87+
res = Array(T, size(da))
88+
for i in 1:n
89+
if da.refs[i] == zero(R)
90+
throw(NAException())
91+
else
92+
res[i] = da.pool[da.refs[i]]
93+
end
94+
end
95+
return res
96+
end
97+
98+
function array{T, R}(da::PooledDataArray{T, R}, replacement::T)
99+
Base.depwarn(
100+
"""
101+
array(pda::PooledDataArray{T, R}, replacement::T) is deprecated.
102+
Use convert(Array, pda, replacement) instead.
103+
""",
104+
:array
105+
)
106+
n = length(da)
107+
res = Array(T, size(da))
108+
for i in 1:n
109+
if da.refs[i] == zero(R)
110+
res[i] = replacement
111+
else
112+
res[i] = da.pool[da.refs[i]]
113+
end
114+
end
115+
return res
116+
end

src/pooleddataarray.jl

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -763,27 +763,6 @@ Base.convert{T,R<:Integer,N}(::Type{DataArray}, pda::PooledDataArray{T,R,N}) =
763763

764764
pdata(a::AbstractArray) = convert(PooledDataArray, a)
765765

766-
# Turn a PooledDataArray into an Array. Fail on NA
767-
function array{T, R}(da::PooledDataArray{T, R})
768-
Base.depwarn(
769-
"""
770-
array(pda::PooledDataArray{T, R}) is deprecated.
771-
Use convert(Array, pda) instead.
772-
""",
773-
:array
774-
)
775-
n = length(da)
776-
res = Array(T, size(da))
777-
for i in 1:n
778-
if da.refs[i] == zero(R)
779-
throw(NAException())
780-
else
781-
res[i] = da.pool[da.refs[i]]
782-
end
783-
end
784-
return res
785-
end
786-
787766
function Base.convert{S, T, R, N}(
788767
::Type{Array{S, N}},
789768
pda::PooledDataArray{T, R, N}
@@ -811,26 +790,6 @@ function Base.convert{T, R, N}(::Type{Array}, pda::PooledDataArray{T, R, N})
811790
return convert(Array{T, N}, pda)
812791
end
813792

814-
function array{T, R}(da::PooledDataArray{T, R}, replacement::T)
815-
Base.depwarn(
816-
"""
817-
array(pda::PooledDataArray{T, R}, replacement::T) is deprecated.
818-
Use convert(Array, pda, replacement) instead.
819-
""",
820-
:array
821-
)
822-
n = length(da)
823-
res = Array(T, size(da))
824-
for i in 1:n
825-
if da.refs[i] == zero(R)
826-
res[i] = replacement
827-
else
828-
res[i] = da.pool[da.refs[i]]
829-
end
830-
end
831-
return res
832-
end
833-
834793
function Base.convert{S, T, R, N}(
835794
::Type{Array{S, N}},
836795
pda::PooledDataArray{T, R, N},

0 commit comments

Comments
 (0)