10
10
from numpy .testing import assert_equal , assert_almost_equal
11
11
import pandas as pd
12
12
import pytest
13
+ import scipy
13
14
from skimage .draw import line
14
15
15
16
from skan import csr
@@ -523,7 +524,7 @@ def test_nx_to_skeleton(
523
524
524
525
525
526
@pytest .mark .parametrize (
526
- 'wrong_skeleton' ,
527
+ ( 'wrong_skeleton' ) ,
527
528
[
528
529
pytest .param (skeleton0 , id = 'Numpy Array.' ),
529
530
pytest .param (csr .Skeleton (skeleton0 ), id = 'Skeleton.' ),
@@ -538,3 +539,36 @@ def test_nx_to_skeleton_attribute_error(wrong_skeleton: Any) -> None:
538
539
"""Test various errors are raised by nx_to_skeleton()."""
539
540
with pytest .raises (Exception ):
540
541
csr .nx_to_skeleton (wrong_skeleton )
542
+
543
+
544
+ @pytest .mark .parametrize (
545
+ ('skeleton' ),
546
+ [
547
+ pytest .param (skeleton0 , id = 'Numpy Array' ),
548
+ pytest .param (csr .Skeleton (skeleton0 ), id = 'Skeleton' ),
549
+ pytest .param (nx_graph , id = 'NetworkX Graph without edges.' ),
550
+ ],
551
+ )
552
+ def test_csr_to_nbgraph_attribute_error (skeleton : Any ) -> None :
553
+ """Raise AttributeError if csr_to_nbgraph() passed incomplete objects."""
554
+ with pytest .raises (AttributeError ):
555
+ csr .csr_to_nbgraph (skeleton )
556
+
557
+
558
+ @pytest .mark .parametrize (
559
+ ('graph' ),
560
+ [
561
+ pytest .param (
562
+ scipy .sparse .csr_matrix (skeleton0 ),
563
+ id = 'Sparse matrix directly from Numpy Array' ,
564
+ ),
565
+ pytest .param (
566
+ scipy .sparse .csr_matrix (csr .Skeleton (skeleton0 )),
567
+ id = 'Sparse matrix from csr.Skeleton' ,
568
+ ),
569
+ ],
570
+ )
571
+ def test_csr_to_nbgraph_type_error (graph : scipy .sparse .csr_matrix ) -> None :
572
+ """Test TypeError is raised by csr_to_nbgraph() if wrong type is passed."""
573
+ with pytest .raises (TypeError ):
574
+ csr .csr_to_nbgraph (graph )
0 commit comments