ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 13 May 2018 02:03:59 +0200Define custom unithttps://ask.sagemath.org/question/42321/define-custom-unit/ Is it possible to declare custom units that can be converted to SI base units? For example: if I want to measure time in ticks and I know that one tick is exactly one nanosecond, can I create a unit 'tick' that can later be converted to seconds?
I know that a custom unit can be declared with
sage: sage.symbolic.units.str_to_unit('tick')
tick
I also know that predefined units can be converted, for example by
sage: units.time.minute.convert(units.time.second)
60*second
However, I want to be able to declare a unit that has both its own name and that can be converted to other units.
sage: tick = sage.symbolic.units.str_to_unit('tick')
sage: tick
tick
sage: #(define relation to SI units here)
sage: tick.convert(units.time.second)
(ValueError: Incompatible units)
Is it possible to define a unit ‘tick’ that can be converted to seconds in this manner?johannehSun, 13 May 2018 02:03:59 +0200https://ask.sagemath.org/question/42321/