66from pySubnetSB .assignment_pair import AssignmentPair # type: ignore
77
88import os
9- from pynauty import Graph # type: ignore
9+ # from pynauty import Graph # type: ignore
1010import matplotlib .pyplot as plt
1111import numpy as np
1212import copy
1313import tellurium as te # type: ignore
1414import unittest
15+ from typing import cast
1516
1617
1718IGNORE_TEST = False
8485class TestNetwork (unittest .TestCase ):
8586
8687 def setUp (self ):
87- self .network = copy .deepcopy (NETWORK )
88+ self .network = cast ( NetworkBase , copy .deepcopy (NETWORK ) )
8889
8990 @util .timeit
9091 def testConstrutor (self ):
@@ -107,7 +108,7 @@ def testCopyEqual(self):
107108 def testIsMatrixEqual (self ):
108109 if IGNORE_TEST :
109110 return
110- network = NetworkBase .makeFromAntimonyStr (NETWORK1 , network_name = NETWORK_NAME )
111+ network = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK1 , network_name = NETWORK_NAME ) )
111112 network3 = NetworkBase .makeFromAntimonyStr (NETWORK3 , network_name = NETWORK_NAME )
112113 self .assertTrue (network .isMatrixEqual (network3 , identity = cn .ID_WEAK ))
113114 self .assertFalse (network .isMatrixEqual (network3 , identity = cn .ID_STRONG ))
@@ -121,7 +122,7 @@ def testRandomlyPermuteTrue(self):
121122 def test (size , num_iteration = 500 ):
122123 reactant_arr = np .random .randint (0 , 3 , (size , size ))
123124 product_arr = np .random .randint (0 , 3 , (size , size ))
124- network = NetworkBase (reactant_arr , product_arr )
125+ network = NetworkBase (reactant_arr , product_arr ) # type: ignore
125126 for _ in range (num_iteration ):
126127 new_network , assignment_pair = network .permute ()
127128 if network == new_network :
@@ -157,10 +158,10 @@ def test(size, num_iteration=500):
157158 def testIsStructurallyCompatible (self ):
158159 if IGNORE_TEST :
159160 return
160- network1 = NetworkBase .makeFromAntimonyStr (NETWORK1 , network_name = NETWORK_NAME )
161- network2 = NetworkBase .makeFromAntimonyStr (NETWORK2 , network_name = NETWORK_NAME )
162- network3 = NetworkBase .makeFromAntimonyStr (NETWORK3 , network_name = NETWORK_NAME )
163- network4 = NetworkBase .makeFromAntimonyStr (NETWORK4 , network_name = NETWORK_NAME )
161+ network1 = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK1 , network_name = NETWORK_NAME ) )
162+ network2 = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK2 , network_name = NETWORK_NAME ) )
163+ network3 = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK3 , network_name = NETWORK_NAME ) )
164+ network4 = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK4 , network_name = NETWORK_NAME ) )
164165 self .assertFalse (network1 .isStructurallyCompatible (network4 ))
165166 self .assertTrue (network1 .isStructurallyCompatible (network2 ))
166167 self .assertTrue (network1 .isStructurallyCompatible (network3 , identity = cn .ID_WEAK ))
@@ -169,7 +170,7 @@ def testIsStructurallyCompatible(self):
169170 def testPrettyPrintReaction (self ):
170171 if IGNORE_TEST :
171172 return
172- network = NetworkBase .makeFromAntimonyStr (NETWORK3 , network_name = "Network3" )
173+ network = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (NETWORK3 , network_name = "Network3" ) )
173174 stg = network .prettyPrintReaction (0 )
174175 self .assertTrue ("2.0 S1 -> 2.0 S1 + S2" in stg )
175176
@@ -193,8 +194,8 @@ def testMakeRandomNetworkFromReactionType2(self):
193194 size = 3
194195 species_names = ["S1" , "S5" , "S10" ]
195196 reaction_names = ['JJ1' , 'JJ2' , 'JJ3' ]
196- network = NetworkBase .makeRandomNetworkByReactionType (size , species_names = species_names ,
197- reaction_names = reaction_names , is_exact = True )
197+ network = NetworkBase .makeRandomNetworkByReactionType (size , species_names = species_names , # type: ignore
198+ reaction_names = reaction_names , is_exact = True ) # type: ignore
198199 self .assertEqual (len (species_names ), network .num_species )
199200 for species_name in species_names :
200201 self .assertTrue (species_name in network .species_names )
@@ -283,6 +284,7 @@ def testFill(self):
283284 self .assertLessEqual (filled_network .num_species , network .num_species + fill_size )
284285 self .assertEqual (filled_network .num_reaction , network .num_reaction + fill_size )
285286 #
287+ network = NetworkBase .makeRandomNetworkByReactionType (5 , 5 )
286288 with self .assertRaises (ValueError ):
287289 network .fill (num_fill_reaction = 0 , num_fill_species = 0 )
288290
@@ -297,7 +299,7 @@ def testIsBoundaryNetwork(self):
297299 k1 = 0.1; k2 = 0.2
298300 A = 0; B = 0
299301 """
300- network = NetworkBase .makeFromAntimonyStr (boundary_network )
302+ network = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (boundary_network ) )
301303 self .assertTrue (network .isBoundaryNetwork ())
302304 #
303305 boundary_network = """
@@ -307,21 +309,21 @@ def testIsBoundaryNetwork(self):
307309 k1 = 0.1; k2 = 0.2
308310 A = 0; B = 0
309311 """
310- network = NetworkBase .makeFromAntimonyStr (boundary_network )
312+ network = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (boundary_network ) )
311313 self .assertFalse (network .isBoundaryNetwork ())
312314
313315 def testMakeFromAntimonyStrRoadrunner (self ):
314316 if IGNORE_TEST :
315317 return
316318 roadrunner = te .loada (BIG_NETWORK )
317- network = NetworkBase .makeFromAntimonyStr (None , roadrunner = roadrunner )
319+ network = cast ( NetworkBase , NetworkBase .makeFromAntimonyStr (None , roadrunner = roadrunner )) # type: ignore
318320 self .assertGreater (network .num_species , 0 )
319321
320322 def testMakeFromSBMLFile (self ):
321323 if IGNORE_TEST :
322324 return
323325 PATH = os .path .join (cn .TEST_DIR , "xml_files/BIOMD0000000033.xml" )
324- network = NetworkBase .makeFromSBMLFile (PATH )
326+ network = cast ( NetworkBase , NetworkBase .makeFromSBMLFile (PATH ) )
325327 self .assertGreater (network .num_species , 0 )
326328
327329 def testMakeInducedNetwork (self ):
0 commit comments