Skip to content

Instantly share code, notes, and snippets.

@asmeurer
asmeurer / gist:1008685
Created June 5, 2011 05:31
32-bit Python risch_integrate(logarithms)
In [1]: for i in range(100):
...: print risch_integrate(Add(*(log(x**j) for j in range(i))), x)
...:
0
0
-x + x*log(x)
-3*x + 3*x*log(x**2)/2
-6*x + 3*x*log(x**2)
-10*x + 5*x*log(x**4)/2
-15*x + 15*x*log(x**4)/4
@asmeurer
asmeurer / Arrow+a.png
Created June 6, 2011 22:20
Arrow \u27FC
Arrow+a.png
@asmeurer
asmeurer / gist:1021243
Created June 12, 2011 04:08
Sage test failure
File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/test_external/test_sage.py", line 66, in test_complex
check_expression("I*y", "y")
File "/users/aaronmeurer/documents/python/sympy/sympy/sympy/test_external/test_sage.py", line 52, in check_expression
assert sympy.S(e_sage) == e_sympy
File "/Users/aaronmeurer/Documents/python/sympy/sympy/sympy/core/sympify.py", line 97, in sympify
return a._sympy_()
File "expression.pyx", line 990, in sage.symbolic.expression.Expression._sympy_ (sage/symbolic/expression.cpp:5752)
File "/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.py", line 214, in __call__
return self.arithmetic(ex, operator)
File "/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/expression_conversions.py", line 600, in arithmetic
@asmeurer
asmeurer / gist:1027747
Created June 15, 2011 18:28
ask key problem
diff --git a/sympy/assumptions/tests/test_query.py b/sympy/assumptions/tests/test_query.py
index 516d0d7..ccb09fe 100644
--- a/sympy/assumptions/tests/test_query.py
+++ b/sympy/assumptions/tests/test_query.py
@@ -982,6 +982,7 @@ def Symbol(expr, assumptions):
assert ask(Q.my_key(x)) == True
assert ask(Q.my_key(x+1)) == None
remove_handler('my_key', MyAskHandler)
+ raises(AttributeError, "ask(Q.my_key(x))")
@asmeurer
asmeurer / gist:1028696
Created June 16, 2011 05:00
float(oo) windows fix
diff --git a/sympy/core/evalf.py b/sympy/core/evalf.py
index 05e6de9..ce276e9 100644
--- a/sympy/core/evalf.py
+++ b/sympy/core/evalf.py
@@ -28,8 +28,8 @@
# Used in a few places as placeholder values to denote exponents and
# precision levels, e.g. of exact numbers. Must be careful to avoid
# passing these to mpmath functions or returning them in final results.
-INF = 1e1000
-MINUS_INF = -1e1000
@asmeurer
asmeurer / gist:1028738
Created June 16, 2011 05:45
skip codegen tests in Python 2.4 windows
diff --git a/sympy/test_external/test_codegen.py b/sympy/test_external/test_codegen.py
index 5245b79..9e2c5ac 100644
--- a/sympy/test_external/test_codegen.py
+++ b/sympy/test_external/test_codegen.py
@@ -33,6 +33,11 @@
import tempfile
import subprocess
+if sys.platform == 'win32' and sys.version_info < (2, 5):
+ # subprocess has problems in Windows Python 2.4, so skip the tests there
@asmeurer
asmeurer / gist:1208773
Created September 10, 2011 20:57
cmp_to_key fix
diff --git a/sympy/core/expr.py b/sympy/core/expr.py
index 88713b6..44eda0c 100644
--- a/sympy/core/expr.py
+++ b/sympy/core/expr.py
@@ -1825,7 +1825,7 @@ def as_coeff_exponent(self, x):
""" c*x**e -> c,e where x can be any symbolic expression.
"""
x = sympify(x)
- wc = Wild('wc')
+ wc = Wild('wc', exclude=[x])
@asmeurer
asmeurer / gist:1208834
Created September 10, 2011 21:43
Basic.sort_key fix
diff --git a/sympy/core/basic.py b/sympy/core/basic.py
index ceeff1c..eac8670 100644
--- a/sympy/core/basic.py
+++ b/sympy/core/basic.py
@@ -311,7 +311,7 @@ def sort_key(self, order=None):
"""
from sympy.core.singleton import S
- return self.class_key(), (len(self.args), self.args), S.One.sort_key(), S.One
+ return self.class_key(), (len(self.args), tuple([i.sort_key() for i in self.args])), S.One.sort_key(), S.One
@asmeurer
asmeurer / as_numer_denom_kernprof.py
Created October 29, 2011 18:16
smichr/and as_numer_denom kernprof
Wrote profile results to t.py.lprof
Timer unit: 1e-06 s
File: sympy/core/add.py
Function: as_numer_denom at line 285
Total time: 17.2948 s
Line # Hits Time Per Hit % Time Line Contents
==============================================================
285 @profile
@asmeurer
asmeurer / gist:1358969
Created November 11, 2011 19:29
Markdown test

Header

Bold

for i in range(10):
    pass