Coverage for /usr/lib/python3/dist-packages/sympy/physics/units/systems/mks.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1""" 

2MKS unit system. 

3 

4MKS stands for "meter, kilogram, second". 

5""" 

6 

7from sympy.physics.units import UnitSystem 

8from sympy.physics.units.definitions import gravitational_constant, hertz, joule, newton, pascal, watt, speed_of_light, gram, kilogram, meter, second 

9from sympy.physics.units.definitions.dimension_definitions import ( 

10 acceleration, action, energy, force, frequency, momentum, 

11 power, pressure, velocity, length, mass, time) 

12from sympy.physics.units.prefixes import PREFIXES, prefix_unit 

13from sympy.physics.units.systems.length_weight_time import dimsys_length_weight_time 

14 

15dims = (velocity, acceleration, momentum, force, energy, power, pressure, 

16 frequency, action) 

17 

18units = [meter, gram, second, joule, newton, watt, pascal, hertz] 

19all_units = [] 

20 

21# Prefixes of units like gram, joule, newton etc get added using `prefix_unit` 

22# in the for loop, but the actual units have to be added manually. 

23all_units.extend([gram, joule, newton, watt, pascal, hertz]) 

24 

25for u in units: 

26 all_units.extend(prefix_unit(u, PREFIXES)) 

27all_units.extend([gravitational_constant, speed_of_light]) 

28 

29# unit system 

30MKS = UnitSystem(base_units=(meter, kilogram, second), units=all_units, name="MKS", dimension_system=dimsys_length_weight_time, derived_units={ 

31 power: watt, 

32 time: second, 

33 pressure: pascal, 

34 length: meter, 

35 frequency: hertz, 

36 mass: kilogram, 

37 force: newton, 

38 energy: joule, 

39 velocity: meter/second, 

40 acceleration: meter/(second**2), 

41}) 

42 

43 

44__all__ = [ 

45 'MKS', 'units', 'all_units', 'dims', 

46]