Page Menu
Home
Search
Configure Global Search
Log In
Paste
P1411
D7813 stress test
Active
Public
Actions
Authored by
Campbell Barton (campbellbarton)
on May 22 2020, 5:44 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
# Run with:
# blender -b --python D7813_stress_test.py
import
random
from
bpy.utils.units
import
to_value
TESTS
=
10000
SEED
=
321
choose_numbers
=
(
"2"
,
"2e-2"
,
"2e+2"
,
"2e+2"
,
"0.2e+2"
,
"0.2e+2_2"
,
# Parenthesized.
"(0.2-2_2)"
,
"(0.2+2_2)"
,
"(0.2e-2_2)"
,
"(0.2e+2_2)"
,
)
choose_ops
=
(
"-"
,
"+"
,
"*"
)
choose_spaces
=
(
""
,
" "
)
from
bpy
import
context
unit_system
=
context
.
scene
.
unit_settings
.
system
unit_category
=
'LENGTH'
random
.
seed
(
SEED
)
for
i
in
range
(
TESTS
):
values
=
[]
for
i
in
range
(
random
.
randint
(
2
,
24
)):
if
i
!=
0
:
values
.
append
(
random
.
choice
(
choose_ops
))
values
.
append
(
random
.
choice
(
choose_spaces
))
values
.
append
(
random
.
choice
(
choose_numbers
))
expr
=
""
.
join
(
values
)
value_unit
=
to_value
(
unit_system
,
unit_category
,
expr
)
value_python
=
eval
(
expr
)
assert
(
value_unit
==
value_python
)
Event Timeline
Campbell Barton (campbellbarton)
created this paste.
May 22 2020, 5:44 AM
Campbell Barton (campbellbarton)
mentioned this in
D7813: Fix T74552: Distribute negatives in number input
.
May 22 2020, 5:46 AM
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
May 22 2020, 5:51 AM
Campbell Barton (campbellbarton)
mentioned this in
T77300: Evaluating units gives incorrect results with scientific notation (2.90x)
.
Jun 3 2020, 10:59 AM
Hans Goudey (HooglyBoogly)
mentioned this in
D7922: Fix T77300: Some Scientific Notation Evalutation Has Incorrect Results
.
Jun 3 2020, 7:11 PM
Log In to Comment