Skip to content

Commit dba7e57

Browse files
authored
deprecate some trues and falses constructors (#24867)
- falses(A::AbstractArray) -> falses(size(A)) - trues(A::AbstractArray) -> trues(size(A))
1 parent 197785d commit dba7e57

File tree

5 files changed

+9
-42
lines changed

5 files changed

+9
-42
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,9 @@ Deprecated or removed
693693
* `a:b` is deprecated for constructing a `StepRange` when `a` and `b` have physical units
694694
(Dates and Times). Use `a:s:b`, where `s = Dates.Day(1)` or `s = Dates.Second(1)`.
695695

696+
* `trues(A::AbstractArray)` and `falses(A::AbstractArray)` are deprecated in favor of
697+
`trues(size(A))` and `falses(size(A))` respectively ([#24595]).
698+
696699
* `cumsum`, `cumprod`, `accumulate`, and their mutating versions now require a `dim`
697700
argument instead of defaulting to using the first dimension ([#24684]).
698701

base/bitarray.jl

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -382,25 +382,6 @@ julia> falses(2,3)
382382
"""
383383
falses(dims::Dims) = fill!(BitArray(uninitialized, dims), false)
384384
falses(dims::Integer...) = falses(map(Int,dims))
385-
"""
386-
falses(A)
387-
388-
Create a `BitArray` with all values set to `false` of the same shape as `A`.
389-
390-
# Examples
391-
```jldoctest
392-
julia> A = [1 2; 3 4]
393-
2×2 Array{Int64,2}:
394-
1 2
395-
3 4
396-
397-
julia> falses(A)
398-
2×2 BitArray{2}:
399-
false false
400-
false false
401-
```
402-
"""
403-
falses(A::AbstractArray) = falses(size(A))
404385

405386
"""
406387
trues(dims)
@@ -417,25 +398,6 @@ julia> trues(2,3)
417398
"""
418399
trues(dims::Dims) = fill!(BitArray(uninitialized, dims), true)
419400
trues(dims::Integer...) = trues(map(Int,dims))
420-
"""
421-
trues(A)
422-
423-
Create a `BitArray` with all values set to `true` of the same shape as `A`.
424-
425-
# Examples
426-
```jldoctest
427-
julia> A = [1 2; 3 4]
428-
2×2 Array{Int64,2}:
429-
1 2
430-
3 4
431-
432-
julia> trues(A)
433-
2×2 BitArray{2}:
434-
true true
435-
true true
436-
```
437-
"""
438-
trues(A::AbstractArray) = trues(size(A))
439401

440402
function one(x::BitMatrix)
441403
m, n = size(x)

base/deprecated.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,6 +2162,10 @@ end
21622162
# issue #24822
21632163
@deprecate_binding Display AbstractDisplay
21642164

2165+
# 24595
2166+
@deprecate falses(A::AbstractArray) falses(size(A))
2167+
@deprecate trues(A::AbstractArray) trues(size(A))
2168+
21652169
# issue #24794
21662170
@deprecate linspace(start, stop) linspace(start, stop, 50)
21672171
@deprecate logspace(start, stop) logspace(start, stop, 50)

doc/src/manual/arrays.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ omitted it will default to [`Float64`](@ref).
5454
| [`zeros(T, dims...)`](@ref) | an `Array` of all zeros |
5555
| [`ones(T, dims...)`](@ref) | an `Array` of all ones |
5656
| [`trues(dims...)`](@ref) | a [`BitArray`](@ref) with all values `true` |
57-
| [`trues(A)`](@ref) | a `BitArray` with all values `true` and the same shape as `A` |
5857
| [`falses(dims...)`](@ref) | a `BitArray` with all values `false` |
59-
| [`falses(A)`](@ref) | a `BitArray` with all values `false` and the same shape as `A` |
6058
| [`reshape(A, dims...)`](@ref) | an array containing the same data as `A`, but with different dimensions |
6159
| [`copy(A)`](@ref) | copy `A` |
6260
| [`deepcopy(A)`](@ref) | copy `A`, recursively copying its elements |

test/bitarray.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ allsizes = [((), BitArray{0}), ((v1,), BitVector),
6262
@test b == trues(sz)
6363
@test all(b)
6464
@test sz == size(b)
65-
c = trues(a)
65+
c = trues(size(a))
6666
@test all(c)
6767
@test !any(a)
6868
@test sz == size(c)
69-
d = falses(b)
69+
d = falses(size(b))
7070
@test !any(d)
7171
@test all(b)
7272
@test sz == size(d)

0 commit comments

Comments
 (0)