1
1
import abc
2
2
from contextlib import suppress
3
3
from copy import deepcopy
4
+ from typing import Any , Callable , Dict
4
5
5
6
from adaptive .utils import _RequireAttrsABCMeta , load , save
6
7
7
8
8
- def uses_nth_neighbors (n ) :
9
+ def uses_nth_neighbors (n : int ) -> Callable :
9
10
"""Decorator to specify how many neighboring intervals the loss function uses.
10
11
11
12
Wraps loss functions to indicate that they expect intervals together
@@ -84,7 +85,7 @@ class BaseLearner(metaclass=_RequireAttrsABCMeta):
84
85
npoints : int
85
86
pending_points : set
86
87
87
- def tell (self , x , y ):
88
+ def tell (self , x : Any , y ) -> None :
88
89
"""Tell the learner about a single value.
89
90
90
91
Parameters
@@ -94,7 +95,7 @@ def tell(self, x, y):
94
95
"""
95
96
self .tell_many ([x ], [y ])
96
97
97
- def tell_many (self , xs , ys ) :
98
+ def tell_many (self , xs : Any , ys : Any ) -> None :
98
99
"""Tell the learner about some values.
99
100
100
101
Parameters
@@ -161,7 +162,7 @@ def copy_from(self, other):
161
162
"""
162
163
self ._set_data (other ._get_data ())
163
164
164
- def save (self , fname , compress = True ):
165
+ def save (self , fname : str , compress : bool = True ) -> None :
165
166
"""Save the data of the learner into a pickle file.
166
167
167
168
Parameters
@@ -175,7 +176,7 @@ def save(self, fname, compress=True):
175
176
data = self ._get_data ()
176
177
save (fname , data , compress )
177
178
178
- def load (self , fname , compress = True ):
179
+ def load (self , fname : str , compress : bool = True ) -> None :
179
180
"""Load the data of a learner from a pickle file.
180
181
181
182
Parameters
@@ -190,8 +191,8 @@ def load(self, fname, compress=True):
190
191
data = load (fname , compress )
191
192
self ._set_data (data )
192
193
193
- def __getstate__ (self ):
194
+ def __getstate__ (self ) -> Dict [ str , Any ] :
194
195
return deepcopy (self .__dict__ )
195
196
196
- def __setstate__ (self , state ) :
197
+ def __setstate__ (self , state : Dict [ str , Any ]) -> None :
197
198
self .__dict__ = state
0 commit comments