File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -1380,6 +1380,7 @@ function _binarymap(f::Function,
1380
1380
mode:: Int ) where {Tx,Ty}
1381
1381
0 <= mode <= 2 || throw (ArgumentError (" Incorrect mode $mode ." ))
1382
1382
R = Base. Broadcast. combine_eltypes (f, (x, y))
1383
+ I = promote_type (eltype (nonzeroinds (x)), eltype (nonzeroinds (y)))
1383
1384
n = length (x)
1384
1385
length (y) == n || throw (DimensionMismatch ())
1385
1386
@@ -1391,7 +1392,7 @@ function _binarymap(f::Function,
1391
1392
my = length (ynzind)
1392
1393
cap = (mode == 0 ? min (mx, my) : mx + my):: Int
1393
1394
1394
- rind = Vector {Int } (undef, cap)
1395
+ rind = Vector {I } (undef, cap)
1395
1396
rval = Vector {R} (undef, cap)
1396
1397
ir = 0
1397
1398
ir = (
Original file line number Diff line number Diff line change @@ -1601,6 +1601,12 @@ end
1601
1601
@test length (nonzeros (simA)) == 0
1602
1602
end
1603
1603
1604
+ @testset " map preserves index types" begin
1605
+ v1 = spzeros (Float32, Int16, 10 )
1606
+ v2 = spzeros (Float32, Int32, 10 )
1607
+ @test eltype (typeof (SparseArrays. nonzeroinds (map (max, v1, v2)))) == Int32
1608
+ end
1609
+
1604
1610
@testset " Fast operations on full column views" begin
1605
1611
n = 1000
1606
1612
A = sprandn (n, n, 0.01 )
You can’t perform that action at this time.
0 commit comments