Returns a dictionary with only the elements of this enum that has a positive value >>> from itertools import islice >>> positive = SIUnit.get_positive() >>> inc = iter(positive.items()) >>> dict(islice(inc, len(positive) // 2)) {'yotta': 24, '
(cls)
| 54 | |
| 55 | @classmethod |
| 56 | def get_positive(cls) -> dict: |
| 57 | """ |
| 58 | Returns a dictionary with only the elements of this enum |
| 59 | that has a positive value |
| 60 | >>> from itertools import islice |
| 61 | >>> positive = SIUnit.get_positive() |
| 62 | >>> inc = iter(positive.items()) |
| 63 | >>> dict(islice(inc, len(positive) // 2)) |
| 64 | {'yotta': 24, 'zetta': 21, 'exa': 18, 'peta': 15, 'tera': 12} |
| 65 | >>> dict(inc) |
| 66 | {'giga': 9, 'mega': 6, 'kilo': 3, 'hecto': 2, 'deca': 1} |
| 67 | """ |
| 68 | return {unit.name: unit.value for unit in cls if unit.value > 0} |
| 69 | |
| 70 | @classmethod |
| 71 | def get_negative(cls) -> dict: |