Skip to content

Commit 454a186

Browse files
committed
check ifinstance(x, Iterable) instead of having __iter__
and order imports according to PEP8
1 parent 7a37803 commit 454a186

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

adaptive/learner/skopt_learner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
22

3+
import collections
4+
35
import numpy as np
46
from skopt import Optimizer
5-
from collections import OrderedDict
67

78
from adaptive.learner.base_learner import BaseLearner
89
from adaptive.notebook_integration import ensure_holoviews
@@ -27,11 +28,11 @@ class SKOptLearner(Optimizer, BaseLearner):
2728
def __init__(self, function, **kwargs):
2829
self.function = function
2930
self.pending_points = set()
30-
self.data = OrderedDict()
31+
self.data = collections.OrderedDict()
3132
super().__init__(**kwargs)
3233

3334
def tell(self, x, y, fit=True):
34-
if hasattr(x, "__iter__"):
35+
if isinstance(x, collections.abc.Iterable):
3536
self.pending_points.discard(tuple(x))
3637
self.data[tuple(x)] = y
3738
super().tell(x, y, fit)

0 commit comments

Comments
 (0)