Skip to content

Commit 087a00f

Browse files
committed
fix typeguard errors
1 parent b072a6d commit 087a00f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

adaptive/learner/average_learner1D.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
from collections import defaultdict
44
from copy import deepcopy
55
from math import hypot
6-
from typing import Callable, DefaultDict, Dict, List, Optional, Sequence, Set, Tuple
6+
from typing import (
7+
Callable,
8+
DefaultDict,
9+
Dict,
10+
Iterable,
11+
List,
12+
Optional,
13+
Sequence,
14+
Set,
15+
Tuple,
16+
)
717

818
import numpy as np
919
import scipy.stats
@@ -356,7 +366,7 @@ def _update_losses_resampling(self, x: Real, real=True) -> None:
356366
if (b is not None) and right_loss_is_unknown:
357367
self.losses_combined[x, b] = float("inf")
358368

359-
def _calc_error_in_mean(self, ys: Sequence[Real], y_avg: Real, n: int) -> float:
369+
def _calc_error_in_mean(self, ys: Iterable[Real], y_avg: Real, n: int) -> float:
360370
variance_in_mean = sum((y - y_avg) ** 2 for y in ys) / (n - 1)
361371
t_student = scipy.stats.t.ppf(1 - self.alpha, df=n - 1)
362372
return t_student * (variance_in_mean / n) ** 0.5

adaptive/learner/base_learner.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
from adaptive.utils import _RequireAttrsABCMeta, load, save
66

77

8-
def uses_nth_neighbors(n):
8+
def uses_nth_neighbors(n: int):
99
"""Decorator to specify how many neighboring intervals the loss function uses.
1010
1111
Wraps loss functions to indicate that they expect intervals together
1212
with ``n`` nearest neighbors
1313
1414
The loss function will then receive the data of the N nearest neighbors
15-
(``nth_neighbors``) aling with the data of the interval itself in a dict.
15+
(``nth_neighbors``) along with the data of the interval itself in a dict.
1616
The `~adaptive.Learner1D` will also make sure that the loss is updated
1717
whenever one of the ``nth_neighbors`` changes.
1818

adaptive/learner/learner1D.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ def _set_data(self, data: Dict[float, float]) -> None:
740740
def __getstate__(self):
741741
return (
742742
cloudpickle.dumps(self.function),
743-
self.bounds,
743+
tuple(self.bounds),
744744
self.loss_per_interval,
745745
dict(self.losses), # SortedDict cannot be pickled
746746
dict(self.losses_combined), # ItemSortedDict cannot be pickled

0 commit comments

Comments
 (0)