From 8409a43d2da3bc468529f4f84cf7bb87ed1f9faf Mon Sep 17 00:00:00 2001 From: Daniel McDonald Date: Sat, 5 Nov 2016 11:21:41 -0700 Subject: [PATCH] BUG: fixes #717 --- ChangeLog.md | 2 ++ tests/test_table.py | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 5efb985e..3e2a4d99 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -19,7 +19,9 @@ New Features: * `Table.sort_order` was performing an implicit cast to dense, and not leveraging fancy indexing. A substantial performance gain was acheived. See [PR #720](https://github.com/biocore/biom-format/pull/720) Bug fixes: + * ``-o`` is now a required parameter of ``biom from-uc``. This was not the case previously, which resulted in a cryptic error message if ``-o`` was not provided. See [issue #683](https://github.com/biocore/biom-format/issues/683). +* Matrices are now cast to csr on `Table` construction if the data evaluate as `isspmatrix`. This fixes [#717](https://github.com/biocore/biom-format/issues/717) where some API methods assumed the data were csc or csr. biom 2.1.5 ---------- diff --git a/tests/test_table.py b/tests/test_table.py index e881b1cf..89037cf4 100644 --- a/tests/test_table.py +++ b/tests/test_table.py @@ -19,6 +19,7 @@ import numpy.testing as npt import numpy as np from scipy.sparse import lil_matrix, csr_matrix, csc_matrix +import scipy.sparse from biom import example_table from biom.exception import (UnknownAxisError, UnknownIDError, TableException, @@ -1711,6 +1712,15 @@ def test_update_ids_cache_bug(self): exp_index = {'x': 0, 'y': 1} self.assertEqual(obs._sample_index, exp_index) + def test_other_spmatrix_type(self): + # I dont actually remember what bug stemmed from this... + ss = scipy.sparse + for c in [ss.lil_matrix, ss.bsr_matrix, ss.coo_matrix, ss.dia_matrix, + ss.dok_matrix, ss.csc_matrix, ss.csr_matrix]: + mat = c((2, 2)) + t = Table(mat, ['a', 'b'], [1, 2]) + self.assertTrue(isinstance(t.matrix_data, (csr_matrix, csc_matrix))) + def test_sort_order(self): """sorts tables by arbitrary order""" # sort by observations arbitrary order