import numpy as np
import tabmat
from scipy.sparse import csc_matrix
rng = np.random.default_rng(seed=123)
X = rng.standard_normal(size=(100,20))
Xd = tabmat.DenseMatrix(X[:,:10])
Xs = tabmat.SparseMatrix(csc_matrix(X[:,10:]))
Xm = tabmat.SplitMatrix([Xd, Xs])
Xm.sandwich(np.ones(X.shape[0]))
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-2-91ba52e4f568> in <module>
8 Xs = tabmat.SparseMatrix(csc_matrix(X[:,10:]))
9 Xm = tabmat.SplitMatrix([Xd, Xs])
---> 10 Xm.sandwich(np.ones(X.shape[0]))
~/anaconda3/envs/py39/lib/python3.9/site-packages/tabmat/split_matrix.py in sandwich(self, d, rows, cols)
287 idx_i = subset_cols_indices[i]
288 mat_i = self.matrices[i]
--> 289 res = mat_i.sandwich(d, rows, subset_cols[i])
290 if isinstance(res, sps.dia_matrix):
291 out[(idx_i, idx_i)] += np.squeeze(res.data)
~/anaconda3/envs/py39/lib/python3.9/site-packages/tabmat/dense_matrix.py in sandwich(self, d, rows, cols)
62 d = np.asarray(d)
63 rows, cols = setup_restrictions(self.shape, rows, cols)
---> 64 return dense_sandwich(self, d, rows, cols)
65
66 def _cross_sandwich(
src/tabmat/ext/dense.pyx in tabmat.ext.dense.dense_sandwich()
Exception:
Xd = tabmat.DenseMatrix(X[:,:10].copy())
Xs = tabmat.SparseMatrix(csc_matrix(X[:,10:]))
Xm = tabmat.SplitMatrix([Xd, Xs])
Xm.sandwich(np.ones(X.shape[0]))
This throws an error:
Compare against this:
(No error)