Skip to content

Commit

Permalink
view -> id
Browse files Browse the repository at this point in the history
  • Loading branch information
ablaom committed Mar 6, 2024
1 parent 4e32410 commit 4db6d59
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ mutable struct EphemeralRegressor <: Deterministic
end
EphemeralRegressor(; n=1) = EphemeralRegressor(n)
function MLJBase.fit(::EphemeralRegressor, verbosity, X, y)
# if I serialize/deserialized `thing` then `view` below changes:
view = objectid(thing)
fitresult = (thing, view, mean(y))
# if I serialize/deserialized `thing` then `id` below changes:
id = objectid(thing)
fitresult = (thing, id, mean(y))
return fitresult, nothing, NamedTuple()
end
function MLJBase.predict(::EphemeralRegressor, fitresult, X)
thing, view, μ = fitresult
return view == objectid(thing) ? fill(μ, nrows(X)) :
thing, id, μ = fitresult
return id == objectid(thing) ? fill(μ, nrows(X)) :
throw(ErrorException("dead fitresult"))
end
MLJBase.iteration_parameter(::EphemeralRegressor) = :n
Expand All @@ -264,8 +264,8 @@ function MLJBase.save(::EphemeralRegressor, fitresult)
end
function MLJBase.restore(::EphemeralRegressor, serialized_fitresult)
thing, μ = serialized_fitresult
view = objectid(thing)
return (thing, view, μ)
id = objectid(thing)
return (thing, id, μ)
end

@testset "save and restore" begin
Expand Down

0 comments on commit 4db6d59

Please sign in to comment.