Skip to content

Commit

Permalink
OWFile: Add test for loading sparse data
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicc committed Apr 21, 2017
1 parent 337f1b2 commit 35727c9
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Orange/widgets/data/tests/test_owfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
# pylint: disable=missing-docstring
from os import path, remove
from unittest.mock import Mock
import pickle
import tempfile


import numpy as np
import scipy.sparse as sp

from AnyQt.QtCore import QMimeData, QPoint, Qt, QUrl
from AnyQt.QtGui import QDragEnterEvent, QDropEvent
Expand Down Expand Up @@ -195,3 +199,19 @@ def test_check_datetime_disabled(self):
for i in range(4):
vartype_delegate.setEditorData(combo, idx(i))
self.assertEqual(combo.count(), counts[i])

def test_domain_edit_on_sparse_data(self):
iris = Table("iris")
iris.X = sp.csr_matrix(iris.X)

f = tempfile.NamedTemporaryFile(suffix='.pickle', delete=False)
pickle.dump(iris, f)
f.close()

self.widget.add_path(f.name)
self.widget.load_data()

output = self.get_output("Data")
self.assertIsInstance(output, Table)
self.assertEqual(iris.X.shape, output.X.shape)
self.assertTrue(sp.issparse(output.X))

0 comments on commit 35727c9

Please sign in to comment.