You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In both cases the add_c_prefix does not have the effect of configuring the formatter to use the c prefix. This is because the formatter includes input for extra_si_prefixes. The current behavior is that, like all other options, the global extra_si_prefixes is used only if the local extra_si_prefixes=None.
An alternative, possibly expected, behavior would be that the local extra_si_prefixes are always merged into the global extra_si_prefixes at format time.
The text was updated successfully, but these errors were encountered:
These semantics are not exceptional, they are the norm within sciform:
from sciform import Formatter, GlobalDefaultsContext
sform = Formatter(
exp_mode="fixed_point",
)
with GlobalDefaultsContext(exp_mode="scientific"):
print(sform(123456))
I make the following proposals:
Confirm that the extra prefixes/parts-per-forms options behave like other options. That is, at format time, any totally unpopulated options are populated with options from the global options.
Make sure there are sufficient tests asserting the above behavior
Make sure the documentation and examples are clear on this behavior
Remove the bare global helper functions like global_add_c_prefix(). These options are redundant with set_global_defaults. Note this is slightly off-topic wrt the original topic of this issue but it contributes to some of the complexity in the code and adds unnecessary mental load to figuring out how these options work. This is the part of the modification that will be breaking.
The upshot is that the extra_si_prefixes, extra_iec_prefixes and extra_parts_per_forms options should be handled exactly like any other options with the small addendum that the add_c_prefix, add_small_si_prefixes and add_ppth_form helper flags exist to populate these dictionary with some special values during __post_init__.
Consider
In both cases the
add_c_prefix
does not have the effect of configuring the formatter to use thec
prefix. This is because the formatter includes input forextra_si_prefixes
. The current behavior is that, like all other options, the globalextra_si_prefixes
is used only if the localextra_si_prefixes=None
.An alternative, possibly expected, behavior would be that the local
extra_si_prefixes
are always merged into the globalextra_si_prefixes
at format time.The text was updated successfully, but these errors were encountered: