Skip to content

Commit 38d7dec

Browse files
committed
update changelog and README
1 parent 0bfeec3 commit 38d7dec

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Release 0.8.3 is a minor release and contains several bugfixes mostly related to
1414
- Bugfix #459: Do not remove current timeout runner in AsyncTimeout to prevent accidental overrides (thanks @rgov)
1515
- Rewording of `State.enter/exit` debug message emitted when callbacks have been processed.
1616
- Bugfix #370: Fix order of `before_state_change/before` and `after/after_state_change` in `AsyncMachine` (thanks @tzoiker and @vishes-shell)
17+
- Bugfix #470: `Graph.get_graph()` did not consider `enum` states when `show_roi=True` (thank @termim)
1718

1819
## 0.8.2 (June 2020)
1920

README.md

+13-5
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,16 @@ machine.get_state(lump.state).name
347347
>>> 'solid'
348348
```
349349

350-
If you'd like you track it using a different attribute, you could do that using the `model_attribute` argument while initializing the `Machine`.
350+
If you'd like you can choose your own state attribute name by passing the `model_attribute` argument while initializing the `Machine`. This will also change the name of `is_«state name»()` to `is_«model_attribute»_«state name»()` though. This is done to allow multiple machines to work on the same model with individual state attribute names.
351351

352352
```python
353353
lump = Matter()
354354
machine = Machine(lump, states=['solid', 'liquid', 'gas'], model_attribute='matter_state', initial='solid')
355355
lump.matter_state
356356
>>> 'solid'
357+
# with a custom 'model_attribute', states can also be checked like this:
358+
lump.is_matter_state_solid()
359+
>>> True
357360
```
358361

359362
#### <a name="enum-state"></a>Enumerations
@@ -963,18 +966,23 @@ machine.add_model(Matter())
963966
machine.add_model(Matter(), initial='liquid')
964967
```
965968

966-
Models with multiple states could attach multiple machines using different `model_attribute` values:
969+
Models with multiple states could attach multiple machines using different `model_attribute` values. As mentioned in [Checking state](#checking-state), this will add custom `is_<model_attribute>_<state_name>` functions:
967970

968971
```python
969972
lump = Matter()
970973

974+
matter_machine = Machine(lump, states=['solid', 'liquid', 'gas'], initial='solid')
975+
# add a second machine to the same model but assign a different state attribute
976+
shipment_machine = Machine(lump, states=['delivered', 'shipping'], initial='delivered', model_attribute='shipping_state')
977+
971978
lump.state
972979
>>> 'solid'
980+
lump.is_solid() # check the default field
981+
>>> True
973982
lump.shipping_state
974983
>>> 'delivered'
975-
976-
matter_machine = Machine(lump, model_attribute='state', **kwargs)
977-
shipment_machine = Machine(lump, model_attribute='shipping_state', **kwargs)
984+
lump.is_shipping_state_delivered() # check the custom field.
985+
>>> True
978986
```
979987

980988
### Logging

0 commit comments

Comments
 (0)