@@ -352,6 +352,7 @@ def test_matrix_processing(
352
352
processed_matrix = matrix_processing (
353
353
matrix = df ,
354
354
normalize = normalize ,
355
+ normalize_method = 'relative' ,
355
356
ignore_diagonals_normalize = ignore_diagonals_normalize ,
356
357
absolute = absolute ,
357
358
fill_diagonal = fill_diagonal ,
@@ -364,6 +365,7 @@ def test_matrix_processing(
364
365
processed_matrix = matrix_processing (
365
366
matrix = df ,
366
367
normalize = normalize ,
368
+ normalize_method = 'relative' ,
367
369
ignore_diagonals_normalize = ignore_diagonals_normalize ,
368
370
absolute = absolute ,
369
371
fill_diagonal = fill_diagonal ,
@@ -384,6 +386,7 @@ def test_matrix_processing(
384
386
processed_matrix = matrix_processing (
385
387
matrix = df ,
386
388
normalize = normalize ,
389
+ normalize_method = 'relative' ,
387
390
ignore_diagonals_normalize = ignore_diagonals_normalize ,
388
391
absolute = absolute ,
389
392
fill_diagonal = fill_diagonal ,
@@ -403,6 +406,7 @@ def test_matrix_processing(
403
406
processed_matrix = matrix_processing (
404
407
matrix = df ,
405
408
normalize = normalize ,
409
+ normalize_method = 'relative' ,
406
410
ignore_diagonals_normalize = ignore_diagonals_normalize ,
407
411
absolute = absolute ,
408
412
fill_diagonal = fill_diagonal ,
@@ -421,6 +425,7 @@ def test_matrix_processing(
421
425
processed_matrix = matrix_processing (
422
426
matrix = df ,
423
427
normalize = normalize ,
428
+ normalize_method = 'relative' ,
424
429
ignore_diagonals_normalize = ignore_diagonals_normalize ,
425
430
absolute = absolute ,
426
431
fill_diagonal = fill_diagonal ,
@@ -439,6 +444,7 @@ def test_matrix_processing(
439
444
processed_matrix = matrix_processing (
440
445
matrix = df ,
441
446
normalize = normalize ,
447
+ normalize_method = 'relative' ,
442
448
ignore_diagonals_normalize = ignore_diagonals_normalize ,
443
449
absolute = absolute ,
444
450
fill_diagonal = fill_diagonal ,
@@ -456,9 +462,8 @@ def test_matrix_processing(
456
462
@pytest .mark .parametrize (
457
463
'normalize_method' ,
458
464
(
459
- ('sum' ),
460
- ('absolute_sum' ),
461
- ('feature_count' ),
465
+ ('fractional' ),
466
+ ('fractional_absolute' ),
462
467
)
463
468
)
464
469
def test_matrix_processing_normalization_single_method (
@@ -471,7 +476,7 @@ def test_matrix_processing_normalization_single_method(
471
476
'c' : [0.5 , - 1.5 , 3.0 ],
472
477
}, index = ['a' , 'b' , 'c' ]).T
473
478
474
- if normalize_method == 'sum ' :
479
+ if normalize_method == 'fractional ' :
475
480
processed_matrix = round (
476
481
matrix_processing (
477
482
matrix = df ,
@@ -487,7 +492,7 @@ def test_matrix_processing_normalization_single_method(
487
492
488
493
assert_frame_equal (processed_matrix , correct_matrix )
489
494
490
- if normalize_method == 'absolute_sum ' :
495
+ if normalize_method == 'fractional_absolute ' :
491
496
processed_matrix = round (
492
497
matrix_processing (
493
498
matrix = df ,
@@ -503,59 +508,6 @@ def test_matrix_processing_normalization_single_method(
503
508
504
509
assert_frame_equal (processed_matrix , correct_matrix )
505
510
506
- if normalize_method == 'feature_count' :
507
- processed_matrix = round (
508
- matrix_processing (
509
- matrix = df ,
510
- normalize = True ,
511
- ignore_diagonals_normalize = False ,
512
- normalize_method = normalize_method
513
- ), 2 )
514
- correct_matrix = pd .DataFrame ({
515
- 'a' : [0.33 , - 1.00 , 2.00 ],
516
- 'b' : [0.17 , - 0.17 , 0.33 ],
517
- 'c' : [0.17 , - 0.50 , 1.00 ]
518
- }, index = ['a' , 'b' , 'c' ]).T
519
-
520
- assert_frame_equal (processed_matrix , correct_matrix )
521
-
522
-
523
- def test_matrix_processing_normalization_list (
524
- normalize_method = ['feature_count' , 'sum' ],
525
- ):
526
- """Tests that `matrix_processing` normalization parameters with lists works properly."""
527
- df = pd .DataFrame ({
528
- 'a' : [1.0 , - 3.0 , 6.0 ],
529
- 'b' : [0.5 , - 0.5 , 1.0 ],
530
- 'c' : [0.5 , - 1.5 , 3.0 ],
531
- }, index = ['a' , 'b' , 'c' ]).T
532
-
533
- processed_matrix = round (
534
- matrix_processing (
535
- matrix = df ,
536
- normalize = True ,
537
- ignore_diagonals_normalize = False ,
538
- normalize_method = normalize_method
539
- ), 2 )
540
-
541
- # When a list is the parameter, the methods inside are calculated sequentialy. It should be the
542
- # same as doing the two methods sequentially independently as well.
543
- correct_matrix = matrix_processing (
544
- matrix = df ,
545
- normalize = True ,
546
- ignore_diagonals_normalize = False ,
547
- normalize_method = normalize_method [0 ]
548
- )
549
- correct_matrix = round (
550
- matrix_processing (
551
- matrix = correct_matrix ,
552
- normalize = True ,
553
- ignore_diagonals_normalize = False ,
554
- normalize_method = normalize_method [1 ]
555
- ), 2 )
556
-
557
- assert_frame_equal (processed_matrix , correct_matrix )
558
-
559
511
560
512
def test_matrix_processing_normalization_callable ():
561
513
"""Tests that `matrix_processing` normalization parameters with Callable works properly."""
@@ -565,7 +517,7 @@ def test_matrix_processing_normalization_callable():
565
517
'c' : [0.5 , - 1.5 , 3.0 ],
566
518
}, index = ['a' , 'b' , 'c' ]).T
567
519
568
- # This is the exact same function as the 'absolute_sum ' normalization method,
520
+ # This is the exact same function as the 'fractional_absolute ' normalization method,
569
521
# thus it should return the same results.
570
522
def divide_by_sum_abs (row ):
571
523
sum_abs = row .abs ().sum ()
@@ -584,7 +536,7 @@ def divide_by_sum_abs(row):
584
536
matrix = df ,
585
537
normalize = True ,
586
538
ignore_diagonals_normalize = False ,
587
- normalize_method = 'absolute_sum '
539
+ normalize_method = 'fractional_absolute '
588
540
), 2 )
589
541
590
542
assert_frame_equal (processed_matrix , correct_matrix )
@@ -605,7 +557,7 @@ def test_matrix_processing_normalization_zero_division():
605
557
matrix = df ,
606
558
normalize = True ,
607
559
ignore_diagonals_normalize = False ,
608
- normalize_method = 'sum '
560
+ normalize_method = 'fractional '
609
561
), 2 )
610
562
611
563
# First row is returned unnormalized
0 commit comments