Skip to content

Commit eb0f519

Browse files
author
Christopher Doris
committed
rename some Utils functions
1 parent e67e124 commit eb0f519

File tree

8 files changed

+49
-49
lines changed

8 files changed

+49
-49
lines changed

src/Convert/rules.jl

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -147,30 +147,30 @@ end
147147
function pyconvert_rule_range(
148148
::Type{R},
149149
x::Py,
150-
::Type{StepRange{T0,S0}} = Utils._type_lb(R),
151-
::Type{StepRange{T1,S1}} = Utils._type_ub(R),
150+
::Type{StepRange{T0,S0}} = Utils.type_lb(R),
151+
::Type{StepRange{T1,S1}} = Utils.type_ub(R),
152152
) where {R<:StepRange,T0,S0,T1,S1}
153-
a = @pyconvert(Utils._typeintersect(Integer, T1), x.start)
154-
b = @pyconvert(Utils._typeintersect(Integer, S1), x.step)
155-
c = @pyconvert(Utils._typeintersect(Integer, T1), x.stop)
153+
a = @pyconvert(Utils.typeintersect(Integer, T1), x.start)
154+
b = @pyconvert(Utils.typeintersect(Integer, S1), x.step)
155+
c = @pyconvert(Utils.typeintersect(Integer, T1), x.stop)
156156
a′, c′ = promote(a, c - oftype(c, sign(b)))
157-
T2 = Utils._promote_type_bounded(T0, typeof(a′), typeof(c′), T1)
158-
S2 = Utils._promote_type_bounded(S0, typeof(c′), S1)
157+
T2 = Utils.promote_type_bounded(T0, typeof(a′), typeof(c′), T1)
158+
S2 = Utils.promote_type_bounded(S0, typeof(c′), S1)
159159
pyconvert_return(StepRange{T2,S2}(a′, b, c′))
160160
end
161161

162162
function pyconvert_rule_range(
163163
::Type{R},
164164
x::Py,
165-
::Type{UnitRange{T0}} = Utils._type_lb(R),
166-
::Type{UnitRange{T1}} = Utils._type_ub(R),
165+
::Type{UnitRange{T0}} = Utils.type_lb(R),
166+
::Type{UnitRange{T1}} = Utils.type_ub(R),
167167
) where {R<:UnitRange,T0,T1}
168168
b = @pyconvert(Int, x.step)
169169
b == 1 || return pyconvert_unconverted()
170-
a = @pyconvert(Utils._typeintersect(Integer, T1), x.start)
171-
c = @pyconvert(Utils._typeintersect(Integer, T1), x.stop)
170+
a = @pyconvert(Utils.typeintersect(Integer, T1), x.start)
171+
c = @pyconvert(Utils.typeintersect(Integer, T1), x.stop)
172172
a′, c′ = promote(a, c - oftype(c, 1))
173-
T2 = Utils._promote_type_bounded(T0, typeof(a′), typeof(c′), T1)
173+
T2 = Utils.promote_type_bounded(T0, typeof(a′), typeof(c′), T1)
174174
pyconvert_return(UnitRange{T2}(a′, c′))
175175
end
176176

@@ -180,13 +180,13 @@ end
180180
function pyconvert_rule_fraction(
181181
::Type{R},
182182
x::Py,
183-
::Type{Rational{T0}} = Utils._type_lb(R),
184-
::Type{Rational{T1}} = Utils._type_ub(R),
183+
::Type{Rational{T0}} = Utils.type_lb(R),
184+
::Type{Rational{T1}} = Utils.type_ub(R),
185185
) where {R<:Rational,T0,T1}
186-
a = @pyconvert(Utils._typeintersect(Integer, T1), x.numerator)
187-
b = @pyconvert(Utils._typeintersect(Integer, T1), x.denominator)
186+
a = @pyconvert(Utils.typeintersect(Integer, T1), x.numerator)
187+
b = @pyconvert(Utils.typeintersect(Integer, T1), x.denominator)
188188
a, b = promote(a, b)
189-
T2 = Utils._promote_type_bounded(T0, typeof(a), typeof(b), T1)
189+
T2 = Utils.promote_type_bounded(T0, typeof(a), typeof(b), T1)
190190
pyconvert_return(Rational{T2}(a, b))
191191
end
192192

@@ -211,7 +211,7 @@ function _pyconvert_rule_iterable(ans::Vector{T0}, it::Py, ::Type{T1}) where {T0
211211
push!(ans, x)
212212
@goto again
213213
end
214-
T2 = Utils._promote_type_bounded(T0, typeof(x), T1)
214+
T2 = Utils.promote_type_bounded(T0, typeof(x), T1)
215215
ans2 = Vector{T2}(ans)
216216
push!(ans2, x)
217217
return _pyconvert_rule_iterable(ans2, it, T1)
@@ -220,8 +220,8 @@ end
220220
function pyconvert_rule_iterable(
221221
::Type{R},
222222
x::Py,
223-
::Type{Vector{T0}} = Utils._type_lb(R),
224-
::Type{Vector{T1}} = Utils._type_ub(R),
223+
::Type{Vector{T0}} = Utils.type_lb(R),
224+
::Type{Vector{T1}} = Utils.type_ub(R),
225225
) where {R<:Vector,T0,T1}
226226
it = pyiter(x)
227227
ans = Vector{T0}()
@@ -242,7 +242,7 @@ function _pyconvert_rule_iterable(ans::Set{T0}, it::Py, ::Type{T1}) where {T0,T1
242242
push!(ans, x)
243243
@goto again
244244
end
245-
T2 = Utils._promote_type_bounded(T0, typeof(x), T1)
245+
T2 = Utils.promote_type_bounded(T0, typeof(x), T1)
246246
ans2 = Set{T2}(ans)
247247
push!(ans2, x)
248248
return _pyconvert_rule_iterable(ans2, it, T1)
@@ -251,8 +251,8 @@ end
251251
function pyconvert_rule_iterable(
252252
::Type{R},
253253
x::Py,
254-
::Type{Set{T0}} = Utils._type_lb(R),
255-
::Type{Set{T1}} = Utils._type_ub(R),
254+
::Type{Set{T0}} = Utils.type_lb(R),
255+
::Type{Set{T1}} = Utils.type_ub(R),
256256
) where {R<:Set,T0,T1}
257257
it = pyiter(x)
258258
ans = Set{T0}()
@@ -281,8 +281,8 @@ function _pyconvert_rule_mapping(
281281
push!(ans, k => v)
282282
@goto again
283283
end
284-
K2 = Utils._promote_type_bounded(K0, typeof(k), K1)
285-
V2 = Utils._promote_type_bounded(V0, typeof(v), V1)
284+
K2 = Utils.promote_type_bounded(K0, typeof(k), K1)
285+
V2 = Utils.promote_type_bounded(V0, typeof(v), V1)
286286
ans2 = Dict{K2,V2}(ans)
287287
push!(ans2, k => v)
288288
return _pyconvert_rule_mapping(ans2, x, it, K1, V1)
@@ -291,8 +291,8 @@ end
291291
function pyconvert_rule_mapping(
292292
::Type{R},
293293
x::Py,
294-
::Type{Dict{K0,V0}} = Utils._type_lb(R),
295-
::Type{Dict{K1,V1}} = Utils._type_ub(R),
294+
::Type{Dict{K0,V0}} = Utils.type_lb(R),
295+
::Type{Dict{K1,V1}} = Utils.type_ub(R),
296296
) where {R<:Dict,K0,V0,K1,V1}
297297
it = pyiter(x)
298298
ans = Dict{K0,V0}()
@@ -372,8 +372,8 @@ end
372372
function pyconvert_rule_iterable(
373373
::Type{R},
374374
x::Py,
375-
::Type{Pair{K0,V0}} = Utils._type_lb(R),
376-
::Type{Pair{K1,V1}} = Utils._type_ub(R),
375+
::Type{Pair{K0,V0}} = Utils.type_lb(R),
376+
::Type{Pair{K1,V1}} = Utils.type_ub(R),
377377
) where {R<:Pair,K0,V0,K1,V1}
378378
it = pyiter(x)
379379
k_ = unsafe_pynext(it)
@@ -398,8 +398,8 @@ function pyconvert_rule_iterable(
398398
pydel!(z_)
399399
return pyconvert_unconverted()
400400
end
401-
K2 = Utils._promote_type_bounded(K0, typeof(k), K1)
402-
V2 = Utils._promote_type_bounded(V0, typeof(v), V1)
401+
K2 = Utils.promote_type_bounded(K0, typeof(k), K1)
402+
V2 = Utils.promote_type_bounded(V0, typeof(v), V1)
403403
return pyconvert_return(Pair{K2,V2}(k, v))
404404
end
405405

src/Utils/mimes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function mimes_for(x)
3535
mimes = copy(ALL_MIMES)
3636
# look for mimes on show methods for this type
3737
for meth in methods(show, Tuple{IO,MIME,typeof(x)}).ms
38-
mimetype = _unwrap_unionall(meth.sig).parameters[3]
38+
mimetype = unwrap_unionall(meth.sig).parameters[3]
3939
mimetype isa DataType || continue
4040
mimetype <: MIME || continue
4141
mime = string(mimetype.parameters[1])

src/Utils/types.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,44 @@ function explode_union(T)
1919
end
2020
end
2121

22-
@generated _typeintersect(::Type{T1}, ::Type{T2}) where {T1,T2} = typeintersect(T1, T2)
22+
@generated typeintersect(::Type{T1}, ::Type{T2}) where {T1,T2} = Base.typeintersect(T1, T2)
2323

24-
@generated _type_ub(::Type{T}) where {T} = begin
24+
@generated type_ub(::Type{T}) where {T} = begin
2525
S = T
2626
while S isa UnionAll
2727
S = S{S.var.ub}
2828
end
2929
S
3030
end
3131

32-
@generated _type_lb(::Type{T}) where {T} = begin
33-
R = _unwrap_unionall(T)
32+
@generated type_lb(::Type{T}) where {T} = begin
33+
R = unwrap_unionall(T)
3434
if R isa DataType
3535
S = T
3636
while S isa UnionAll
3737
S = S{S.var in R.parameters ? S.var.lb : S.var.ub}
3838
end
3939
S
4040
else
41-
_type_ub(T)
41+
type_ub(T)
4242
end
4343
end
4444

45-
@generated function _unwrap_unionall(::Type{T}) where {T}
45+
@generated function unwrap_unionall(::Type{T}) where {T}
4646
R = T
4747
while R isa UnionAll
4848
R = R.body
4949
end
5050
R
5151
end
5252

53-
@generated _promote_type_bounded(::Type{S}, ::Type{T}, ::Type{B}) where {S,T,B} = begin
53+
@generated promote_type_bounded(::Type{S}, ::Type{T}, ::Type{B}) where {S,T,B} = begin
5454
S <: B || error("require S <: B")
5555
T <: B || error("require T <: B")
5656
if B isa Union
5757
return Union{
58-
_promote_type_bounded(typeintersect(S, B.a), typeintersect(T, B.a), B.a),
59-
_promote_type_bounded(typeintersect(S, B.b), typeintersect(T, B.b), B.b),
58+
promote_type_bounded(typeintersect(S, B.a), typeintersect(T, B.a), B.a),
59+
promote_type_bounded(typeintersect(S, B.b), typeintersect(T, B.b), B.b),
6060
}
6161
else
6262
R = promote_type(S, T)
@@ -73,9 +73,9 @@ end
7373
end
7474
end
7575

76-
@generated _promote_type_bounded(
76+
@generated promote_type_bounded(
7777
::Type{T1},
7878
::Type{T2},
7979
::Type{T3},
8080
::Type{B},
81-
) where {T1,T2,T3,B} = _promote_type_bounded(_promote_type_bounded(T1, T2, B), T3, B)
81+
) where {T1,T2,T3,B} = promote_type_bounded(promote_type_bounded(T1, T2, B), T3, B)

src/Wrap/PyArray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function pyarray_make(
8989
::Type{A},
9090
x::Py,
9191
info::PyArraySource,
92-
::Type{PyArray{T0,N0,M0,L0,R0}} = Utils._type_lb(A),
93-
::Type{PyArray{T1,N1,M1,L1,R1}} = Utils._type_ub(A),
92+
::Type{PyArray{T0,N0,M0,L0,R0}} = Utils.type_lb(A),
93+
::Type{PyArray{T1,N1,M1,L1,R1}} = Utils.type_ub(A),
9494
) where {A<:PyArray,T0,N0,M0,L0,R0,T1,N1,M1,L1,R1}
9595
# R (buffer eltype)
9696
R′ = pyarray_get_R(info)::DataType

src/Wrap/PyDict.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Py(x::PyDict) = x.py
77
function pyconvert_rule_mapping(
88
::Type{T},
99
x::Py,
10-
::Type{T1} = Utils._type_ub(T),
10+
::Type{T1} = Utils.type_ub(T),
1111
) where {T<:PyDict,T1}
1212
pyconvert_return(T1(x))
1313
end

src/Wrap/PyIterable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ end
1919
function pyconvert_rule_iterable(
2020
::Type{T},
2121
x::Py,
22-
::Type{T1} = Utils._type_ub(T),
22+
::Type{T1} = Utils.type_ub(T),
2323
) where {T<:PyIterable,T1}
2424
pyconvert_return(T1(x))
2525
end

src/Wrap/PyList.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Py(x::PyList) = x.py
66
function pyconvert_rule_sequence(
77
::Type{T},
88
x::Py,
9-
::Type{T1} = Utils._type_ub(T),
9+
::Type{T1} = Utils.type_ub(T),
1010
) where {T<:PyList,T1}
1111
pyconvert_return(T1(x))
1212
end

src/Wrap/PySet.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Py(x::PySet) = x.py
66
function pyconvert_rule_set(
77
::Type{T},
88
x::Py,
9-
::Type{T1} = Utils._type_ub(T),
9+
::Type{T1} = Utils.type_ub(T),
1010
) where {T<:PySet,T1}
1111
pyconvert_return(T1(x))
1212
end

0 commit comments

Comments
 (0)