-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
approach to default packages #23876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
approach to default packages #23876
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,22 +119,26 @@ macro deprecate_binding(old, new, export_old=true) | |
Expr(:call, :deprecate, __module__, Expr(:quote, old))) | ||
end | ||
|
||
macro deprecate_moved(old, new, export_old=true) | ||
macro deprecate_moved(old, new, export_old=true, default_package=false) | ||
eold = esc(old) | ||
return Expr(:toplevel, | ||
:(function $eold(args...; kwargs...) | ||
error($eold, " has been moved to the package ", $new, ".jl.\n", | ||
"Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n", | ||
"and then run `using ", $new, "` to load it.") | ||
end), | ||
default_package ? :(function $eold(args...; kwargs...) | ||
error($eold, " has been moved to the standard library package ", $new, ".\n", | ||
"Restart Julia and then run `using ", $new, "` to load it.") | ||
end) : | ||
:(function $eold(args...; kwargs...) | ||
error($eold, " has been moved to the package ", $new, ".jl.\n", | ||
"Run `Pkg.add(\"", $new, "\")` to install it, restart Julia,\n", | ||
"and then run `using ", $new, "` to load it.") | ||
end), | ||
export_old ? Expr(:export, eold) : nothing, | ||
Expr(:call, :deprecate, __module__, Expr(:quote, old), 2)) | ||
end | ||
|
||
# BEGIN 0.6-alpha deprecations (delete when 0.6 is released) | ||
|
||
@deprecate isambiguous(m1::Method, m2::Method, b::Bool) isambiguous(m1, m2, ambiguous_bottom=b) false | ||
# TODO: delete allow_bottom keyword code in Base.Test.detect_ambiguities | ||
# TODO: delete allow_bottom keyword code in Test.detect_ambiguities | ||
|
||
# END 0.6-alpha deprecations | ||
|
||
|
@@ -996,73 +1000,6 @@ iteratoreltype(::Type{Task}) = EltypeUnknown() | |
|
||
isempty(::Task) = error("isempty not defined for Tasks") | ||
|
||
@eval Base.Test begin | ||
approx_full(x::AbstractArray) = x | ||
approx_full(x::Number) = x | ||
approx_full(x) = full(x) | ||
|
||
function test_approx_eq(va, vb, Eps, astr, bstr) | ||
va = approx_full(va) | ||
vb = approx_full(vb) | ||
la, lb = length(linearindices(va)), length(linearindices(vb)) | ||
if la != lb | ||
error("lengths of ", astr, " and ", bstr, " do not match: ", | ||
"\n ", astr, " (length $la) = ", va, | ||
"\n ", bstr, " (length $lb) = ", vb) | ||
end | ||
diff = real(zero(eltype(va))) | ||
for (xa, xb) = zip(va, vb) | ||
if isfinite(xa) && isfinite(xb) | ||
diff = max(diff, abs(xa-xb)) | ||
elseif !isequal(xa,xb) | ||
error("mismatch of non-finite elements: ", | ||
"\n ", astr, " = ", va, | ||
"\n ", bstr, " = ", vb) | ||
end | ||
end | ||
|
||
if !isnan(Eps) && !(diff <= Eps) | ||
sdiff = string("|", astr, " - ", bstr, "| <= ", Eps) | ||
error("assertion failed: ", sdiff, | ||
"\n ", astr, " = ", va, | ||
"\n ", bstr, " = ", vb, | ||
"\n difference = ", diff, " > ", Eps) | ||
end | ||
end | ||
|
||
array_eps(a::AbstractArray{Complex{T}}) where {T} = eps(float(maximum(x->(isfinite(x) ? abs(x) : T(NaN)), a))) | ||
array_eps(a) = eps(float(maximum(x->(isfinite(x) ? abs(x) : oftype(x,NaN)), a))) | ||
|
||
test_approx_eq(va, vb, astr, bstr) = | ||
test_approx_eq(va, vb, 1E4*length(linearindices(va))*max(array_eps(va), array_eps(vb)), astr, bstr) | ||
|
||
""" | ||
@test_approx_eq_eps(a, b, tol) | ||
|
||
Test two floating point numbers `a` and `b` for equality taking into account | ||
a margin of tolerance given by `tol`. | ||
""" | ||
macro test_approx_eq_eps(a, b, c) | ||
Base.depwarn(string("@test_approx_eq_eps is deprecated, use `@test ", a, " ≈ ", b, " atol=", c, "` instead"), | ||
Symbol("@test_approx_eq_eps")) | ||
:(test_approx_eq($(esc(a)), $(esc(b)), $(esc(c)), $(string(a)), $(string(b)))) | ||
end | ||
export @test_approx_eq_eps | ||
|
||
""" | ||
@test_approx_eq(a, b) | ||
|
||
Deprecated. Test two floating point numbers `a` and `b` for equality taking into | ||
account small numerical errors. | ||
""" | ||
macro test_approx_eq(a, b) | ||
Base.depwarn(string("@test_approx_eq is deprecated, use `@test ", a, " ≈ ", b, "` instead"), | ||
Symbol("@test_approx_eq")) | ||
:(test_approx_eq($(esc(a)), $(esc(b)), $(string(a)), $(string(b)))) | ||
end | ||
export @test_approx_eq | ||
end | ||
|
||
# Deprecate Array(T, dims...) in favor of proper type constructors | ||
@deprecate Array(::Type{T}, d::NTuple{N,Int}) where {T,N} Array{T}(d) | ||
@deprecate Array(::Type{T}, d::Int...) where {T} Array{T}(d...) | ||
|
@@ -1429,6 +1366,18 @@ end | |
using .DSP | ||
export conv, conv2, deconv, filt, filt!, xcorr | ||
|
||
module Test | ||
for f in [Symbol("@inferred"), Symbol("@test"), Symbol("@test_approx_eq"), | ||
Symbol("@test_approx_eq_eps"), Symbol("@test_broken"), Symbol("@test_nowarn"), | ||
Symbol("@test_skip"), Symbol("@test_throws"), Symbol("@test_warn"), | ||
Symbol("@testset"), :GenericArray, :GenericDict, :GenericSet, :GenericString, | ||
:detect_ambiguities, :detect_unbound_args] | ||
@eval Base.@deprecate_moved $f "Test" true true | ||
end | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
export Test | ||
deprecate(@__MODULE__, :Test) | ||
|
||
# PR #21709 | ||
@deprecate cov(x::AbstractVector, corrected::Bool) cov(x, corrected=corrected) | ||
@deprecate cov(x::AbstractMatrix, vardim::Int, corrected::Bool) cov(x, vardim, corrected=corrected) | ||
|
@@ -1724,19 +1673,12 @@ import .LinAlg: diagm | |
@deprecate_binding φ MathConstants.φ | ||
@deprecate_binding golden MathConstants.golden | ||
|
||
# deprecate writecsv | ||
@deprecate writecsv(io, a; opts...) writedlm(io, a, ','; opts...) | ||
|
||
# PR #23271 | ||
function IOContext(io::IO; kws...) | ||
depwarn("IOContext(io, k=v, ...) is deprecated, use IOContext(io, :k => v, ...) instead.", :IOContext) | ||
IOContext(io, (k=>v for (k, v) in kws)...) | ||
end | ||
|
||
# deprecate readcsv | ||
@deprecate readcsv(io; opts...) readdlm(io, ','; opts...) | ||
@deprecate readcsv(io, T::Type; opts...) readdlm(io, ',', T; opts...) | ||
|
||
@deprecate IOContext(io::IO, key, value) IOContext(io, key=>value) | ||
|
||
# PR #23485 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,15 @@ end | |
|
||
# Documenter Setup. | ||
|
||
# make links for stdlib package docs | ||
if Sys.iswindows() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this dirty the repo if one builds the docs? Locally, I just committed the symlinked file that is being created here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will that work everywhere? Do we have any symlinks in the repo currently? I didn't want to be the first :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've seen people do it for linking in the README.md into the documentation. Whether it will work everywhere... your guess is much better than mine. |
||
cp("../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") | ||
cp("../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") | ||
else | ||
symlink("../../../stdlib/DelimitedFiles/docs/src/index.md", "src/stdlib/delimitedfiles.md") | ||
symlink("../../../stdlib/Test/docs/src/index.md", "src/stdlib/test.md") | ||
end | ||
|
||
const PAGES = [ | ||
"Home" => "index.md", | ||
"Manual" => [ | ||
|
@@ -69,6 +78,7 @@ const PAGES = [ | |
"stdlib/linalg.md", | ||
"stdlib/constants.md", | ||
"stdlib/file.md", | ||
"stdlib/delimitedfiles.md", | ||
"stdlib/io-network.md", | ||
"stdlib/punctuation.md", | ||
"stdlib/sort.md", | ||
|
@@ -116,9 +126,11 @@ const PAGES = [ | |
], | ||
] | ||
|
||
using DelimitedFiles, Test | ||
|
||
makedocs( | ||
build = joinpath(pwd(), "_build/html/en"), | ||
modules = [Base, Core, BuildSysImg], | ||
modules = [Base, Core, BuildSysImg, DelimitedFiles, Test], | ||
clean = false, | ||
doctest = "doctest" in ARGS, | ||
linkcheck = "linkcheck" in ARGS, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
delimitedfiles.md | ||
test.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# This file should contain site-specific commands to be executed on Julia startup | ||
# Users may store their own personal commands in the user home directory `homedir()`, in a file named `.juliarc.jl` | ||
|
||
using DelimitedFiles |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Delimited Files | ||
|
||
```@docs | ||
DelimitedFiles.readdlm(::Any, ::Char, ::Type, ::Char) | ||
DelimitedFiles.readdlm(::Any, ::Char, ::Char) | ||
DelimitedFiles.readdlm(::Any, ::Char, ::Type) | ||
DelimitedFiles.readdlm(::Any, ::Char) | ||
DelimitedFiles.readdlm(::Any, ::Type) | ||
DelimitedFiles.readdlm(::Any) | ||
DelimitedFiles.writedlm | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be no need to restart Julia in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, maybe, but it's fairly easy to end up with conflicting identifiers and such.