Skip to content

Commit 222a1cc

Browse files
committed
release 0.6.5
also: reworked `_get_graph`
1 parent 4b38b9d commit 222a1cc

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ examples/state.png
1515
MANIFEST
1616
*.bak
1717
pylint.log
18+
test.py

Changelog.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changelog
22

3-
## 0.6.5 ()
3+
## 0.6.5 (April, 2018)
44

5-
- Feature #287: Embedding `HierarchicalMachine` will now reuse the machine's `initial` state. Passing `initial: False` overrides this(thanks @mrjogo).
5+
Release 0.6.5 is a minor release and contains a new feature and a bugfix:
6+
7+
- Feature #287: Embedding `HierarchicalMachine` will now reuse the machine's `initial` state. Passing `initial: False` overrides this (thanks @mrjogo).
68
- Bug #292: Models using `GraphMashine` were not picklable in the past due to `graph` property. Graphs for each model are now stored in `GraphMachine.model_graphs` (thanks @ansumanm)
79

810
## 0.6.4 (January, 2018)

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Coverage Status](https://coveralls.io/repos/pytransitions/transitions/badge.svg?branch=master&service=github)](https://coveralls.io/github/pytransitions/transitions?branch=master)
55
[![Pylint](https://img.shields.io/badge/pylint-9.71%2F10-green.svg)](https://github.com/pytransitions/transitions)
66
[![PyPi](https://img.shields.io/pypi/v/transitions.svg)](https://pypi.org/project/transitions)
7-
[![GitHub commits](https://img.shields.io/github/commits-since/pytransitions/transitions/0.6.4.svg)](https://github.com/pytransitions/transitions/compare/0.6.4...master)
7+
[![GitHub commits](https://img.shields.io/github/commits-since/pytransitions/transitions/0.6.5.svg)](https://github.com/pytransitions/transitions/compare/0.6.5...master)
88
[![License](https://img.shields.io/github/license/pytransitions/transitions.svg)](LICENSE)
99
<!--[![Name](Image)](Link)-->
1010

test.py

Whitespace-only changes.

transitions/extensions/diagrams.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ class GraphMachine(Machine):
307307
"""
308308

309309
_pickle_blacklist = ['model_graphs']
310+
graph_cls = Graph
310311
transition_cls = TransitionGraphSupport
311312

312313
# model_graphs cannot be pickled. Omit them.
@@ -359,14 +360,13 @@ def __init__(self, *args, **kwargs):
359360
setattr(self, 'get_graph', self.get_combined_graph)
360361

361362
def _get_graph(self, model, title=None, force_new=False, show_roi=False):
362-
if title is None:
363-
title = self.title
364-
if model not in self.model_graphs or force_new:
365-
self.model_graphs[model] = NestedGraph(self).get_graph(title) if isinstance(self, HierarchicalMachine) \
366-
else Graph(self).get_graph(title)
363+
if force_new:
364+
self.model_graphs[model] = self.graph_cls(self).get_graph(title if title is not None else self.title)
367365
self.set_node_state(self.model_graphs[model], model.state, state='active')
368-
369-
return self.model_graphs[model] if not show_roi else self._graph_roi(model)
366+
try:
367+
return self.model_graphs[model] if not show_roi else self._graph_roi(model)
368+
except KeyError:
369+
return self._get_graph(model, title, force_new=True, show_roi=show_roi)
370370

371371
def get_combined_graph(self, title=None, force_new=False, show_roi=False):
372372
""" This method is currently equivalent to 'get_graph' of the first machine's model.

transitions/extensions/factory.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from .nesting import HierarchicalMachine, NestedTransition, NestedEvent
1313
from .locking import LockedMachine, LockedEvent
14-
from .diagrams import GraphMachine, TransitionGraphSupport
14+
from .diagrams import GraphMachine, TransitionGraphSupport, NestedGraph
1515

1616

1717
class MachineFactory(object):
@@ -55,6 +55,7 @@ class HierarchicalGraphMachine(GraphMachine, HierarchicalMachine):
5555
"""
5656

5757
transition_cls = NestedGraphTransition
58+
graph_cls = NestedGraph
5859

5960

6061
class LockedHierarchicalMachine(LockedMachine, HierarchicalMachine):
@@ -79,6 +80,7 @@ class LockedHierarchicalGraphMachine(GraphMachine, LockedMachine, HierarchicalMa
7980

8081
transition_cls = NestedGraphTransition
8182
event_cls = LockedNestedEvent
83+
graph_cls = NestedGraph
8284

8385

8486
# 3d tuple (graph, nested, locked)

0 commit comments

Comments
 (0)