Returns a dictionary with only the elements of this enum that has a negative value @example >>> from itertools import islice >>> negative = SIUnit.get_negative() >>> inc = iter(negative.items()) >>> dict(islice(inc, len(negative) // 2))
(cls)
| 69 | |
| 70 | @classmethod |
| 71 | def get_negative(cls) -> dict: |
| 72 | """ |
| 73 | Returns a dictionary with only the elements of this enum |
| 74 | that has a negative value |
| 75 | @example |
| 76 | >>> from itertools import islice |
| 77 | >>> negative = SIUnit.get_negative() |
| 78 | >>> inc = iter(negative.items()) |
| 79 | >>> dict(islice(inc, len(negative) // 2)) |
| 80 | {'deci': -1, 'centi': -2, 'milli': -3, 'micro': -6, 'nano': -9} |
| 81 | >>> dict(inc) |
| 82 | {'pico': -12, 'femto': -15, 'atto': -18, 'zepto': -21, 'yocto': -24} |
| 83 | """ |
| 84 | return {unit.name: unit.value for unit in cls if unit.value < 0} |
| 85 | |
| 86 | |
| 87 | def add_si_prefix(value: float) -> str: |