Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Jan 29, 2016
1 parent c145252 commit 18509a0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Sismic for Python
:target: https://travis-ci.org/AlexandreDecan/sismic
.. image:: https://coveralls.io/repos/AlexandreDecan/sismic/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/AlexandreDecan/sismic?branch=master
.. image:: https://api.codacy.com/project/badge/grade/10d0a71b01c144859db571ddf17bb7d4
:target: https://www.codacy.com/app/alexandre-decan/sismic
.. image:: https://badge.fury.io/py/sismic.svg
:target: https://pypi.python.org/pypi/sismic
.. image:: https://readthedocs.org/projects/sismic/badge/?version=stable
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Sismic user manual
:target: https://travis-ci.org/AlexandreDecan/sismic
.. image:: https://coveralls.io/repos/AlexandreDecan/sismic/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/AlexandreDecan/sismic?branch=master
.. image:: https://api.codacy.com/project/badge/grade/10d0a71b01c144859db571ddf17bb7d4
:target: https://www.codacy.com/app/alexandre-decan/sismic
.. image:: https://badge.fury.io/py/sismic.svg
:target: https://pypi.python.org/pypi/sismic
.. image:: https://readthedocs.org/projects/sismic/badge/?version=stable
Expand Down
10 changes: 6 additions & 4 deletions sismic/model/statechart.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,20 @@ def leaf_for(self, names: list) -> list:
:return: the names of the leaves in *states*
:raise StatechartError: if state does not exist
"""
[self.state_for(s) for s in names] # Raise StatechartError if state does not exist
# Check that states exist
for name in names:
self.state_for(name) # Raise a StatechartError if it does not exist!

leaves = []
# TODO: Need a more efficient way to compute this set
for state in names:
for name in names:
keep = True
for descendant in self.descendants_for(state):
for descendant in self.descendants_for(name):
if descendant in names:
keep = False
break
if keep:
leaves.append(state)
leaves.append(name)
return leaves

# ######### TRANSITIONS ##########
Expand Down
1 change: 1 addition & 0 deletions tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class SimulatorHistoryTests(unittest.TestCase):
def test_init(self):
sc = io.import_from_yaml(open('tests/yaml/history.yaml'))
Interpreter(sc, DummyEvaluator)
self.assertTrue(True)

def test_memory(self):
sc = io.import_from_yaml(open('tests/yaml/history.yaml'))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_export(self):
for f, filename in self.files:
with self.subTest(filename=filename):
sc_1 = io.import_from_yaml(f)
ex_1 = io.export_to_yaml(sc_1)
io.export_to_yaml(sc_1)

def test_export_valid(self):
for f, filename in self.files:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_transitions_to_unknown_state(self):
transitions:
- target: s2
"""
with self.assertRaises(exceptions.StatechartError) as cm:
with self.assertRaises(exceptions.StatechartError):
io.import_from_yaml(yaml)

def test_history_not_in_compound(self):
Expand All @@ -103,7 +103,7 @@ def test_history_not_in_compound(self):
- name: s2
type: shallow history
"""
with self.assertRaises(exceptions.StatechartError) as cm:
with self.assertRaises(exceptions.StatechartError):
io.import_from_yaml(yaml)


Expand Down Expand Up @@ -194,7 +194,7 @@ def setUp(self):
self.sc = io.import_from_yaml(open('tests/yaml/internal.yaml'))

def test_rotate_source(self):
tr = list(filter(lambda t: t.source == 's1', self.sc.transitions))[0]
tr = next(t for t in self.sc.transitions if t.source == 's1')
self.sc.rotate_transition(tr, new_source='s1')
self.assertEqual(tr.source, 's1')

Expand Down

0 comments on commit 18509a0

Please sign in to comment.