Skip to content

Conversation

@Nathan-Majernik
Copy link

nice_scale_prefix(), nice_array(), and plottable_array() now all optionally take a unit_symbol argument. This allows the detection of prefixes that don't make sense and prevents them from being used. Other code which calls these functions in the repo updated to reflect the change

Fixes #116


Basic test:

python -c "
from pmd_beamphysics.units import nice_scale_prefix

# Test the updated cases
print('Test: A (Ampere) unit should get prefix')
f, p = nice_scale_prefix(1e-6, unit_symbol='A')
print(f'  Result: factor={f}, prefix=\"{p}\"')

print('\nTest: √m unit should NOT get prefix')
f, p = nice_scale_prefix(1e-6, unit_symbol='√m')
print(f'  Result: factor={f}, prefix=\"{p}\"')

print('\nTest: m (meter) unit should get prefix')
f, p = nice_scale_prefix(1e-6, unit_symbol='m')
print(f'  Result: factor={f}, prefix=\"{p}\"')
"

nice_scale_prefix(), nice_array(), and plottable_array() now all optionally take a unit_symbol argument. This allows the detection of prefixes that don't make sense and prevents them from being used. Other code updated to use this new argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improper SI prefixes

1 participant