Thanks for your answers. I was thinking of making a custom class, but 
wanted to be sure I wasn't reinventing the wheel.
I made a first attempt to define a custom class, but I stumbled upon an 
issue with eval and simplify. If the integrand is 0 the whole integral can 
be set to 0.
So I tried the followiung code without success:

import sympy as sp
class LebesgueIntegral(sp.Expr):
    def _latex(self, printer, exp=1):
        m, n, l = self.args
        _m, _n, _l = printer._print(m), printer._print(n), printer._print(l)
        return r'\int_{%s} %s \,d%s' % (_m, _n, _l)

    @classmethod
    def eval(cls, m, n, l):
        if n == 0:
            return 0

    def _eval_simplify(self, **kwargs):
        if self.args[1] == 0:
            return 0
        return self

u = LebesgueIntegral(sp.Symbol('\Omega'), sp.sympify(0),sp.Symbol('x'))
print(sp.latex(u))
print(sp.simplify(u))
print(sp.simplify(2*u))

The above code gives me the output:
\int_{\Omega} 0 \,dx
0
2*LebesgueIntegral(\Omega, 0, x)

Why is the method eval not called in the first print statement?
I had a look at the simplify module but it is very hard for me to 
understand. Is it intended that the simplify method of the class is not 
called in the third print statement?

Michael Gfrerer

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/4f46ffe4-e4ca-4d14-bcb5-2402574af17dn%40googlegroups.com.

Reply via email to