Skip to content

Commit f4d3d6d

Browse files
author
Pepijn de Vos
committed
Change typeof(x) <: y to x isa y
1 parent 585feb3 commit f4d3d6d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/MultiScaleArrays.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ are its “intrinsic values”. There is an indexing scheme on `ln`, where:
4141
- `ln[i]` provides a linear index through all `.nodes` and `.values` values in every lower
4242
level and `ln.values` itself.
4343
44-
Thus, `typeof(ln) <: AbstractVector{B}`, where `B` is the eltype of its leaves and
44+
Thus, `ln isa AbstractVector{B}`, where `B` is the eltype of its leaves and
4545
all `.values`'s.
4646
4747
In addition, iterators are provided to make it easy to iterate through levels.

src/print_human_readable.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function toprint_AbstractMultiScaleArray!(toprint, X::AbstractMultiScaleArray, f
3232
n_char_per_name))
3333
first_element = add_separator!(first_element, toprint, level)
3434
else
35-
if !(typeof(x) <: AbstractMultiScaleArrayLeaf)
35+
if !(x isa AbstractMultiScaleArrayLeaf)
3636
push!(toprint[level],
3737
take_first_char(split(string(typeof(x)), "{")[1],
3838
n_char_per_name))
@@ -81,7 +81,7 @@ print_human_readable(embryo.nodes[1].nodes[1]; fields = [:values])
8181
"""
8282
function print_human_readable(X::AbstractMultiScaleArray; n_char_per_name = 6,
8383
fields = nothing, levelmax = Inf, n_item_max_per_levels = Inf) # fields = nothing OR [field1,field2,...]
84-
# if typeof(X) <: AbstractMultiScaleArrayLeaf
84+
# if X isa AbstractMultiScaleArrayLeaf
8585
# println(X)
8686
# else
8787
toprint = Vector{Vector{String}}([[]]) # one vector per row, one string per element

test/indexing_and_creation_tests.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ p = construct(Population, deepcopy([cell1, cell2]))
5252
sim_p = similar(p)
5353
sim_p_arr = similar(p, axes(p))
5454

55-
@test typeof(sim_p) <: Population
56-
@test typeof(sim_p_arr) <: Vector{Float64}
55+
@test sim_p isa Population
56+
@test sim_p_arr isa Vector{Float64}
5757
@test length(sim_p) == length(p)
5858
@test length(sim_p.nodes[1]) == length(p.nodes[1])
5959
@test !(sim_p.nodes[1] === p.nodes[1])
@@ -135,7 +135,7 @@ g = (x, y) -> x * y
135135

136136
cell3 = cell1 .+ 2
137137

138-
@test typeof(cell3) <: AbstractMultiScaleArray
138+
@test cell3 isa AbstractMultiScaleArray
139139

140140
cell3 = similar(cell1)
141141
cell3 .= [1, 2, 3]
@@ -242,12 +242,12 @@ end
242242
em2 = copy(em)
243243

244244
for (pop1, pop2) in LevelIter(2, em, em2)
245-
@test typeof(pop1) <: Population
245+
@test pop1 isa Population
246246
@test pop1[:] == pop2[:]
247247
end
248248

249249
for (cell1, cell2) in LevelIter(3, em, em2)
250-
@test typeof(cell1) <: Cell
250+
@test cell1 isa Cell
251251
@test cell1[:] == cell2[:]
252252
end
253253

0 commit comments

Comments
 (0)