Skip to content

Commit 95c64fd

Browse files
authored
Merge branch 'master' into rf/rand/depr-tuple
2 parents 8561baf + a1ff12c commit 95c64fd

File tree

313 files changed

+4489
-4522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+4489
-4522
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ The steps required to add a new docstring are listed below:
174174
Examples written within docstrings can be used as testcases known as "doctests" by annotating code blocks with `jldoctest`.
175175

176176
```jldoctest
177-
julia> Unicode.uppercase("Docstring test")
177+
julia> uppercase("Docstring test")
178178
"DOCSTRING TEST"
179179
```
180180

NEWS.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ New language features
4040
* Field access via dot-syntax can now be overloaded by adding methods to
4141
`Base.getproperty` and `Base.setproperty!` ([#1974]).
4242

43+
* Values for `Enum`s can now be specified inside of a `begin` block when using the
44+
`@enum` macro ([#25424]).
45+
4346
Language changes
4447
----------------
4548

@@ -176,6 +179,8 @@ Language changes
176179
* The syntax `using A.B` can now only be used when `A.B` is a module, and the syntax
177180
`using A: B` can only be used for adding single bindings ([#8000]).
178181

182+
* `=>` now has its own precedence level, giving it strictly higher precedence than
183+
`=` and `,` ([#25391]).
179184

180185
Breaking changes
181186
----------------
@@ -359,9 +364,27 @@ This section lists changes that do not have deprecation warnings.
359364
trait; see its documentation for details. Types which support subtraction (operator
360365
`-`) must now implement `widen` for hashing to work inside heterogeneous arrays.
361366

362-
* `findn(x::AbstractVector)` now return a 1-tuple with the vector of indices, to be
367+
* `findn(x::AbstractVector)` now returns a 1-tuple with the vector of indices, to be
363368
consistent with higher order arrays ([#25365]).
364369

370+
* `find` now returns the same type of indices as `keys`/`pairs` for `AbstractArray`,
371+
`AbstractDict`, `AbstractString`, `Tuple` and `NamedTuple` objects ([#24774]).
372+
In particular, this means that it returns `CartesianIndex` objects for matrices
373+
and higher-dimensional arrays instead of linear indices as was previously the case.
374+
Use `LinearIndices(a)[find(f, a)]` to compute linear indices.
375+
376+
* `AbstractSet` objects are now considered equal by `==` and `isequal` if all of their
377+
elements are equal ([#25368]). This has required changing the hashing algorithm
378+
for `BitSet`.
379+
380+
* the default behavior of `titlecase` is changed in two ways ([#23393]):
381+
+ characters not starting a word are converted to lowercase;
382+
a new keyword argument `strict` is added which
383+
allows to get the old behavior when it's `false`.
384+
+ any non-letter character is considered as a word separator;
385+
to get the old behavior (only "space" characters are considered as
386+
word separators), use the keyword `wordsep=isspace`.
387+
365388
Library improvements
366389
--------------------
367390

@@ -844,26 +867,25 @@ Deprecated or removed
844867
* `workspace` is discontinued, check out [Revise.jl](https://github.com/timholy/Revise.jl)
845868
for an alternative workflow ([#25046]).
846869

847-
* `cumsum`, `cumprod`, `accumulate`, and their mutating versions now require a `dim`
848-
argument instead of defaulting to using the first dimension ([#24684]).
870+
* `cumsum`, `cumprod`, `accumulate`, their mutating versions, and `diff` all now require a `dim`
871+
argument instead of defaulting to using the first dimension unless there is only
872+
one dimension ([#24684], [#25457]).
849873

850874
* The `sum_kbn` and `cumsum_kbn` functions have been moved to the
851875
[KahanSummation](https://github.com/JuliaMath/KahanSummation.jl) package ([#24869]).
852876

853-
* Unicode-related string functions have been moved to the new `Unicode` standard
854-
library module ([#25021]). This applies to `normalize_string`, `graphemes`,
855-
`is_assigned_char`, `textwidth`, `islower`, `isupper`, `isalpha`,
856-
`isdigit`, `isxdigit`, `isnumber`, `isalnum`, `iscntrl`, `ispunct`, `isspace`,
857-
`isprint`, `isgraph`, `lowercase`, `uppercase`, `titlecase`, `lcfirst` and `ucfirst`.
877+
* `isnumber` has been renamed to `isnumeric` ([#25021]).
878+
879+
* `is_assigned_char` and `normalize_string` have been renamed to `isassigned` and
880+
`normalize`, and moved to the new `Unicode` standard library module.
881+
`graphemes` has also been moved to that module ([#25021]).
858882

859883
* The functions `eigs` and `svds` have been moved to the `IterativeEigensolvers` standard
860884
library module ([#24714]).
861885

862-
* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).
886+
* Sparse array functionality has moved to the `SparseArrays` standard library module ([#25249]).
863887

864-
* `isnumber` has been deprecated in favor of `isnumeric`, `is_assigned_char`
865-
in favor of `isassigned` and `normalize_string` in favor of `normalize`, all three
866-
in the new `Unicode` standard library module ([#25021]).
888+
* `@printf` and `@sprintf` have been moved to the `Printf` standard library ([#23929],[#25056]).
867889

868890
* The aliases `Complex32`, `Complex64` and `Complex128` have been deprecated in favor of `ComplexF16`,
869891
`ComplexF32` and `ComplexF64` respectively ([#24647]).
@@ -918,6 +940,11 @@ Deprecated or removed
918940
* `rand(t::Tuple{Vararg{Int}})` is deprecated in favor of `rand(Float64, t)` or `rand(t...)`;
919941
`rand(::Tuple)` will have another meaning in the future ([#25429], [#25278]).
920942

943+
* The generic implementations of `strides(::AbstractArray)` and `stride(::AbstractArray, ::Int)`
944+
have been deprecated. Subtypes of `AbstractArray` that implement the newly introduced strided
945+
array interface should define their own `strides` method ([#25321]).
946+
947+
921948
Command-line option changes
922949
---------------------------
923950

@@ -1140,6 +1167,7 @@ Command-line option changes
11401167
[#24713]: https://github.com/JuliaLang/julia/issues/24713
11411168
[#24714]: https://github.com/JuliaLang/julia/issues/24714
11421169
[#24715]: https://github.com/JuliaLang/julia/issues/24715
1170+
[#24774]: https://github.com/JuliaLang/julia/issues/24774
11431171
[#24781]: https://github.com/JuliaLang/julia/issues/24781
11441172
[#24785]: https://github.com/JuliaLang/julia/issues/24785
11451173
[#24786]: https://github.com/JuliaLang/julia/issues/24786
@@ -1165,3 +1193,4 @@ Command-line option changes
11651193
[#25184]: https://github.com/JuliaLang/julia/issues/25184
11661194
[#25231]: https://github.com/JuliaLang/julia/issues/25231
11671195
[#25365]: https://github.com/JuliaLang/julia/issues/25365
1196+
[#25424]: https://github.com/JuliaLang/julia/issues/25424

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Code coverage:
1515

1616
[travis-img]: https://img.shields.io/travis/JuliaLang/julia/master.svg?label=Linux+/+macOS
1717
[appveyor-img]: https://img.shields.io/appveyor/ci/JuliaLang/julia/master.svg?label=Windows
18-
[coveralls-img]: https://img.shields.io/codecov/c/github/JuliaLang/julia/master.svg?label=coveralls
18+
[coveralls-img]: https://img.shields.io/coveralls/c/github/JuliaLang/julia/master.svg?label=coveralls
1919
[codecov-img]: https://img.shields.io/codecov/c/github/JuliaLang/julia/master.svg?label=codecov
2020

2121
## The Julia Language

base/Enums.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ julia> f(apple)
4646
"I'm a Fruit with value: 1"
4747
```
4848
49+
Values can also be specified inside a `begin` block, e.g.
50+
51+
```julia
52+
@enum EnumName begin
53+
value1
54+
value2
55+
end
56+
```
57+
4958
`BaseType`, which defaults to [`Int32`](@ref), must be a primitive subtype of `Integer`.
5059
Member values can be converted between the enum type and `BaseType`. `read` and `write`
5160
perform these conversions automatically.
@@ -69,7 +78,12 @@ macro enum(T, syms...)
6978
lo = hi = 0
7079
i = zero(basetype)
7180
hasexpr = false
81+
82+
if length(syms) == 1 && syms[1] isa Expr && syms[1].head == :block
83+
syms = syms[1].args
84+
end
7285
for s in syms
86+
s isa LineNumberNode && continue
7387
if isa(s, Symbol)
7488
if i == typemin(basetype) && !isempty(vals)
7589
throw(ArgumentError("overflow in value \"$s\" of Enum $typename"))

base/abstractarray.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,14 @@ eachindex(::IndexLinear, A::AbstractArray) = linearindices(A)
849849
function eachindex(::IndexLinear, A::AbstractArray, B::AbstractArray...)
850850
@_inline_meta
851851
indsA = linearindices(A)
852-
all(x->linearindices(x) == indsA, B) || throw_eachindex_mismatch(IndexLinear(), A, B...)
852+
_all_match_first(linearindices, indsA, B...) || throw_eachindex_mismatch(IndexLinear(), A, B...)
853853
indsA
854854
end
855+
function _all_match_first(f::F, inds, A, B...) where F<:Function
856+
@_inline_meta
857+
(inds == f(A)) & _all_match_first(f, inds, B...)
858+
end
859+
_all_match_first(f::F, inds) where F<:Function = true
855860

856861
isempty(a::AbstractArray) = (_length(a) == 0)
857862

@@ -1548,7 +1553,7 @@ function isequal(A::AbstractArray, B::AbstractArray)
15481553
return true
15491554
end
15501555

1551-
function cmp(A::AbstractArray, B::AbstractArray)
1556+
function cmp(A::AbstractVector, B::AbstractVector)
15521557
for (a, b) in zip(A, B)
15531558
if !isequal(a, b)
15541559
return isless(a, b) ? -1 : 1
@@ -1557,7 +1562,7 @@ function cmp(A::AbstractArray, B::AbstractArray)
15571562
return cmp(length(A), length(B))
15581563
end
15591564

1560-
isless(A::AbstractArray, B::AbstractArray) = cmp(A, B) < 0
1565+
isless(A::AbstractVector, B::AbstractVector) = cmp(A, B) < 0
15611566

15621567
function (==)(A::AbstractArray, B::AbstractArray)
15631568
if axes(A) != axes(B)
@@ -1727,7 +1732,7 @@ for all `i` and `j`.
17271732
17281733
# Examples
17291734
```jldoctest
1730-
julia> a = reshape(collect(1:16),(2,2,2,2))
1735+
julia> a = reshape(Vector(1:16),(2,2,2,2))
17311736
2×2×2×2 Array{Int64,4}:
17321737
[:, :, 1, 1] =
17331738
1 3

base/abstractarraymath.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Elements of `dims` must be unique and within the range `1:ndims(A)`.
5151
5252
# Examples
5353
```jldoctest
54-
julia> a = reshape(collect(1:4),(2,2,1,1))
54+
julia> a = reshape(Vector(1:4),(2,2,1,1))
5555
2×2×1×1 Array{Int64,4}:
5656
[:, :, 1, 1] =
5757
1 3
@@ -186,7 +186,7 @@ first dimension.
186186
187187
# Examples
188188
```jldoctest
189-
julia> b = reshape(collect(1:16), (4,4))
189+
julia> b = reshape(Vector(1:16), (4,4))
190190
4×4 Array{Int64,2}:
191191
1 5 9 13
192192
2 6 10 14

0 commit comments

Comments
 (0)