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

Commit 6711153

Browse files
committed
test: cover missing lines
1 parent ffc6a50 commit 6711153

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

.buildkite/testing.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ steps:
77
version: "1"
88
- JuliaCI/julia-coverage#v1:
99
codecov: true
10-
dirs:
11-
- src
12-
- ext
1310
command: julia --code-coverage=user --color=yes --project .buildkite/scripts/downstream.jl "{{matrix.repo}}" "CUDA"
1411
agents:
1512
queue: "juliagpu"

src/LuxCore.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ for op in (:initialparameters, :initialstates)
7171
end
7272

7373
_fmap_leaf(::AbstractExplicitLayer) = true
74-
_fmap_leaf(::Nothing) = true
7574
_fmap_leaf(x) = Functors.isleaf(x)
7675

7776
_getemptystate(::AbstractExplicitLayer) = NamedTuple()
@@ -311,7 +310,7 @@ end
311310
A Boolean Value
312311
"""
313312
check_fmap_condition(cond::C, ::Nothing, x) where {C} = any(cond, fleaves(x))
314-
check_fmap_condition(cond::C, ::Nothing, ::NamedTuple{}) where {C} = any(cond, ())
313+
check_fmap_condition(cond::C, ::Nothing, ::NamedTuple{()}) where {C} = any(cond, ())
315314
function check_fmap_condition(cond::C, ::Type{T}, x) where {C, T}
316315
x isa T && return true
317316
return check_fmap_condition(cond, nothing, x)

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ end
7171
@test LuxCore.initialparameters(rng, NamedTuple()) == NamedTuple()
7272
@test_throws MethodError LuxCore.initialparameters(rng, ())
7373
@test LuxCore.initialparameters(rng, nothing) == NamedTuple()
74+
@test LuxCore.initialparameters(rng, (nothing, layer)) ==
75+
(NamedTuple(), NamedTuple())
7476

7577
@test LuxCore.initialstates(rng, NamedTuple()) == NamedTuple()
7678
@test_throws MethodError LuxCore.initialstates(rng, ())
7779
@test LuxCore.initialstates(rng, nothing) == NamedTuple()
80+
@test LuxCore.initialparameters(rng, (nothing, layer)) ==
81+
(NamedTuple(), NamedTuple())
7882
end
7983
end
8084

@@ -173,6 +177,7 @@ end
173177
@test new_model.layers.layer_2.out == 10
174178

175179
@test LuxCore.outputsize(model, rand(5), rng) == (5,)
180+
@test LuxCore.outputsize(model, rand(5, 2), rng) == (5,)
176181
end
177182

178183
@testset "Method Ambiguity" begin
@@ -269,4 +274,9 @@ end
269274
@test LuxCore.replicate(rng) !== rng
270275
@test LuxCore.replicate(rng) == rng
271276
end
277+
278+
@testset "empty fleaves" begin
279+
@test_broken length(fleaves(NamedTuple())) == 0 # upstream issue
280+
@test !LuxCore.check_fmap_condition(isodd, nothing, NamedTuple())
281+
end
272282
end

0 commit comments

Comments
 (0)