Skip to content

Commit 2efbfb6

Browse files
committed
fix: Python 3.10+ compatibility (collections.abc, math.factorial)
1 parent ff8845a commit 2efbfb6

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

adaptive/learner/learnerND.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
from collections import OrderedDict, Iterable
2+
from collections import OrderedDict
3+
from collections.abc import Iterable
34
import heapq
45
import itertools
56
import random
@@ -24,7 +25,7 @@ def volume(simplex, ys=None):
2425
dim = len(simplex) - 1
2526

2627
# See https://www.jstor.org/stable/2315353
27-
vol = np.abs(np.linalg.det(matrix)) / np.math.factorial(dim)
28+
vol = np.abs(np.linalg.det(matrix)) / math.factorial(dim)
2829
return vol
2930

3031

adaptive/learner/triangulation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from collections import Counter, Sized, Iterable
1+
from collections import Counter
2+
from collections.abc import Sized, Iterable
23
from itertools import combinations, chain
34

45
import numpy as np
@@ -575,7 +576,7 @@ def add_point(self, point, simplex=None, transform=None):
575576
return self.bowyer_watson(pt_index, actual_simplex, transform)
576577

577578
def volume(self, simplex):
578-
prefactor = np.math.factorial(self.dim)
579+
prefactor = factorial(self.dim)
579580
vertices = np.array(self.get_vertices(simplex))
580581
vectors = vertices[1:] - vertices[0]
581582
return float(abs(np.linalg.det(vectors)) / prefactor)

0 commit comments

Comments
 (0)