Skip to content

Commit

Permalink
Added .type() method to Node class. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-hen committed Apr 6, 2021
1 parent 4442161 commit 5792aa4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ def tag(self):
"""Returns the node's tag."""
return str(self.java.tag()) if self.exists() else None

def type(self):
"""Returns the node's feature type."""
return str(self.java.getType())

def parent(self):
"""Returns the parent node."""
if self.is_root():
Expand Down
6 changes: 6 additions & 0 deletions tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ def test_tag():
assert Node(model, 'functions/step').tag() == 'step1'


def test_type():
assert Node(model, 'functions/step').type() == 'Step'
assert Node(model, 'functions/image').type() == 'Image'
assert Node(model, 'functions/table').type() == 'Interpolation'


def test_parent():
assert Node(model, 'functions/step').parent() == Node(model, 'functions')

Expand Down

0 comments on commit 5792aa4

Please sign in to comment.