Skip to content

Commit 6e4b8c9

Browse files
committed
rename 'done_points' -> 'data' for the IntegratorLearner
1 parent 2b89d7b commit 6e4b8c9

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

adaptive/learner/integrator_learner.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class _Interval:
100100
The parent interval.
101101
children : list of `_Interval`s
102102
The intervals resulting from a split.
103-
done_points : dict
103+
data : dict
104104
A dictionary with the x-values and y-values: `{x1: y1, x2: y2 ...}`.
105105
done : bool
106106
The integral and the error for the interval has been calculated.
@@ -133,15 +133,15 @@ class _Interval:
133133
"ndiv",
134134
"parent",
135135
"children",
136-
"done_points",
136+
"data",
137137
"done_leaves",
138138
"depth_complete",
139139
"removed",
140140
]
141141

142142
def __init__(self, a, b, depth, rdepth):
143143
self.children = []
144-
self.done_points = {}
144+
self.data = {}
145145
self.a = a
146146
self.b = b
147147
self.depth = depth
@@ -172,9 +172,9 @@ def T(self):
172172

173173
def refinement_complete(self, depth):
174174
"""The interval has all the y-values to calculate the intergral."""
175-
if len(self.done_points) < ns[depth]:
175+
if len(self.data) < ns[depth]:
176176
return False
177-
return all(p in self.done_points for p in self.points(depth))
177+
return all(p in self.data for p in self.points(depth))
178178

179179
def points(self, depth=None):
180180
if depth is None:
@@ -255,7 +255,7 @@ def complete_process(self, depth):
255255
assert self.depth_complete is None or self.depth_complete == depth - 1
256256
self.depth_complete = depth
257257

258-
fx = [self.done_points[k] for k in self.points(depth)]
258+
fx = [self.data[k] for k in self.points(depth)]
259259
self.fx = np.array(fx)
260260
force_split = False # This may change when refining
261261

@@ -375,7 +375,7 @@ def __init__(self, function, bounds, tol):
375375
self.tol = tol
376376
self.max_ivals = 1000
377377
self.priority_split = []
378-
self.done_points = {}
378+
self.data = {}
379379
self.pending_points = set()
380380
self._stack = []
381381
self.x_mapping = defaultdict(lambda: SortedSet([], key=attrgetter("rdepth")))
@@ -391,13 +391,13 @@ def approximating_intervals(self):
391391
def tell(self, point, value):
392392
if point not in self.x_mapping:
393393
raise ValueError(f"Point {point} doesn't belong to any interval")
394-
self.done_points[point] = value
394+
self.data[point] = value
395395
self.pending_points.discard(point)
396396

397397
# Select the intervals that have this point
398398
ivals = self.x_mapping[point]
399399
for ival in ivals:
400-
ival.done_points[point] = value
400+
ival.data[point] = value
401401

402402
if ival.depth_complete is None:
403403
from_depth = 0 if ival.parent is not None else 2
@@ -438,8 +438,8 @@ def add_ival(self, ival):
438438
for x in ival.points():
439439
# Update the mappings
440440
self.x_mapping[x].add(ival)
441-
if x in self.done_points:
442-
self.tell(x, self.done_points[x])
441+
if x in self.data:
442+
self.tell(x, self.data[x])
443443
elif x not in self.pending_points:
444444
self.pending_points.add(x)
445445
self._stack.append(x)
@@ -518,7 +518,7 @@ def _fill_stack(self):
518518
@property
519519
def npoints(self):
520520
"""Number of evaluated points."""
521-
return len(self.done_points)
521+
return len(self.data)
522522

523523
@property
524524
def igral(self):
@@ -552,11 +552,9 @@ def loss(self, real=True):
552552
def plot(self):
553553
hv = ensure_holoviews()
554554
ivals = sorted(self.ivals, key=attrgetter("a"))
555-
if not self.done_points:
555+
if not self.data:
556556
return hv.Path([])
557-
xs, ys = zip(
558-
*[(x, y) for ival in ivals for x, y in sorted(ival.done_points.items())]
559-
)
557+
xs, ys = zip(*[(x, y) for ival in ivals for x, y in sorted(ival.data.items())])
560558
return hv.Path((xs, ys))
561559

562560
def _get_data(self):
@@ -565,7 +563,7 @@ def _get_data(self):
565563

566564
return (
567565
self.priority_split,
568-
self.done_points,
566+
self.data,
569567
self.pending_points,
570568
self._stack,
571569
x_mapping,
@@ -574,7 +572,7 @@ def _get_data(self):
574572
)
575573

576574
def _set_data(self, data):
577-
self.priority_split, self.done_points, self.pending_points, self._stack, x_mapping, self.ivals, self.first_ival = (
575+
self.priority_split, self.data, self.pending_points, self._stack, x_mapping, self.ivals, self.first_ival = (
578576
data
579577
)
580578

adaptive/tests/test_cquad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def test_tell_in_random_order(first_add_33=False):
188188
learners.append(learner)
189189

190190
# Check whether the points of the learners are identical
191-
assert set(learners[0].done_points) == set(learners[1].done_points)
191+
assert set(learners[0].data) == set(learners[1].data)
192192

193193
# Test whether approximating_intervals gives a complete set of intervals
194194
for learner in learners:

0 commit comments

Comments
 (0)