Skip to content

Commit

Permalink
Merge branch 'master' into feature/count-reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Apr 30, 2020
2 parents 5fcc4cd + 2f90dde commit d453af0
Show file tree
Hide file tree
Showing 46 changed files with 754 additions and 475 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ runtest harness).
- **Homepage:** <https://julialang.org>
- **Community:** <https://julialang.org/community/>
- **Source code:** <https://github.com/JuliaLang/julia>
- **Documentation:** <https://docs.julialang.org/>
- **Documentation:** <https://docs.julialang.org>
- **Code coverage:** <https://coveralls.io/r/JuliaLang/julia>

* Design of Julia
Expand Down
18 changes: 9 additions & 9 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ This section lists changes that do not have deprecation warnings.
to evaluate the wrapper. Consequently, package authors generally need to specialize
`copy` and `copyto!` methods rather than `broadcast` and `broadcast!`. This also allows
for more customization and control of fused broadcasts. See the
[Interfaces chapter](https://docs.julialang.org/en/latest/manual/interfaces/#man-interfaces-broadcasting-1)
[Interfaces chapter](https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting-1)
for more information.

* `find` has been renamed to `findall`. `findall`, `findfirst`, `findlast`, `findnext`
Expand Down Expand Up @@ -2756,7 +2756,7 @@ Library improvements
`JULIA_INPUT_COLOR` and `JULIA_ANSWER_COLOR` to `"bold"`.
For example, one way of doing this is adding `ENV["JULIA_INPUT_COLOR"] = :bold`
and `ENV["JULIA_ANSWER_COLOR"] = :bold` to the `.juliarc.jl` file. See the
[manual section on customizing colors](https://docs.julialang.org/en/latest/manual/interacting-with-julia#Customizing-Colors-1)
[manual section on customizing colors](https://docs.julialang.org/en/v1/stdlib/REPL/#Customizing-Colors-1)
for more information.

* The default color for info messages has been changed from blue to cyan
Expand Down Expand Up @@ -3119,7 +3119,7 @@ Experimental language features
------------------------------

* Support for
[multi-threading](https://docs.julialang.org/en/latest/manual/parallel-computing/#multi-threading-experimental).
[multi-threading](https://docs.julialang.org/en/v1/manual/parallel-computing/#man-multithreading-1).
Loops with independent iterations can be easily parallelized with the
`Threads.@threads` macro.

Expand Down Expand Up @@ -3521,7 +3521,7 @@ Deprecated or removed
* `@unix_only` is deprecated in favor of `if is_unix()`
* `@osx_only` is deprecated in favor of `if is_apple()`
* `@linux_only` is deprecated in favor of `if is_linux()`
* NOTE: Using `@static` could be useful/necessary when used in a function's local scope. See details at the section entitled [Handling Operating System Variation](https://docs.julialang.org/en/latest/manual/handling-operating-system-variation/#man-handling-operating-system-variation) in the manual.
* NOTE: Using `@static` could be useful/necessary when used in a function's local scope. See details at the section entitled [Handling Operating System Variation](https://docs.julialang.org/en/v1/manual/handling-operating-system-variation/) in the manual.

Command-line option changes
---------------------------
Expand Down Expand Up @@ -3578,7 +3578,7 @@ New language features
types instead of to their values. The function then returns an expression forming the
body of the function to be called at run time ([#7311]).

* [Documentation system](https://docs.julialang.org/en/latest/manual/documentation/)
* [Documentation system](https://docs.julialang.org/en/v1/manual/documentation/)
for functions, methods, types and macros in packages and user code ([#8791]).

* The syntax `function foo end` can be used to introduce a generic function without
Expand Down Expand Up @@ -3608,11 +3608,11 @@ New language features
* `++` is now parsed as an infix operator, but does not yet have a default definition ([#11030], [#11686]).

* Support for inter-task communication using `Channels` ([#12264]).
See https://docs.julialang.org/en/latest/manual/parallel-computing/#channels for details.
See https://docs.julialang.org/en/v1/manual/parallel-computing/#Channels-1 for details.

* `RemoteRef`s now point to remote channels. The remote channels can be of length greater than 1.
Default continues to be of length 1 ([#12385]).
See https://docs.julialang.org/en/latest/manual/parallel-computing/#remoterefs-and-abstractchannels for details.
See https://docs.julialang.org/en/v1/manual/parallel-computing/#Remote-References-and-AbstractChannels-1 for details.

* `@__LINE__` special macro now available to reflect invocation source line number ([#12727]).

Expand Down Expand Up @@ -4813,8 +4813,8 @@ Bugfixes and performance updates

Too numerous to mention.

[packages chapter]: https://docs.julialang.org/en/latest/manual/packages/
[sorting functions]: https://docs.julialang.org/en/latest/stdlib/sort/
[packages chapter]: https://docs.julialang.org/en/v1/stdlib/Pkg/
[sorting functions]: https://docs.julialang.org/en/v1/base/sort/
[pairwise summation]: https://en.wikipedia.org/wiki/Pairwise_summation
[a448e080]: https://github.com/JuliaLang/julia/commit/a448e080dc736c7fb326426dfcb2528be36973d3
[5e3f074b]: https://github.com/JuliaLang/julia/commit/5e3f074b9173044a0a4219f9b285879ff7cec041
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Standard library changes
* A 1-d `Zip` iterator (where `Base.IteratorSize` is `Base.HasShape{1}()`) with defined length of `n` has now also size of `(n,)` (instead of throwing an error with truncated iterators) ([#29927]).
* The `@timed` macro now returns a `NamedTuple` ([#34149])
* New `supertypes(T)` function returns a tuple of all supertypes of `T` ([#34419]).
* Views of builtin ranges are now recomputed ranges (like indexing returns) instead of
`SubArray`s ([#26872]).
* Sorting-related functions such as `sort` that take the keyword arguments `lt`, `rev`, `order`
and `by` now do not discard `order` if `by` or `lt` are passed. In the former case, the
order from `order` is used to compare the values of `by(element)`. In the latter case,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and installing Julia, below.
- **Homepage:** <https://julialang.org>
- **Binaries:** <https://julialang.org/downloads/>
- **Source code:** <https://github.com/JuliaLang/julia>
- **Documentation:** <https://docs.julialang.org/>
- **Documentation:** <https://docs.julialang.org>
- **Packages:** <https://pkg.julialang.org/>
- **Discussion forum:** <https://discourse.julialang.org>
- **Slack:** <https://julialang.slack.com> (get an invite from <https://slackinvite.julialang.org>)
Expand Down
15 changes: 12 additions & 3 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,15 @@ See also [`copyto!`](@ref).
This method requires at least Julia 1.1. In Julia 1.0 this method
is available from the `Future` standard library as `Future.copy!`.
"""
copy!(dst::AbstractVector, src::AbstractVector) = append!(empty!(dst), src)
function copy!(dst::AbstractVector, src::AbstractVector)
if length(dst) != length(src)
resize!(dst, length(src))
end
for i in eachindex(dst, src)
@inbounds dst[i] = src[i]
end
dst
end

function copy!(dst::AbstractArray, src::AbstractArray)
axes(dst) == axes(src) || throw(ArgumentError(
Expand Down Expand Up @@ -1112,8 +1120,9 @@ end
"""
parent(A)
Returns the "parent array" of an array view type (e.g., `SubArray`), or the array itself if
it is not a view.
Return the underlying "parent array”. This parent array of objects of types `SubArray`, `ReshapedArray`
or `LinearAlgebra.Transpose` is what was passed as an argument to `view`, `reshape`, `transpose`, etc.
during object creation. If the input is not a wrapped object, return the input itself.
# Examples
```jldoctest
Expand Down
19 changes: 3 additions & 16 deletions base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,22 +424,9 @@ Dict{Int64,String} with 1 entry:
function filter(f, d::AbstractDict)
# don't just do filter!(f, copy(d)): avoid making a whole copy of d
df = empty(d)
try
for pair in d
if f(pair)
df[pair.first] = pair.second
end
end
catch e
if isa(e, MethodError) && e.f === f
depwarn("In `filter(f, dict)`, `f` is now passed a single pair instead of two arguments.", :filter)
for (k, v) in d
if f(k, v)
df[k] = v
end
end
else
rethrow()
for pair in d
if f(pair)
df[pair.first] = pair.second
end
end
return df
Expand Down
2 changes: 1 addition & 1 deletion base/arrayshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end
const undef_ref_alignment = (3,3)

"""
`alignment(X, rows, cols, cols_if_complete, cols_otherwise, sep)` returns the
`alignment(io, X, rows, cols, cols_if_complete, cols_otherwise, sep)` returns the
alignment for specified parts of array `X`, returning the (left,right) info.
It will look in X's `rows`, `cols` (both lists of indices)
and figure out what's needed to be fully aligned, for example looking all
Expand Down
5 changes: 5 additions & 0 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ over `Array{Bool, N}` and allowing some operations to work on 64 values at once.
By default, Julia returns `BitArrays` from [broadcasting](@ref Broadcasting) operations
that generate boolean elements (including dotted-comparisons like `.==`) as well as from
the functions [`trues`](@ref) and [`falses`](@ref).
!!! note
Due to its packed storage format, concurrent access to the elements of a `BitArray`
where at least one of them is a write is not thread safe.
"""
mutable struct BitArray{N} <: AbstractArray{Bool, N}
chunks::Vector{UInt64}
Expand Down
36 changes: 26 additions & 10 deletions base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ BroadcastStyle(a::AbstractArrayStyle{M}, ::DefaultArrayStyle{N}) where {M,N} =
# methods that instead specialize on `BroadcastStyle`,
# copyto!(dest::AbstractArray, bc::Broadcasted{MyStyle})

struct Broadcasted{Style<:Union{Nothing,BroadcastStyle}, Axes, F, Args<:Tuple}
struct Broadcasted{Style<:Union{Nothing,BroadcastStyle}, Axes, F, Args<:Tuple} <: Base.AbstractBroadcasted
f::F
args::Args
axes::Axes # the axes of the resulting object (may be bigger than implied by `args` if this is nested inside a larger `Broadcasted`)
Expand All @@ -193,21 +193,25 @@ function Base.show(io::IO, bc::Broadcasted{Style}) where {Style}
end

## Allocating the output container
Base.similar(bc::Broadcasted{DefaultArrayStyle{N}}, ::Type{ElType}) where {N,ElType} =
similar(Array{ElType}, axes(bc))
Base.similar(bc::Broadcasted{DefaultArrayStyle{N}}, ::Type{Bool}) where N =
similar(BitArray, axes(bc))
Base.similar(bc::Broadcasted, ::Type{T}) where {T} = similar(bc, T, axes(bc))
Base.similar(::Broadcasted{DefaultArrayStyle{N}}, ::Type{ElType}, dims) where {N,ElType} =
similar(Array{ElType}, dims)
Base.similar(::Broadcasted{DefaultArrayStyle{N}}, ::Type{Bool}, dims) where N =
similar(BitArray, dims)
# In cases of conflict we fall back on Array
Base.similar(bc::Broadcasted{ArrayConflict}, ::Type{ElType}) where ElType =
similar(Array{ElType}, axes(bc))
Base.similar(bc::Broadcasted{ArrayConflict}, ::Type{Bool}) =
similar(BitArray, axes(bc))
Base.similar(::Broadcasted{ArrayConflict}, ::Type{ElType}, dims) where ElType =
similar(Array{ElType}, dims)
Base.similar(::Broadcasted{ArrayConflict}, ::Type{Bool}, dims) =
similar(BitArray, dims)

@inline Base.axes(bc::Broadcasted) = _axes(bc, bc.axes)
_axes(::Broadcasted, axes::Tuple) = axes
@inline _axes(bc::Broadcasted, ::Nothing) = combine_axes(bc.args...)
_axes(bc::Broadcasted{<:AbstractArrayStyle{0}}, ::Nothing) = ()

@inline Base.axes(bc::Broadcasted{<:Any, <:NTuple{N}}, d::Integer) where N =
d <= N ? axes(bc)[d] : OneTo(1)

BroadcastStyle(::Type{<:Broadcasted{Style}}) where {Style} = Style()
BroadcastStyle(::Type{<:Broadcasted{S}}) where {S<:Union{Nothing,Unknown}} =
throw(ArgumentError("Broadcasted{Unknown} wrappers do not have a style assigned"))
Expand All @@ -219,6 +223,12 @@ argtype(bc::Broadcasted) = argtype(typeof(bc))
_eachindex(t::Tuple{Any}) = t[1]
_eachindex(t::Tuple) = CartesianIndices(t)

Base.IndexStyle(bc::Broadcasted) = IndexStyle(typeof(bc))
Base.IndexStyle(::Type{<:Broadcasted{<:Any,<:Tuple{Any}}}) = IndexLinear()
Base.IndexStyle(::Type{<:Broadcasted{<:Any}}) = IndexCartesian()

Base.LinearIndices(bc::Broadcasted{<:Any,<:Tuple{Any}}) = axes(bc)[1]

Base.ndims(::Broadcasted{<:Any,<:NTuple{N,Any}}) where {N} = N
Base.ndims(::Type{<:Broadcasted{<:Any,<:NTuple{N,Any}}}) where {N} = N

Expand Down Expand Up @@ -564,7 +574,13 @@ end
@boundscheck checkbounds(bc, I)
@inbounds _broadcast_getindex(bc, I)
end
Base.@propagate_inbounds Base.getindex(bc::Broadcasted, i1::Integer, i2::Integer, I::Integer...) = bc[CartesianIndex((i1, i2, I...))]
Base.@propagate_inbounds Base.getindex(
bc::Broadcasted,
i1::Union{Integer,CartesianIndex},
i2::Union{Integer,CartesianIndex},
I::Union{Integer,CartesianIndex}...,
) =
bc[CartesianIndex((i1, i2, I...))]
Base.@propagate_inbounds Base.getindex(bc::Broadcasted) = bc[CartesianIndex(())]

@inline Base.checkbounds(bc::Broadcasted, I::Union{Integer,CartesianIndex}) =
Expand Down
11 changes: 6 additions & 5 deletions base/channels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,16 @@ false
```jldoctest
julia> c = Channel(0);
julia> task = @async (put!(c,1);error("foo"));
julia> task = @async (put!(c, 1); error("foo"));
julia> bind(c,task);
julia> bind(c, task);
julia> take!(c)
1
julia> put!(c,1);
ERROR: foo
julia> put!(c, 1);
ERROR: TaskFailedException:
foo
Stacktrace:
[...]
```
Expand Down Expand Up @@ -281,7 +282,7 @@ function close_chnl_on_taskdone(t::Task, c::Channel)
if istaskfailed(t)
excp = task_result(t)
if excp isa Exception
close(c, excp)
close(c, TaskFailedException(t))
return
end
end
Expand Down
26 changes: 24 additions & 2 deletions base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ end
"""
**Welcome to Julia $(string(VERSION)).** The full manual is available at
https://docs.julialang.org/
https://docs.julialang.org
as well as many great tutorials and learning resources:
Expand All @@ -24,7 +24,7 @@ For help on a specific function or macro, type `?` followed
by its name, e.g. `?cos`, or `?@time`, and press enter.
Type `;` to enter shell mode, `]` to enter package mode.
"""
kw"help", kw"?", kw"Julia", kw"julia", kw""
kw"help", kw"Julia", kw"julia", kw""

"""
using
Expand Down Expand Up @@ -644,6 +644,28 @@ desired can be used.
"""
kw"if", kw"elseif", kw"else"

"""
a ? b : c
Short form for conditionals; read "if `a`, evaluate `b` otherwise evaluate `c`".
Also known as the [ternary operator](https://en.wikipedia.org/wiki/%3F:).
This syntax is equivalent to `if a; b else c end`, but is often used to
emphasize the value `b`-or-`c` which is being used as part of a larger
expression, rather than the side effects that evaluating `b` or `c` may have.
See the manual section on [control flow](@ref man-conditional-evaluation) for more details.
# Examples
```
julia> x = 1; y = 2;
julia> println(x > y ? "x is larger" : "y is larger")
y is larger
```
"""
kw"?", kw"?:"

"""
for
Expand Down
16 changes: 14 additions & 2 deletions base/errorshow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ function show_error_hints(io, ex, args...)
end
end

show_index(io::IO, x::Any) = show(io, x)
show_index(io::IO, x::Slice) = show_index(io, x.indices)
show_index(io::IO, x::LogicalIndex) = show_index(io, x.mask)
show_index(io::IO, x::OneTo) = print(io, "1:", x.stop)
show_index(io::IO, x::Colon) = print(io, ':')


function showerror(io::IO, ex::BoundsError)
print(io, "BoundsError")
if isdefined(ex, :a)
Expand All @@ -118,10 +125,15 @@ function showerror(io::IO, ex::BoundsError)
if isdefined(ex, :i)
!isa(ex.a, AbstractArray) && print(io, "\n ")
print(io, " at index [")
if isa(ex.i, AbstractRange)
if ex.i isa AbstractRange
print(io, ex.i)
elseif ex.i isa AbstractString
show(io, ex.i)
else
join(io, ex.i, ", ")
for (i, x) in enumerate(ex.i)
i > 1 && print(io, ", ")
show_index(io, x)
end
end
print(io, ']')
end
Expand Down
3 changes: 2 additions & 1 deletion base/floatfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ end
# NOTE: this relies on the current keyword dispatch behaviour (#9498).
function round(x::Real, r::RoundingMode=RoundNearest;
digits::Union{Nothing,Integer}=nothing, sigdigits::Union{Nothing,Integer}=nothing, base::Union{Nothing,Integer}=nothing)
isfinite(x) || return x
if digits === nothing
if sigdigits === nothing
if base === nothing
Expand All @@ -139,10 +138,12 @@ function round(x::Real, r::RoundingMode=RoundNearest;
# or throw(ArgumentError("`round` cannot use `base` argument without `digits` or `sigdigits` arguments."))
end
else
isfinite(x) || return float(x)
_round_sigdigits(x, r, sigdigits, base === nothing ? 10 : base)
end
else
if sigdigits === nothing
isfinite(x) || return float(x)
_round_digits(x, r, digits, base === nothing ? 10 : base)
else
throw(ArgumentError("`round` cannot use both `digits` and `sigdigits` arguments."))
Expand Down
Loading

0 comments on commit d453af0

Please sign in to comment.