Vecnorm, countnz, At_mul_B and "all that jazz" - how to learn that these (and other) features have been deprecated?

While trying to manually upgrade to Julia 1.x a package developed in the pre-0.7 days by somebody else, namely PolynomialMatrices (my fork), now seemingly abandoned by its original author(s), I - being new to Julia - frequently encounter a problem that some features of the language used in the old code are now deprecated but this fact is not stated anywhere (I certainly do consult NEWS for the individual releases, in particular https://github.com/JuliaLang/julia/blob/v0.7.0/NEWS.md). True, some of these issues are detected through warnings in Julia v0.7 (and a solution is advised) but not all (some issues only demonstrate themselves as errors upon running some code). It is just that some features are described in the documentation for v0.6.4 and then absent in the docs for v0.7. Missing are (unless I am really overlooking something), for example:

And I am curious if these disappeared without any substitution in 1.0 and newer. Any replacement for any of these?

On a general note, is there any systematic way how to keep track of these changes in the language without searching through discussions?

Or is it perhaps the other way around: that after discovering these issues by myself I should contribute by sending PR to the corresponding NEWS.md?

Many thanks.

1 Like

Every single one of the functions that you asked about have deprecation warnings in Julia 0.7 that tell you the name of the new function. In general, you should upgrade code from Julia 0.6 by first porting it to Julia 0.7 and eliminating the deprecation warnings, and then porting it to 1.0.

If you try vecnorm in 0.7, it will tell you to use norm instead. (The old induced-norm functionality is now called opnorm.)

julia> vecnorm([3,4,5])
WARNING: Base.vecnorm is deprecated: it has been moved to the standard library package `LinearAlgebra`.
Add `using LinearAlgebra` to your imports.
 in module Main
┌ Warning: `vecnorm` is deprecated, use `norm` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
7.0710678118654755

If you use At_mul_B it will tell you to use transpose(A) * B instead:

julia> At_mul_B(rand(3,3), rand(3,3))
┌ Warning: `At_mul_B(A::AbstractMatrix{T}, B::AbstractMatrix{S}) where {T, S}` is deprecated, use `transpose(A) * B` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
3×3 Array{Float64,2}:
 0.448665  0.475241  0.598641
 0.594207  0.592333  0.728903
 0.880249  0.881354  0.878509

Similarly for At_mul_Bt, which is deprecated to transpose(A) * transpose(B).

And countnz(x) is deprecated for count(!iszero, x):

julia> countnz([3,4,5])
┌ Warning: `countnz(x)` is deprecated, use either `count(!iszero, x)` or `count(t -> t != 0, x)` instead.
│   caller = top-level scope at none:0
└ @ Core none:0
3
7 Likes

Many thanks. Indeed, you are right, Julia 0.7 is giving not only warnings but also suggestions for all three examples.

Let me explain that what I did was that I only worked with the warnings that Julia 0.7 returned after using the whole package. There were many dozens if not hundreds warnings, after eliminating those (took a few hours), I thought/hoped that I was done and hurried to switch to Julia 1.1 and run the first examples there (it is these late night shifts…). It seems I will have to stay in Julia 0.7 for some time while upgrading the package.

But still… I think it would be useful if it is also stated somewhere explicitly (in README.md for Julia 0.7 perhaps) that countnz, At_mul_Bt and vecnorm are deprecated.

1 Like

Most deprecation warnings are only issued when code is actually run — just eliminating deprecations from using is not generally sufficient, since loading the module typically only executes a small set of top-level code. If the package has a good test suite, then the next step is eliminating deprecation warnings emitted when you run the tests.

3 Likes