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 flipbits! in favor of dot-broadcasting #27067

Merged
merged 4 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Deprecate flipbits! in favor of dot-broadcasting
Seems like we no longer need this function:

```julia
julia> B = bitrand(100,1000);

julia> @benchmark flipbits!($B)
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     87.996 ns (0.00% GC)
  median time:      88.474 ns (0.00% GC)
  mean time:        88.596 ns (0.00% GC)
  maximum time:     118.378 ns (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     960

julia> @benchmark $B .= .!$B
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     88.060 ns (0.00% GC)
  median time:      88.202 ns (0.00% GC)
  mean time:        88.314 ns (0.00% GC)
  maximum time:     137.057 ns (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     960
```
  • Loading branch information
mbauman committed May 10, 2018
commit 97df0c3f57adc04fde7fae36aab662a9315bf22c
30 changes: 0 additions & 30 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1062,36 +1062,6 @@ function (-)(B::BitArray)
return A
end

"""
flipbits!(B::BitArray{N}) -> BitArray{N}

Performs a bitwise not operation on `B`. See [`~`](@ref).

# Examples
```jldoctest
julia> A = trues(2,2)
2×2 BitArray{2}:
true true
true true

julia> flipbits!(A)
2×2 BitArray{2}:
false false
false false
```
"""
function flipbits!(B::BitArray)
Bc = B.chunks
@inbounds if !isempty(Bc)
for i = 1:length(Bc)
Bc[i] = ~Bc[i]
end
Bc[end] &= _msk_end(B)
end
return B
end


## Binary arithmetic operators ##

for f in (:+, :-)
Expand Down
3 changes: 3 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,9 @@ function search(buf::IOBuffer, delim::UInt8)
return Int(q-p+1)
end

# Issue #27067
@deprecate flipbits!(B::BitArray) B .= .!B

@deprecate linearindices(x::AbstractArray) LinearIndices(x)

# PR #26647
Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ export

# bitarrays
falses,
flipbits!,
trues,

# dequeues
Expand Down
10 changes: 0 additions & 10 deletions doc/src/base/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,3 @@ Base.reverse(::AbstractVector; kwargs...)
Base.reverseind
Base.reverse!
```

## BitArrays

[`BitArray`](@ref)s are space-efficient "packed" boolean arrays, which store one bit per boolean value.
They can be used similarly to `Array{Bool}` arrays (which store one byte per boolean value),
and can be converted to/from the latter via `Array(bitarray)` and `BitArray(array)`, respectively.

```@docs
Base.flipbits!
```
4 changes: 4 additions & 0 deletions doc/src/manual/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,10 @@ indirectly. By putting the [`@views`](@ref) macro in front of an expression or
block of code, any `array[...]` slice in that expression will be converted to
create a `SubArray` view instead.

[`BitArray`](@ref)s are space-efficient "packed" boolean arrays, which store one bit per boolean value.
They can be used similarly to `Array{Bool}` arrays (which store one byte per boolean value),
and can be converted to/from the latter via `Array(bitarray)` and `BitArray(array)`, respectively.

A "strided" array is stored in memory with elements laid out in regular offsets such that
an instance with a supported `isbits` element type can be passed to
external C and Fortran functions that expect this memory layout. Strided arrays
Expand Down