Skip to content

Commit

Permalink
Added typechecking for add_submodule() and add_component()
Browse files Browse the repository at this point in the history
  • Loading branch information
ktnyt committed Jul 29, 2015
1 parent 9e5a943 commit fcd7790
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/brica1/module.py
Expand Up @@ -16,6 +16,7 @@
import numpy

# BriCA imports
from component import *
from unit import *

class Module(Unit):
Expand Down Expand Up @@ -52,6 +53,10 @@ def add_submodule(self, id, submodule):
"""

if not isinstance(submodule, Module):
raise AssertionError("Not a Module instance")
return

if id in self.components:
raise LookupError("There is already a component of the same name")
return
Expand Down Expand Up @@ -121,6 +126,10 @@ def add_component(self, id, component):
"""

if not isinstance(component, Component):
raise AssertionError("Not a Component instance")
return

if id in self.submodules:
raise LookupError("There is already a submodule of the same name")
return
Expand Down

0 comments on commit fcd7790

Please sign in to comment.