Skip to content

Commit ba72571

Browse files
authored
Merge pull request #66 from JuliaMath/aa/modernize
Modernize the doc setup and add a Project file
2 parents f5e557d + ac7e284 commit ba72571

File tree

9 files changed

+55
-57
lines changed

9 files changed

+55
-57
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
Manifest.toml
45
docs/build
56
docs/site
7+
docs/Manifest.toml

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ os:
44
- linux
55
julia:
66
- 0.7
7+
- 1.0
8+
- 1.1
79
- nightly
810
notifications:
911
email: false
@@ -12,6 +14,13 @@ notifications:
1214
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
1315
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Primes"); Pkg.test("Primes"; coverage=true)'
1416
after_success:
15-
- julia -e 'Pkg.add("Coverage"); ps=Pkg.PackageSpec(name="Documenter", version="0.19"); Pkg.add(ps); Pkg.pin(ps)'
16-
- julia -e 'cd(Pkg.dir("Primes")); using Coverage; Coveralls.submit(Coveralls.process_folder())'
17-
- julia -e 'cd(Pkg.dir("Primes")); include(joinpath("docs", "make.jl"))'
17+
- julia -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
18+
jobs:
19+
include:
20+
- stage: "Documentation"
21+
julia: 1.0
22+
os: linux
23+
script:
24+
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
25+
- julia --project=docs/ docs/make.jl
26+
after_success: skip

Project.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name = "Primes"
2+
uuid = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
3+
4+
[extras]
5+
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
6+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
7+
8+
[targets]
9+
test = ["DataStructures", "Test"]

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
julia 0.7-alpha
1+
julia 0.7

appveyor.yml

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,26 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
7-
3+
- julia_version: 0.7
4+
- julia_version: 1.0
5+
- julia_version: 1.1
6+
- julia_version: nightly
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
810
branches:
911
only:
1012
- master
1113
- /release-.*/
12-
1314
notifications:
1415
- provider: Email
1516
on_build_success: false
1617
on_build_failure: false
1718
on_build_status_changed: false
18-
1919
install:
20-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
21-
# If there's a newer build queued for the same PR, cancel this one
22-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
23-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
24-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
25-
throw "There are newer queued builds for this pull request, failing early." }
26-
# Download most recent Julia Windows binary
27-
- ps: (new-object net.webclient).DownloadFile(
28-
$env:JULIA_URL,
29-
"C:\projects\julia-binary.exe")
30-
# Run installer silently, output to C:\projects\julia
31-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
32-
20+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3321
build_script:
34-
# Need to convert from shallow to complete for Pkg.clone to work
35-
- IF EXIST .git\shallow (git fetch --unshallow)
36-
- C:\projects\julia\bin\julia -e "versioninfo();
37-
Pkg.clone(pwd(), \"Primes\"); Pkg.build(\"Primes\")"
38-
22+
- echo "%JL_BUILD_SCRIPT%"
23+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3924
test_script:
40-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"Primes\")"
25+
- echo "%JL_TEST_SCRIPT%"
26+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

docs/Project.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[deps]
2+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
4+
5+
[compat]
6+
Documenter = "~0.20"

docs/make.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ using Documenter, Primes
22

33
makedocs(
44
modules = [Primes],
5-
clean = false,
6-
format = :html,
75
sitename = "Primes.jl",
86
pages = Any[
97
"Home" => "index.md",
@@ -12,9 +10,6 @@ makedocs(
1210
)
1311

1412
deploydocs(
15-
julia = "nightly",
1613
repo = "github.com/JuliaMath/Primes.jl.git",
1714
target = "build",
18-
deps = nothing,
19-
make = nothing,
2015
)

docs/src/api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
```@meta
2+
DocTestSetup = :(using Primes)
3+
```
4+
15
# Prime number functions
26

37
## Prime factorization

src/Primes.jl

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This includes parts that were formerly a part of Julia. License is MIT: http://julialang.org/license
2-
VERSION < v"0.7.0-beta2.199" && __precompile__()
1+
# This file includes code that was formerly a part of Julia. License is MIT: http://julialang.org/license
2+
33
module Primes
44

55
using Base.Iterators: repeated
@@ -338,13 +338,8 @@ Set([2,5])
338338
"""
339339
factor(::Type{D}, n::T) where {T<:Integer, D<:AbstractDict} = factor!(n, D(Dict{T,Int}()))
340340
factor(::Type{A}, n::T) where {T<:Integer, A<:AbstractArray} = A(factor(Vector{T}, n))
341-
if VERSION >= v"0.7.0-beta.81"
342-
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
343-
mapreduce(collect, vcat, [repeated(k, v) for (k, v) in factor(n)], init=Vector{T}())
344-
else
345-
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
346-
mapreduce(collect, vcat, Vector{T}(), [repeated(k, v) for (k, v) in factor(n)])
347-
end
341+
factor(::Type{Vector{T}}, n::T) where {T<:Integer} =
342+
mapreduce(collect, vcat, [repeated(k, v) for (k, v) in factor(n)], init=Vector{T}())
348343
factor(::Type{S}, n::T) where {T<:Integer, S<:Union{Set,BitSet}} = S(keys(factor(n)))
349344
factor(::Type{T}, n) where {T<:Any} = throw(MethodError(factor, (T, n)))
350345

@@ -435,12 +430,6 @@ function pollardfactors!(n::T, h::AbstractDict{K,Int}) where {T<:Integer,K<:Inte
435430
end
436431
end
437432

438-
if VERSION >= v"0.7.0-beta.183"
439-
ndigits2(n) = ndigits(n, base=2)
440-
else
441-
ndigits2(n) = ndigits(n, 2)
442-
end
443-
444433
"""
445434
ismersenneprime(M::Integer; [check::Bool = true]) -> Bool
446435
@@ -461,7 +450,7 @@ true
461450
"""
462451
function ismersenneprime(M::Integer; check::Bool = true)
463452
if check
464-
d = ndigits2(M)
453+
d = ndigits(M, base=2)
465454
M >= 0 && isprime(d) && (M >> d == 0) ||
466455
throw(ArgumentError("The argument given is not a valid Mersenne Number (`M = 2^p - 1`)."))
467456
end
@@ -486,7 +475,7 @@ true
486475
```
487476
"""
488477
function isrieselprime(k::Integer, Q::Integer)
489-
n = ndigits2(Q)
478+
n = ndigits(Q, base=2)
490479
0 < k < Q || throw(ArgumentError("The condition 0 < k < Q must be met."))
491480
if k == 1 && isodd(n)
492481
return n % 4 == 3 ? ll_primecheck(Q, 3) : ll_primecheck(Q)
@@ -500,7 +489,7 @@ end
500489

501490
# LL backend -- not for export
502491
function ll_primecheck(X::Integer, s::Integer = 4)
503-
S, N = BigInt(s), BigInt(ndigits2(X))
492+
S, N = BigInt(s), BigInt(ndigits(X, base=2))
504493
X < 7 && throw(ArgumentError("The condition X ≥ 7 must be met."))
505494
for i in 1:(N - 2)
506495
S = (S^2 - 2) % X
@@ -543,12 +532,10 @@ end
543532

544533
# modify a BigInt in-place
545534
function add_!(n::BigInt, x::Int)
546-
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
547-
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
548535
if x < 0
549-
ccall((:__gmpz_sub_ui, :libgmp), Cvoid, (Any, Any, Culong), n, n, -x)
536+
ccall((:__gmpz_sub_ui, :libgmp), Cvoid, (Ref{BigInt}, Ref{BigInt}, Culong), n, n, -x)
550537
else
551-
ccall((:__gmpz_add_ui, :libgmp), Cvoid, (Any, Any, Culong), n, n, x)
538+
ccall((:__gmpz_add_ui, :libgmp), Cvoid, (Ref{BigInt}, Ref{BigInt}, Culong), n, n, x)
552539
end
553540
n
554541
end

0 commit comments

Comments
 (0)