JuliaML / LossFunctions.jl

Julia package of loss functions for machine learning.
https://juliaml.github.io/LossFunctions.jl/stable
Other
148 stars 34 forks source link

Cannot use LossFunctions in Julia 1.0 #142

Closed ablaom closed 3 years ago

ablaom commented 3 years ago

Since the patch 0.7.1 release:

julia> using LossFunctions
[ Info: Recompiling stale cache file /Users/anthony/.julia/compiled/v1.0/LossFunctions/6fG6k.ji for LossFunctions [30fc2ffe-d236-52d8-8643-a9d8f7c094a7]
ERROR: LoadError: LoadError: cannot add methods to an abstract type
Stacktrace:
 [1] top-level scope at none:0
 [2] include at ./boot.jl:317 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1044
 [4] include at ./sysimg.jl:29 [inlined]
 [5] include(::String) at /Users/anthony/.julia/packages/LossFunctions/ncsU2/src/LossFunctions.jl:1
 [6] top-level scope at none:0
 [7] include at ./boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1044
 [9] include(::Module, ::String) at ./sysimg.jl:29
 [10] top-level scope at none:2
 [11] eval at ./boot.jl:319 [inlined]
 [12] eval(::Expr) at ./client.jl:393
 [13] top-level scope at ./none:3
in expression starting at /Users/anthony/.julia/packages/LossFunctions/ncsU2/src/supervised.jl:192
in expression starting at /Users/anthony/.julia/packages/LossFunctions/ncsU2/src/LossFunctions.jl:25
ERROR: Failed to precompile LossFunctions [30fc2ffe-d236-52d8-8643-a9d8f7c094a7] to /Users/anthony/.julia/compiled/v1.0/LossFunctions/6fG6k.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1203
 [3] _require(::Base.PkgId) at ./loading.jl:960
 [4] require(::Base.PkgId) at ./loading.jl:858
 [5] require(::Module, ::Symbol) at ./loading.jl:853

The cause is the new line making loss instances callable in this diff:

https://github.com/JuliaML/LossFunctions.jl/compare/v0.7.0...v0.7.1

I think you need 1.3 at least for this to work as implemented.

cc @juliohm

juliohm commented 3 years ago

Thank you @ablaom, #143 should fix this issue. I will wait for the tests and then will merge and trigger another patch release. I always forget the breath of Julia versions out there.

ablaom commented 3 years ago

@juliohm Thank you for the prompt attention!