From 4c51624ae1e69a2084c012d227cb52289154f8bb Mon Sep 17 00:00:00 2001 From: Christoph Groth Date: Fri, 12 Jan 2018 12:21:02 +0100 Subject: use insort instead of sort --- vquad/core.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'vquad') diff --git a/vquad/core.py b/vquad/core.py index 7f586f9..23f1c24 100644 --- a/vquad/core.py +++ b/vquad/core.py @@ -3,6 +3,8 @@ # This file is part of Vquad. It is subject to the license terms in the file # LICENSE.rst found in the top-level directory of this distribution. +from bisect import insort + import numpy as np from scipy.linalg import norm @@ -193,8 +195,12 @@ class Vquad: return if split: - self.ivals.extend(self.split(self.ivals.pop())) - self.ivals.sort() + # Replace current interval by its children. + for new in self.split(self.ivals.pop()): + insort(self.ivals, new) + else: + # The error estimate of the current interval has changed. + insort(self.ivals, self.ivals.pop()) def totals(self): igral = self.igral_excess -- cgit v1.2.3-74-g4815