-
Notifications
You must be signed in to change notification settings - Fork 56
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
add == for vectors #248
add == for vectors #248
Conversation
Codecov Report
@@ Coverage Diff @@
## main #248 +/- ##
==========================================
- Coverage 91.82% 91.80% -0.03%
==========================================
Files 12 12
Lines 7307 7330 +23
==========================================
+ Hits 6710 6729 +19
- Misses 597 601 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This reminds of our broadcast code. Couldn't we replace the code by |
julia> using SparseArrays
julia> a = sprandn(100000, 0.9);
julia> b = sprandn(100000, 0.9);
julia> @time a .== b;
0.002611 seconds (7 allocations: 879.344 KiB) i agree that they are similar but that would make it allocating. i don't think we want that. |
What I had in mind is something lazy like |
Do we have tests for this? Including things like equal vectors where one has a stored zero? |
i added a test with explicit zero |
if you have something specific in mind, do share |
Do we really need all the |
Co-authored-by: Daniel Karrasch <[email protected]>
@ViralBShah on really large examples, yeah julia> @benchmark eq1($A, $B)
BenchmarkTools.Trial: 29 samples with 1 evaluation.
Range (min … max): 168.045 ms … 186.107 ms ┊ GC (min … max): 0.00% … 0.00%
Time (median): 173.698 ms ┊ GC (median): 0.00%
Time (mean ± σ): 174.602 ms ± 4.069 ms ┊ GC (mean ± σ): 0.00% ± 0.00%
▁ ▁▁▁▁█ ██ ▁ █▁▁ ▁▁▁█ ▁▁ ▁ ▁ ▁ ▁ ▁ ▁
█▁▁▁▁▁█████▁▁██▁█▁███▁████▁▁██▁▁▁█▁█▁▁▁█▁▁█▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁█ ▁
168 ms Histogram: frequency by time 186 ms <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark eq2($A, $B)
BenchmarkTools.Trial: 23 samples with 1 evaluation.
Range (min … max): 189.635 ms … 370.411 ms ┊ GC (min … max): 0.00% … 0.00%
Time (median): 200.284 ms ┊ GC (median): 0.00%
Time (mean ± σ): 221.056 ms ± 49.187 ms ┊ GC (mean ± σ): 0.00% ± 0.00%
█▅
▅███▁██▅▁▁▁▁▅▁▁▁▁▅▅▅▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▅▁▅ ▁
190 ms Histogram: frequency by time 370 ms < |
i could replace the last two loops with return all(iszero, view(nonzeros(A), i:nnz(A))) && all(iszero, view(nonzeros(B), j:nnz(B))) |
@ViralBShah so do i replace it or no? |
I think either way is fine. |
This patch updates SparseArrays. In particular it contains JuliaSparse/SparseArrays.jl#260 which is necessary to make progress in #46759. All changes: - Fix ambiguities with Base. (JuliaSparse/SparseArrays.jl#268) - add == for vectors (JuliaSparse/SparseArrays.jl#248) - add undef initializers (JuliaSparse/SparseArrays.jl#263) - Make sure reductions benefit from sparsity (JuliaSparse/SparseArrays.jl#244) - Remove fkeep! from the documentation (JuliaSparse/SparseArrays.jl#261) - Fix direction of circshift (JuliaSparse/SparseArrays.jl#260) - Fix `vcat` of sparse vectors with numbers (JuliaSparse/SparseArrays.jl#253) - decrement should always return a vector (JuliaSparse/SparseArrays.jl#241) - change order of arguments in fkeep, fix bug with fixed elements (JuliaSparse/SparseArrays.jl#240) - Sparse matrix/vectors with fixed sparsity pattern. (JuliaSparse/SparseArrays.jl#201)
This patch updates SparseArrays. In particular it contains JuliaSparse/SparseArrays.jl#260 which is necessary to make progress in #46759. All changes: - Fix ambiguities with Base. (JuliaSparse/SparseArrays.jl#268) - add == for vectors (JuliaSparse/SparseArrays.jl#248) - add undef initializers (JuliaSparse/SparseArrays.jl#263) - Make sure reductions benefit from sparsity (JuliaSparse/SparseArrays.jl#244) - Remove fkeep! from the documentation (JuliaSparse/SparseArrays.jl#261) - Fix direction of circshift (JuliaSparse/SparseArrays.jl#260) - Fix `vcat` of sparse vectors with numbers (JuliaSparse/SparseArrays.jl#253) - decrement should always return a vector (JuliaSparse/SparseArrays.jl#241) - change order of arguments in fkeep, fix bug with fixed elements (JuliaSparse/SparseArrays.jl#240) - Sparse matrix/vectors with fixed sparsity pattern. (JuliaSparse/SparseArrays.jl#201)
merge on green.
Closes #246