Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
babel.numbers.NumberPattern Class Reference

Public Member Functions

None __init__ (self, str pattern, tuple[str, str] prefix, tuple[str, str] suffix, tuple[int, int] grouping, tuple[int, int] int_prec, tuple[int, int] frac_prec, tuple[int, int]|None exp_prec, bool|None exp_plus, str|None number_pattern=None)
 
str __repr__ (self)
 
Literal[0, 2, 3] compute_scale (self)
 
tuple[decimal.Decimal, int, str] scientific_notation_elements (self, decimal.Decimal value, Locale|str|None locale, *Literal["default"]|str numbering_system="latn")
 
 apply (self, float|decimal.Decimal|str value, Locale|str|None locale, str|None currency=None, bool currency_digits=True, bool decimal_quantization=True, tuple[int, int]|None force_frac=None, bool group_separator=True, *Literal["default"]|str numbering_system="latn")
 

Public Attributes

 pattern
 
 prefix
 
 suffix
 
 number_pattern
 
 grouping
 
 int_prec
 
 frac_prec
 
 exp_prec
 
 exp_plus
 
 scale
 

Protected Member Functions

str _format_significant (self, decimal.Decimal value, int minimum, int maximum)
 
str _format_int (self, str value, int min, int max, Locale|str|None locale, *Literal["default"]|str numbering_system)
 
str _quantize_value (self, decimal.Decimal value, Locale|str|None locale, tuple[int, int] frac_prec, bool group_separator, *Literal["default"]|str numbering_system)
 
str _format_frac (self, str value, Locale|str|None locale, tuple[int, int]|None force_frac=None, *Literal["default"]|str numbering_system)
 

Member Function Documentation

◆ apply()

babel.numbers.NumberPattern.apply (   self,
float | decimal.Decimal | str  value,
Locale | str | None  locale,
str | None   currency = None,
bool   currency_digits = True,
bool   decimal_quantization = True,
tuple[int, int] | None   force_frac = None,
bool   group_separator = True,
*Literal["default"] | str   numbering_system = "latn" 
)
Renders into a string a number following the defined pattern.

Forced decimal quantization is active by default so we'll produce a
number string that is strictly following CLDR pattern definitions.

:param value: The value to format. If this is not a Decimal object,
              it will be cast to one.
:type value: decimal.Decimal|float|int
:param locale: The locale to use for formatting.
:type locale: str|babel.core.Locale
:param currency: Which currency, if any, to format as.
:type currency: str|None
:param currency_digits: Whether or not to use the currency's precision.
                        If false, the pattern's precision is used.
:type currency_digits: bool
:param decimal_quantization: Whether decimal numbers should be forcibly
                             quantized to produce a formatted output
                             strictly matching the CLDR definition for
                             the locale.
:type decimal_quantization: bool
:param force_frac: DEPRECATED - a forced override for `self.frac_prec`
                   for a single formatting invocation.
:param group_separator: Whether to use the locale's number group separator.
:param numbering_system: The numbering system used for formatting number symbols. Defaults to "latn".
                         The special value "default" will use the default numbering system of the locale.
:return: Formatted decimal string.
:rtype: str
:raise UnsupportedNumberingSystemError: If the numbering system is not supported by the locale.

◆ compute_scale()

Literal[0, 2, 3] babel.numbers.NumberPattern.compute_scale (   self)
Return the scaling factor to apply to the number before rendering.

Auto-set to a factor of 2 or 3 if presence of a ``%`` or ``‰`` sign is
detected in the prefix or suffix of the pattern. Default is to not mess
with the scale at all and keep it to 0.

◆ scientific_notation_elements()

tuple[decimal.Decimal, int, str] babel.numbers.NumberPattern.scientific_notation_elements (   self,
decimal.Decimal  value,
Locale | str | None  locale,
*Literal["default"] | str   numbering_system = "latn" 
)
 Returns normalized scientific notation components of a value.

The documentation for this class was generated from the following file: