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

Method get_negative

conversions/prefix_conversions_string.py:71–84  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
87def add_si_prefix(value: float) -> str:

Callers 1

add_si_prefixFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected