@@ -5,7 +5,7 @@ abstract NULL
55
66Base. showcompact (io:: IO , :: Type{NULL} ) = show (io, NULL)
77Base. show (io:: IO , :: Type{NULL} ) = print (io, " #NULL" )
8- Base. alignment (:: Type{NULL} ) = (5 ,0 )
8+ Base. alignment (io :: IO , :: Type{NULL} ) = (5 ,0 )
99
1010function Base. show (io:: IO , X:: NullableArray )
1111 print (io, typeof (X))
@@ -25,7 +25,7 @@ function Base.show_delim_array(io::IO, X::NullableArray, op, delim, cl,
2525 multiline = false
2626 else
2727 x = X. isnull[i] ? NULL : X. values[i]
28- multiline = isa (x,AbstractArray) && ndims (x)> 1 && length (x)> 0
28+ multiline = isa (x, AbstractArray) && ndims (x) > 1 && length (x) > 0
2929 newline && multiline && println (io)
3030 if ! isbits (x) && is (x, X)
3131 print (io, " #= circular reference =#" )
@@ -54,19 +54,19 @@ function Base.show_delim_array(io::IO, X::NullableArray, op, delim, cl,
5454end
5555
5656function Base. alignment {T,N,U<:NullableArray} (
57- X:: SubArray{T,N,U} ,
57+ io :: IO , X:: SubArray{T,N,U} ,
5858 rows:: AbstractVector , cols:: AbstractVector ,
5959 cols_if_complete:: Integer , cols_otherwise:: Integer , sep:: Integer
6060)
6161 a = []
6262 for j in cols
6363 l = r = 0
6464 for i in rows
65- if isassigned (X,i, j)
65+ if isassigned (X, i, j)
6666 if isnull (X, i, j)
67- aij = alignment (NULL)
67+ aij = alignment (io, NULL)
6868 else
69- aij = alignment (values (X, i,j))
69+ aij = alignment (io, values (X, i, j))
7070 end
7171 else
7272 aij = undef_ref_alignment
@@ -75,33 +75,33 @@ function Base.alignment{T,N,U<:NullableArray}(
7575 r = max (r, aij[2 ])
7676 end
7777 push! (a, (l, r))
78- if length (a) > 1 && sum (map (sum,a)) + sep* length (a) >= cols_if_complete
78+ if length (a) > 1 && sum (map (sum, a)) + sep* length (a) >= cols_if_complete
7979 pop! (a)
8080 break
8181 end
8282 end
83- if 1 < length (a) < size (X,2 )
84- while sum (map (sum,a)) + sep* length (a) >= cols_otherwise
83+ if 1 < length (a) < size (X, 2 )
84+ while sum (map (sum, a)) + sep* length (a) >= cols_otherwise
8585 pop! (a)
8686 end
8787 end
8888 return a
8989end
9090
9191function Base. alignment (
92- X:: Union{NullableArray, NullableMatrix} ,
92+ io :: IO , X:: Union{NullableArray, NullableMatrix} ,
9393 rows:: AbstractVector , cols:: AbstractVector ,
9494 cols_if_complete:: Integer , cols_otherwise:: Integer , sep:: Integer
9595)
9696 a = []
9797 for j in cols
9898 l = r = 0
9999 for i in rows
100- if isassigned (X,i, j)
100+ if isassigned (X, i, j)
101101 if isnull (X, i, j)
102- aij = alignment (NULL)
102+ aij = alignment (io, NULL)
103103 else
104- aij = alignment (values (X, i,j))
104+ aij = alignment (io, values (X, i, j))
105105 end
106106 else
107107 aij = undef_ref_alignment
@@ -115,52 +115,163 @@ function Base.alignment(
115115 break
116116 end
117117 end
118- if 1 < length (a) < size (X,2 )
119- while sum (map (sum,a)) + sep* length (a) >= cols_otherwise
118+ if 1 < length (a) < size (X, 2 )
119+ while sum (map (sum, a)) + sep* length (a) >= cols_otherwise
120120 pop! (a)
121121 end
122122 end
123123 return a
124124end
125125
126- function Base. print_matrix_row {T,N,P<:NullableArray} (io :: IO ,
127- X:: SubArray{T,N,P} , A:: Vector ,
126+ function Base. print_matrix_row {T,N,P<:NullableArray} (
127+ io :: IO , X:: SubArray{T,N,P} , A:: Vector ,
128128 i:: Integer , cols:: AbstractVector , sep:: AbstractString
129129)
130- for k = 1 : length (A)
131- j = cols[k]
132- if isassigned (X,i,j)
133- x = isnull (X,i,j) ? NULL : values (X,i,j)
134- a = alignment (x)
135- sx = sprint (showcompact_lim, x)
136- else
137- a = undef_ref_alignment
138- sx = undef_ref_str
139- end
140- l = repeat (" " , A[k][1 ]- a[1 ])
141- r = repeat (" " , A[k][2 ]- a[2 ])
142- print (io, l, sx, r)
143- if k < length (A); print (io, sep); end
130+ if VERSION < v " 0.5.0-dev+1936" # compat issues from
131+ # https://github.com/JuliaLang/julia/pull/13825
132+ for k = 1 : length (A)
133+ j = cols[k]
134+ if isassigned (X, i, j)
135+ x = isnull (X, i, j) ? NULL : values (X, i, j)
136+ a = alignment (x)
137+ sx = sprint (showcompact_lim, x)
138+ else
139+ a = undef_ref_alignment
140+ sx = undef_ref_str
141+ end
142+ l = repeat (" " , A[k][1 ]- a[1 ])
143+ r = repeat (" " , A[k][2 ]- a[2 ])
144+ print (io, l, sx, r)
145+ if k < length (A); print (io, sep); end
146+ end
147+ else
148+ for k = 1 : length (A)
149+ j = cols[k]
150+ if isassigned (X, i, j)
151+ x = isnull (X, i, j) ? NULL : values (X, i, j)
152+ a = alignment (io, x)
153+ sx = sprint (showcompact_lim, x)
154+ else
155+ a = undef_ref_alignment
156+ sx = undef_ref_str
157+ end
158+ l = repeat (" " , A[k][1 ]- a[1 ])
159+ r = repeat (" " , A[k][2 ]- a[2 ])
160+ print (io, l, sx, r)
161+ if k < length (A); print (io, sep); end
162+ end
144163 end
145164end
146165
147166function Base. print_matrix_row (io:: IO ,
148167 X:: Union{NullableVector, NullableMatrix} , A:: Vector ,
149168 i:: Integer , cols:: AbstractVector , sep:: AbstractString
150169)
151- for k = 1 : length (A)
152- j = cols[k]
153- if isassigned (X,i,j)
154- x = isnull (X,i,j) ? NULL : values (X,i,j)
155- a = alignment (x)
156- sx = sprint (showcompact_lim, x)
157- else
158- a = undef_ref_alignment
159- sx = undef_ref_str
160- end
161- l = repeat (" " , A[k][1 ]- a[1 ])
162- r = repeat (" " , A[k][2 ]- a[2 ])
163- print (io, l, sx, r)
164- if k < length (A); print (io, sep); end
170+ if VERSION < v " 0.5.0-dev+1936" # compat issues from
171+ # https://github.com/JuliaLang/julia/pull/13825
172+ for k = 1 : length (A)
173+ j = cols[k]
174+ if isassigned (X, i, j)
175+ x = isnull (X, i, j) ? NULL : values (X, i, j)
176+ a = alignment (x)
177+ sx = sprint (showcompact_lim, x)
178+ else
179+ a = undef_ref_alignment
180+ sx = undef_ref_str
181+ end
182+ l = repeat (" " , A[k][1 ]- a[1 ])
183+ r = repeat (" " , A[k][2 ]- a[2 ])
184+ print (io, l, sx, r)
185+ if k < length (A); print (io, sep); end
186+ end
187+ else
188+ for k = 1 : length (A)
189+ j = cols[k]
190+ if isassigned (X, i, j)
191+ x = isnull (X, i, j) ? NULL : values (X, i, j)
192+ a = alignment (io, x)
193+ sx = sprint (showcompact_lim, x)
194+ else
195+ a = undef_ref_alignment
196+ sx = undef_ref_str
197+ end
198+ l = repeat (" " , A[k][1 ]- a[1 ])
199+ r = repeat (" " , A[k][2 ]- a[2 ])
200+ print (io, l, sx, r)
201+ if k < length (A); print (io, sep); end
202+ end
203+ end
204+ end
205+
206+ # Methods for compatibility issues for VERSION < 0.5.0-dev+1936 stemming
207+ # from https://github.com/JuliaLang/julia/pull/13825
208+
209+ Base. alignment (:: Type{NULL} ) = (5 ,0 )
210+ function Base. alignment {T,N,U<:NullableArray} (
211+ X:: SubArray{T,N,U} ,
212+ rows:: AbstractVector , cols:: AbstractVector ,
213+ cols_if_complete:: Integer , cols_otherwise:: Integer , sep:: Integer
214+ )
215+ a = []
216+ for j in cols
217+ l = r = 0
218+ for i in rows
219+ if isassigned (X, i, j)
220+ if isnull (X, i, j)
221+ aij = alignment (NULL)
222+ else
223+ aij = alignment (values (X, i, j))
224+ end
225+ else
226+ aij = undef_ref_alignment
227+ end
228+ l = max (l, aij[1 ])
229+ r = max (r, aij[2 ])
230+ end
231+ push! (a, (l, r))
232+ if length (a) > 1 && sum (map (sum, a)) + sep* length (a) >= cols_if_complete
233+ pop! (a)
234+ break
235+ end
236+ end
237+ if 1 < length (a) < size (X, 2 )
238+ while sum (map (sum, a)) + sep* length (a) >= cols_otherwise
239+ pop! (a)
240+ end
241+ end
242+ return a
243+ end
244+ function Base. alignment (
245+ X:: Union{NullableArray, NullableMatrix} ,
246+ rows:: AbstractVector , cols:: AbstractVector ,
247+ cols_if_complete:: Integer , cols_otherwise:: Integer , sep:: Integer
248+ )
249+ a = []
250+ for j in cols
251+ l = r = 0
252+ for i in rows
253+ if isassigned (X, i, j)
254+ if isnull (X, i, j)
255+ aij = alignment (NULL)
256+ else
257+ aij = alignment (values (X, i, j))
258+ end
259+ else
260+ aij = undef_ref_alignment
261+ end
262+ l = max (l, aij[1 ])
263+ r = max (r, aij[2 ])
264+ end
265+ push! (a, (l, r))
266+ if length (a) > 1 && sum (map (sum,a)) + sep* length (a) >= cols_if_complete
267+ pop! (a)
268+ break
269+ end
165270 end
271+ if 1 < length (a) < size (X, 2 )
272+ while sum (map (sum, a)) + sep* length (a) >= cols_otherwise
273+ pop! (a)
274+ end
275+ end
276+ return a
166277end
0 commit comments