steph1111 / PRECISE

Precision Rules Enforced Calculations In Scientific Environments
Other
0 stars 0 forks source link

sig_float: Create tests #4

Open steph1111 opened 1 year ago

steph1111 commented 1 year ago

Tests moved to tests_sig_float.py

steph1111 commented 1 year ago

Sig fig count tests:

+ 1) 00122.9800 -> 7
+ 2) 12000 -> 2
+ 3) 12000. -> 5
+ 4) 0012000. -> 5
+ 5) 2536.000 -> 7
+ 6) 1.000 -> 4
+ 7) 0.00033 -> 2
+ 8) 12.09 -> 4
+ 9) -000001 -> 1
+ 10) -10. -> 2
+ 11) 0.2000 -> 4

Addition and subtraction tests:

+ 1) 13.0198 + 1.2 = 14.2
+ 2) 94 + 15 + 182.113 = 291
+ 3) 59.21 - 18.8722 = 40.34
+ 4) 8.679 + .3 + 5.88 = 14.9
+ 5) 2.36 + 5.4 = 7.8
+ 6) 7.2361 + 8.42 = 15.66
+ 7) 420. + 3.51 = 424
+ 8) 500 + 1.365 = 500
+ 9) -420. + 3.51 = -416
+ 10) -50 + -3.2 = -50
+ 11) 300 - 47.465 = 300
+ 12) 0.0007 - 0.775 = -0.774

Multiplication and division tests:

+ 1) 6 * 0.30 = 2
+ 2) 0.03 * 7 * 210 = 40
+ 3) 11.6 * 6.24 = 72.4
+ 4) 0.004 * 5280 = 20
+ 5) 500.55 / 5.11 = 98.0
+ 6) 1000 / 8.2 = 100
+ 7) 51.6 * 31.4 = 1620
+ 8) 8088 * 0.4 = 3000
+ 9) 204.17 / 3.2 = 64
+ 10) 8000 / 9.7 = 800
+ 11) 10.0 * 0.200 = 2.00
+ 12) 1 / 3 = 0.3333333333333333

Mixed operations tests:

+ 1) (15.803 - 4.76) / 9.3 = 1.2
+ 2) (0.91 + 1.2 + 8.4) / 3.700 = 2.84
+ 3) (2.8 * 4.532) + 12.690 = 25
- 4) 55  * 55  * 1.0  + 1.0  = 3000 

Rounding tests:

+ 1) round_sig(8712082, 2) -> 8700000
+ 2) round_sig(8000, 2) -> 8\bar{0}00
+ 3) round_sig(980, 2) -> 980
+ 4) round_sig(120000, 6) -> 120000.
+ 5) round_sig(("120000", {"kg":1, "m":1, "s":-2}), 4) -> 120\bar{0}00 \; kg \cdot m \cdot s^{-2}

Unit tests:

+ 1) (2.8 \; kg^{2} \cdot m^{5}) / (2.2 \; kg^{2} \cdot m) = 1.3 \; m^{4}
+ 2) V2 = 0.476 \; L
+ 3) density_object: 2490 \; kg \cdot m^{-3}
+ 4) R: 0.08206 \; L \cdot atm \cdot mol^{-1} \cdot K^{-1}
+ 5) mass (m): 0.03 \; kg

LaTeX tests:

+ 1) density_obj in format=1: 2490 \; kg \cdot m^{-3}
+ 2) density_obj in format=2: 2490 \frac{kg}{m^{3}}
+ 3) R in format=1: 0.08206 \; L \cdot atm \cdot mol^{-1} \cdot K^{-1}
+ 4) R in format=2: 0.08206 \frac{L \cdot atm}{mol \cdot K}
+ 5) R in format=3: 0.08206 \; L \cdot atm / mol \cdot K
+ 6) V2 in format=1: 0.476 \; L
+ 7) V2 in format=2: 0.476 \; L
+ 8) f in format=2: 300.0 \frac {1}{s}
+ 9) f in format=3: 300.0 \; s^{-1}

Scientific tests:

+ 1) 3.000 \times 10^{2} \; s^{-1}
+ 2) 1.2 \times 10^{5} \; kg \cdot m \cdot s^{-2}
+ 3) 1.23000 \times 10^{2} \; m
schrodinstein commented 1 year ago

Please see here for my test generator. EDIT: Note that it does NOT deal with sig figs. We will need to validate manually.