Processor to convert the units the function arguments. The syntax is equal to `Processor` except that strings are interpreted as units. >>> conv = FromQuantityProcessor('ms') >>> conv(Q_(1, 's')) 1000.0
| 183 | |
| 184 | |
| 185 | class FromQuantityProcessor(Processor): |
| 186 | """Processor to convert the units the function arguments. |
| 187 | |
| 188 | The syntax is equal to `Processor` except that strings are interpreted |
| 189 | as units. |
| 190 | |
| 191 | >>> conv = FromQuantityProcessor('ms') |
| 192 | >>> conv(Q_(1, 's')) |
| 193 | 1000.0 |
| 194 | |
| 195 | """ |
| 196 | |
| 197 | @classmethod |
| 198 | def to_callable(cls, obj): |
| 199 | if isinstance(obj, (str, Q_)): |
| 200 | return convert_to(obj, return_float=True) |
| 201 | raise TypeError('FromQuantityProcessor argument must be a string ' |
| 202 | ' or a callable, not {}'.format(obj)) |
| 203 | |
| 204 | |
| 205 | class ToQuantityProcessor(Processor): |