Reputation: 2411
A TypeError: MyNetwork.__init__() missing 1 required positional argument: 'some_parameter'
is thrown on the last line of the following code snippet:
class MyNetwork(nx.DiGraph):
def __init__(self, some_parameter: str, **attr):
super().__init__(**attr)
self.some_parameter = some_parameter
network = MyNetwork("some_parameter")
network.add_nodes_from([1,2,3])
network.add_edges_from([(1, 2), (2, 3), (3, 1)])
sub_network = network.subgraph([2,3])
How can this be fixed? The issue seems to be that the subgraph()
method which MyNetwork
inherited from nx.DiGraph
wants to create a new instance of MyNetwork
where the constructor (in this example) requires a single parameter.
Upvotes: 0
Views: 23