Skip to content

Commit

Permalink
remove _deepcopy_fix and depend on sortedcollections >= 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Jan 25, 2019
1 parent 0bfdd20 commit b29f547
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions adaptive/learner/learner1D.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,24 +657,11 @@ def _set_data(self, data):
self.tell_many(*zip(*data.items()))


def _fix_deepcopy(sorted_dict, x_scale):
# XXX: until https://github.com/grantjenks/sortedcollections/issues/5 is fixed
import types
def __deepcopy__(self, memo):
items = deepcopy(list(self.items()))
lm = loss_manager(self.x_scale)
lm.update(items)
return lm
sorted_dict.x_scale = x_scale
sorted_dict.__deepcopy__ = types.MethodType(__deepcopy__, sorted_dict)


def loss_manager(x_scale):
def sort_key(ival, loss):
loss, ival = finite_loss(ival, loss, x_scale)
return -loss, ival
sorted_dict = sortedcollections.ItemSortedDict(sort_key)
_fix_deepcopy(sorted_dict, x_scale)
return sorted_dict


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_version_and_cmdclass(package_name):

install_requires = [
'scipy',
'sortedcollections',
'sortedcollections >= 1.1',
'sortedcontainers >= 2.0',
]

Expand Down

0 comments on commit b29f547

Please sign in to comment.