Ask Your Question

Convert derived SI units to base units

asked 2013-06-20 02:10:16 -0500

stan gravatar image

How can I convert SI units involving temperature (kelvin) to their base units?

Example using units of heat capacity:

# Temperature units multiplied by other units cannot be converted
blah =

Traceback (click to the left of this block for traceback)


ValueError: Cannot convert

I need this output:


There is a discussion of this issue at the link below, but there should be a function to convert to base units in the absence of numerical values. Link: [!sea...]

Does anyone know how to do this?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-06-22 10:00:49 -0500

Eviatar Bach gravatar image

updated 2013-07-02 17:07:43 -0500

This should be a built-in function, indeed. Here's a solution in the meanwhile:

def convert(expr):
     op = expr.operator()
     ops = expr.operands()
     if op:
        if len(ops) == 2:
            return op(*map(convert, ops))
            return op(convert(ops[0]), reduce(op, map(convert, ops[1:])))
        return expr.convert() if hasattr(expr, 'convert') else expr


sage: blah =
sage: convert(blah)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2013-06-20 02:10:16 -0500

Seen: 518 times

Last updated: Jul 02 '13