Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Julia - How to know what is the latest version (v1.0.0) equivalent function?

Tags:

julia

I previously used ismatch function in Julia v0.6.0 but now it returns an error with v1.0.0 and it's not present in the v0.7.0 or v1.0 documentation. So how can I find the non depreciated equivalent of ismatch for latest Julia version ?

More generally in Julia, how is it possible to know the equivalent of any depreciated function if it exists ?

I only have Julia v1.0 installed on my computer.

like image 510
JKHA Avatar asked Mar 05 '23 10:03

JKHA


1 Answers

When it comes to porting old v0.6 code to v1.0, it is generally recommended to use v0.7. Typically, it will show you a deprecation warning with instructions on how to get the same result in v1.0.

For example, we can run code involving ismatch as follows (on Julia v0.7):

julia> ismatch(r"a.c", "abc")
┌ Warning: `ismatch(r::Regex, s::AbstractString)` is deprecated, use `occursin(r, s)` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
true

According to the deprecation warning, we should replace all calls to ismatch(r::Regex, s::AbstractString) with occursin(r, s) for future compatibility. In the case that deprecations occur throughout a project, Julia (v0.7) may be started using the --depwarn=error flag, which will immediately error (and provide detailed information about location) upon calling a deprecated method.

Note that deprecations are defined in base/deprecations.jl. You can check this file on github or locally to see what function 0.7 is mapping the deprecated method to.

(Note that there is also a function match in v1.0, which one gets as a suggestion when doing ?ismatch on 1.0.)

like image 79
carstenbauer Avatar answered May 12 '23 17:05

carstenbauer