@@ -361,13 +361,13 @@ def test_category_product_not_cat(random_gen):
361
361
362
362
def test_category_interaction ():
363
363
c = pd .Series (pd .Categorical ([0 , 0 , 0 , 1 , 1 , 1 ]))
364
- actual = category_interaction (c , precondition = False ).A
364
+ actual = category_interaction (c , precondition = False ).toarray ()
365
365
expected = np .zeros ((6 , 2 ))
366
366
expected [:3 , 0 ] = 1.0
367
367
expected [3 :, 1 ] = 1.0
368
368
assert_allclose (actual , expected )
369
369
370
- actual = category_interaction (c , precondition = True ).A
370
+ actual = category_interaction (c , precondition = True ).toarray ()
371
371
cond = np .sqrt ((expected ** 2 ).sum (0 ))
372
372
expected /= cond
373
373
assert_allclose (actual , expected )
@@ -381,12 +381,12 @@ def test_category_continuous_interaction():
381
381
expected [:3 , 0 ] = v [:3 ]
382
382
expected [3 :, 1 ] = v [3 :]
383
383
384
- assert_allclose (actual .A , expected )
384
+ assert_allclose (actual .toarray () , expected )
385
385
386
386
actual = category_continuous_interaction (c , v , precondition = True )
387
387
cond = np .sqrt ((expected ** 2 ).sum (0 ))
388
388
expected /= cond
389
- assert_allclose (actual .A , expected )
389
+ assert_allclose (actual .toarray () , expected )
390
390
391
391
392
392
def test_category_continuous_interaction_interwoven ():
@@ -396,7 +396,7 @@ def test_category_continuous_interaction_interwoven():
396
396
expected = np .zeros ((6 , 2 ))
397
397
expected [::2 , 0 ] = v [::2 ]
398
398
expected [1 ::2 , 1 ] = v [1 ::2 ]
399
- assert_allclose (actual .A , expected )
399
+ assert_allclose (actual .toarray () , expected )
400
400
401
401
402
402
def test_interaction_cat_only (cat ):
@@ -406,7 +406,7 @@ def test_interaction_cat_only(cat):
406
406
expected = category_interaction (category_product (cat ), precondition = False )
407
407
actual = interact .sparse
408
408
assert isinstance (actual , csc_matrix )
409
- assert_allclose (expected .A , actual .A )
409
+ assert_allclose (expected .toarray () , actual .toarray () )
410
410
411
411
412
412
def test_interaction_cont_only (cont ):
@@ -416,15 +416,15 @@ def test_interaction_cont_only(cont):
416
416
expected = cont .to_numpy ()
417
417
actual = interact .sparse
418
418
assert isinstance (actual , csc_matrix )
419
- assert_allclose (expected , actual .A )
419
+ assert_allclose (expected , actual .toarray () )
420
420
421
421
422
422
def test_interaction_cat_cont (cat , cont ):
423
423
interact = Interaction (cat = cat , cont = cont )
424
424
assert interact .nobs == cat .shape [0 ]
425
425
assert_frame_equal (cat , interact .cat )
426
426
assert_frame_equal (cont , interact .cont )
427
- base = category_interaction (category_product (cat ), precondition = False ).A
427
+ base = category_interaction (category_product (cat ), precondition = False ).toarray ()
428
428
expected = []
429
429
for i in range (cont .shape [1 ]):
430
430
element = base .copy ()
@@ -433,13 +433,13 @@ def test_interaction_cat_cont(cat, cont):
433
433
expected = np .column_stack (expected )
434
434
actual = interact .sparse
435
435
assert isinstance (actual , csc_matrix )
436
- assert_allclose (expected , interact .sparse .A )
436
+ assert_allclose (expected , interact .sparse .toarray () )
437
437
438
438
439
439
def test_interaction_from_frame (cat , cont ):
440
440
base = Interaction (cat = cat , cont = cont )
441
441
interact = Interaction .from_frame (pd .concat ([cat , cont ], axis = 1 ))
442
- assert_allclose (base .sparse .A , interact .sparse .A )
442
+ assert_allclose (base .sparse .toarray () , interact .sparse .toarray () )
443
443
444
444
445
445
def test_interaction_cat_bad_nobs ():
@@ -458,7 +458,7 @@ def test_empty_interaction():
458
458
def test_interaction_cat_cont_convert (cat , cont ):
459
459
base = Interaction (cat , cont )
460
460
interact = Interaction (cat .to_numpy (), cont )
461
- assert_allclose (base .sparse .A , interact .sparse .A )
461
+ assert_allclose (base .sparse .toarray () , interact .sparse .toarray () )
462
462
463
463
464
464
def test_absorbing_regressors (cat , cont , interact , weights ):
@@ -486,7 +486,7 @@ def test_absorbing_regressors(cat, cont, interact, weights):
486
486
assert expected .shape == actual .shape
487
487
assert_array_equal (expected .indptr , actual .indptr )
488
488
assert_array_equal (expected .indices , actual .indices )
489
- assert_allclose (expected .A , actual .A )
489
+ assert_allclose (expected .toarray () , actual .toarray () )
490
490
assert expected_rank == rank
491
491
492
492
@@ -532,11 +532,11 @@ def test_against_ols(ols_data):
532
532
if ols_data .absorb .cat .shape [1 ] > 0 :
533
533
dummies = dummy_matrix (ols_data .absorb .cat , precondition = False )[0 ]
534
534
assert isinstance (dummies , sp .csc_matrix )
535
- absorb .append (dummies .A )
535
+ absorb .append (dummies .toarray () )
536
536
has_dummy = ols_data .absorb .cat .shape [1 ] > 0
537
537
if ols_data .interactions is not None :
538
538
for interact in ols_data .interactions :
539
- absorb .append (interact .sparse .A )
539
+ absorb .append (interact .sparse .toarray () )
540
540
_x = ols_data .x
541
541
if absorb :
542
542
absorb = np .column_stack (absorb )
0 commit comments