MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / get_positive

Method get_positive

conversions/prefix_conversions_string.py:56–68  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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:

Callers 1

add_si_prefixFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected