Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 24b6d39

Browse filesBrowse files
committed
implement math.comb ourselves
1 parent dfc5ea0 commit 24b6d39
Copy full SHA for 24b6d39

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed

‎lib/matplotlib/bezier.py

Copy file name to clipboardExpand all lines: lib/matplotlib/bezier.py
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99

1010
import matplotlib.cbook as cbook
1111

12-
_comb = np.vectorize(math.comb)
12+
# same algorithm as 3.8's math.comb
13+
def _comb(n, k):
14+
k = min(k, n - k)
15+
i = np.arange(1, k + 1)
16+
return np.prod((n + 1 - i)/i).astype(int)
17+
_comb = np.vectorize(_comb)
1318

1419
class NonIntersectingPathException(ValueError):
1520
pass
@@ -277,6 +282,7 @@ def polynomial_coefficients(self):
277282
278283
"""
279284
n = self.degree
285+
# matplotlib uses n <= 4. overflow plausible starting around n = 15.
280286
if n > 10:
281287
warnings.warn("Polynomial coefficients formula unstable for high "
282288
"order Bezier curves!", RuntimeWarning)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.