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

Fix leading duplicates in COO. #19

Closed
wants to merge 1 commit into from
Closed

Fix leading duplicates in COO. #19

wants to merge 1 commit into from

Conversation

MaxvdKolk
Copy link

When leading duplicates are present in a COO matrix, the conversion
towards CSR becomes invalid and not identical to the original COO
representation. This changes the dedupe function, such that leading
duplicates are treated correctly by starting the counter at -1 compared
to 0.

The following illustrates the problem:

// create identity matrix with a duplicate at (0,0) that should drop out
coo := NewCOO(2, 2, make([]int, 0), make([]int, 0), make([]float64, 0))
coo.Set(0, 0, 100)
coo.Set(0, 0, -100)
coo.Set(0, 0, 1)	
coo.Set(1, 1, 1)

csr := coo.ToCSR()

// compare matrices after conversion to CSR, expect equal matrices. 
if !mat.Equal(coo, csr) {
    fmt.Printf("Expected:\n%v\n but created:\n%v\n", mat.Formatted(coo), mat.Formatted(csr))
}

When evaluated, we observe the output, showing the influence of the leading duplicates.

⎡1  0⎤
⎣0  1⎦
but created:
⎡100    0⎤
⎣  0    1⎦

The committed change should resolve this.

When leading duplicates are present in a COO matrix, the conversion
towards CSR becomes invalid and not identical to the original COO
representation. This changes the dedupe function, such that leading
duplicates are treated correctly by starting the counter at -1 compared
to 0.
@codecov
Copy link

codecov bot commented Jun 10, 2020

Codecov Report

Merging #19 into master will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #19      +/-   ##
==========================================
+ Coverage   76.08%   76.10%   +0.02%     
==========================================
  Files          15       15              
  Lines        2354     2356       +2     
==========================================
+ Hits         1791     1793       +2     
  Misses        385      385              
  Partials      178      178              
Impacted Files Coverage Δ
coordinate.go 89.02% <100.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ae25042...d6ed124. Read the comment docs.

@MaxvdKolk MaxvdKolk closed this by deleting the head repository Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant