Skip to content

Instantly share code, notes, and snippets.

View Upabjojr's full-sized avatar

Francesco Bonazzi Upabjojr

View GitHub Profile
# Replace with date and time the code was generated:
from generated_tempdir_2019_09_13_232810.generated_part000000 import match_root
from sympy import *
x = symbols("x")
def check_constraints(subst, constraints):
for cons in constraints:
ret = cons(**{k: v for k, v in subst.items() if k in cons.__code__.co_varnames})
if not ret:
# This file is a working draft...
from datetime import datetime
import sys
from sympy.integrals.rubi.rubimain import get_rubi_object
sys.setrecursionlimit(15000)
import re
@Upabjojr
Upabjojr / verify_matrix_derivative.py
Created December 14, 2018 21:44
Script to check results of derivatives of matricial expression
from symengine import *
X = Matrix(var("X1:10")).reshape(3, 3)
A = Matrix(var("A1:10")).reshape(3, 3)
B = Matrix(var("B1:10")).reshape(3, 3)
C = Matrix(var("C1:10")).reshape(3, 3)
D = Matrix(var("D1:10")).reshape(3, 3)
a = Matrix(var("a1:4")).reshape(3, 1)
b = Matrix(var("b1:4")).reshape(3, 1)
@Upabjojr
Upabjojr / difference_detector_with_settrace.py
Last active September 5, 2017 21:20
Detect difference in script execution
import sys
import multiprocessing
import collections
import inspect
def f(x):
print("f function entered.")
a = x + 10
print("Value of a: ", a)
@Upabjojr
Upabjojr / get_grad.py
Last active August 29, 2015 14:10
Get gradient in another coordinate system by transformation
from sympy import *
init_printing()
from sympy.diffgeom import *
r, x, y, z = symbols('r x y z', positive=True)
theta, phi = symbols('theta phi')
N = 3
M = Manifold('M', N)
P = Patch('P', M)
rect = CoordSystem('rect', P, ['x', 'y', 'z'])
@Upabjojr
Upabjojr / fullform2sympy.py
Last active February 8, 2018 17:50
A draft to transform some limited subset of Mathematica's FullForm expression into a SymPy expression.
import re
replacements = dict(
Times="Mul",
Plus="Add",
Power="Pow",
)
def parse_full_form(wmexpr):
out = []