This was fixed by https://github.com/python-adaptive/adaptive/pull/268
Bas Nijholt authored on 24/04/2020 18:59:081 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,26 @@ |
1 |
+import asyncio |
|
2 |
+ |
|
3 |
+from adaptive import Runner, SequenceLearner |
|
4 |
+from adaptive.runner import SequentialExecutor |
|
5 |
+ |
|
6 |
+ |
|
7 |
+class FailOnce: |
|
8 |
+ def __init__(self): |
|
9 |
+ self.failed = False |
|
10 |
+ |
|
11 |
+ def __call__(self, value): |
|
12 |
+ if self.failed: |
|
13 |
+ return value |
|
14 |
+ self.failed = True |
|
15 |
+ raise RuntimeError |
|
16 |
+ |
|
17 |
+ |
|
18 |
+def test_fail_with_sequence_of_unhashable(): |
|
19 |
+ # https://github.com/python-adaptive/adaptive/issues/265 |
|
20 |
+ seq = [{1: 1}] # unhashable |
|
21 |
+ learner = SequenceLearner(FailOnce(), sequence=seq) |
|
22 |
+ runner = Runner( |
|
23 |
+ learner, goal=SequenceLearner.done, retries=1, executor=SequentialExecutor() |
|
24 |
+ ) |
|
25 |
+ asyncio.get_event_loop().run_until_complete(runner.task) |
|
26 |
+ assert runner.status() == "finished" |