Skip to content
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

Deprecate prime number functions (isprime, primes, primesmask, factor) #16481

Merged
merged 3 commits into from
May 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Breaking changes
Library improvements
--------------------

* Most of the combinatorics functions have been moved from `Base`
* Most of the combinatorics functions have been moved from `Base`
to the [Combinatorics.jl package](https://github.com/JuliaLang/Combinatorics.jl) ([#13897]).

* Packages:
Expand Down Expand Up @@ -173,6 +173,9 @@ Library improvements
or `is_apple()`. There's now also an `@static` macro that will evaluate the condition of an if-statement at
compile time, for when a static branch is required ([#16219]).

* Prime number related functions have been moved from `Base` to the
[Primes.jl package](https://github.com/JuliaMath/Primes.jl) ([#16481]).

Deprecated or removed
---------------------

Expand Down
10 changes: 10 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,16 @@ for deprecatedfunc in [:combinations, :factorial, :prevprod, :levicivita,
end
end

# Primes functions that have been moved out of base (#16481)
for deprecatedfunc in [:isprime, :primes, :primesmask, :factor]
@eval begin
$deprecatedfunc(args...) = error(string($deprecatedfunc, args,
" has been moved to the package Primes.jl.\n",
"Run Pkg.add(\"Primes\") to install Primes on Julia v0.5-"))
export $deprecatedfunc
end
end

#14335
@deprecate super(T::DataType) supertype(T)

Expand Down
58 changes: 0 additions & 58 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1291,21 +1291,6 @@ is equivalent to `!isapprox(x,y)`.
"""
isapprox

"""
primes([lo,] hi)

Returns a collection of the prime numbers (from `lo`, if specified) up to `hi`.
"""
primes

"""
primesmask([lo,] hi)

Returns a prime sieve, as a `BitArray`, of the positive integers (from `lo`, if specified)
up to `hi`. Useful when working with either primes or composite numbers.
"""
primesmask

"""
sinh(x)

Expand Down Expand Up @@ -7719,23 +7704,6 @@ the same as the way an object is printed in the Julia REPL.)
"""
TextDisplay

"""
factor(n) -> Dict

Compute the prime factorization of an integer `n`. Returns a dictionary. The keys of the
dictionary correspond to the factors, and hence are of the same type as `n`. The value
associated with each key indicates the number of times the factor appears in the
factorization.

```jldoctest
julia> factor(100) # == 2*2*5*5
Dict{Int64,Int64} with 2 entries:
2 => 2
5 => 2
```
"""
factor

"""
ismatch(r::Regex, s::AbstractString) -> Bool

Expand Down Expand Up @@ -8391,32 +8359,6 @@ any element type for which `dot` is defined), compute the Euclidean dot product
"""
vecdot

"""
isprime(x::Integer) -> Bool

Returns `true` if `x` is prime, and `false` otherwise.

```jldoctest
julia> isprime(3)
true
```
"""
isprime(::Integer)

"""
isprime(x::BigInt, [reps = 25]) -> Bool

Probabilistic primality test. Returns `true` if `x` is prime; and `false` if `x` is not
prime with high probability. The false positive rate is about `0.25^reps`. `reps = 25` is
considered safe for cryptographic applications (Knuth, Seminumerical Algorithms).

```jldoctest
julia> isprime(big(3))
true
```
"""
isprime(::BigInt, ?)

"""
>(x, y)

Expand Down
4 changes: 0 additions & 4 deletions base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ export
exp2,
expm1,
exponent,
factor,
factorial,
fld,
fld1,
Expand Down Expand Up @@ -380,7 +379,6 @@ export
isnan,
isodd,
ispow2,
isprime,
isqrt,
isreal,
isimag,
Expand Down Expand Up @@ -412,8 +410,6 @@ export
prevfloat,
prevpow,
prevpow2,
primes,
primesmask,
rad2deg,
rationalize,
real,
Expand Down
4 changes: 1 addition & 3 deletions base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export BigInt

import Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), ($),
binomial, cmp, convert, div, divrem, factorial, fld, gcd, gcdx, lcm, mod,
ndigits, promote_rule, rem, show, isqrt, string, isprime, powermod,
ndigits, promote_rule, rem, show, isqrt, string, powermod,
sum, trailing_zeros, trailing_ones, count_ones, base, tryparse_internal,
bin, oct, dec, hex, isequal, invmod, prevpow2, nextpow2, ndigits0z, widen, signed, unsafe_trunc, trunc

Expand Down Expand Up @@ -541,8 +541,6 @@ function ndigits0z(x::BigInt, b::Integer=10)
end
ndigits(x::BigInt, b::Integer=10) = x.size == 0 ? 1 : ndigits0z(x,b)

isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp), Cint, (Ptr{BigInt}, Cint), &x, reps) > 0

prevpow2(x::BigInt) = x.size < 0 ? -prevpow2(-x) : (x <= 2 ? x : one(BigInt) << (ndigits(x, 2)-1))
nextpow2(x::BigInt) = x.size < 0 ? -nextpow2(-x) : (x <= 2 ? x : one(BigInt) << ndigits(x-1, 2))

Expand Down
206 changes: 0 additions & 206 deletions base/primes.jl

This file was deleted.

2 changes: 0 additions & 2 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ include("multidimensional.jl")
include("permuteddimsarray.jl")
using .PermutedDimsArrays

include("primes.jl")

let SOURCE_PATH = ""
global include = function(path)
prev = SOURCE_PATH
Expand Down
4 changes: 0 additions & 4 deletions contrib/BBEditTextWrangler-julia.plist
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@
<string>export</string>
<string>extrema</string>
<string>eye</string>
<string>factor</string>
<string>factorial</string>
<string>factorize</string>
<string>falses</string>
Expand Down Expand Up @@ -633,7 +632,6 @@
<string>isposdef!</string>
<string>isposdef</string>
<string>ispow2</string>
<string>isprime</string>
<string>isprint</string>
<string>ispunct</string>
<string>isqrt</string>
Expand Down Expand Up @@ -849,8 +847,6 @@
<string>prevind</string>
<string>prevpow2</string>
<string>prevpow</string>
<string>primes</string>
<string>primesmask</string>
<string>print</string>
<string>print_escaped</string>
<string>print_joined</string>
Expand Down
Loading