Table.copy() changes sparsity
- Dominant language
- Python
- Stars
- 5.7k
- Forks
- 1.1k
- Avg merge
- 12d 2h
- Merged PRs (30d)
- 1
Description
`Table.copy` can sometimes change sparsity, which is unexpected. It is likely needlessly complex as it goes through the constructor (`Table.__new__`). I found this in one of our tests:
```
import unittest
from Orange.data import Table
from scipy import sparse as sp
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.data.owmergedata import OWMergeData
class TestOWMergeDataBug(WidgetTest):
def test_sparse(self):
self.widget = self.create_widget(OWMergeData)
data = Table("iris")[::25]
data_ed_sparse = Table("titanic")[::300].to_sparse()
self.send_signal("Data", data)
self.send_signal("Extra Data", data_ed_sparse)
output_sparse = self.get_output("Data")
self.assertTrue(sp.issparse(output_sparse.X))
output_sparse = output_sparse.copy()
self.assertTrue(sp.issparse(output_sparse.X)) # FAILS
if __name__ == "__main__":
unittest.main()
```
Contributor guide
Research direction
Start with the Table.copy and Table.__new__ entry points named in the issue, then run the provided TestOWMergeDataBug.test_sparse reproduction. Trace why copying output_sparse changes the sparsity of X, and verify that the sparse assertion passes after the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100