4
4
from _plotly_utils .basevalidators import NumberValidator
5
5
import numpy as np
6
6
import pandas as pd
7
+ from plotly .tests .test_optional .test_utils .test_utils import np_nan , np_inf
7
8
8
9
# Fixtures
9
10
# --------
@@ -36,7 +37,7 @@ def validator_aok():
36
37
# ------------
37
38
# ### Acceptance ###
38
39
@pytest .mark .parametrize (
39
- "val" , [1.0 , 0.0 , 1 , - 1234.5678 , 54321 , np .pi , np . nan , np . inf , - np . inf ]
40
+ "val" , [1.0 , 0.0 , 1 , - 1234.5678 , 54321 , np .pi , np_nan (), np_inf () , - np_inf () ]
40
41
)
41
42
def test_acceptance (val , validator ):
42
43
assert validator .validate_coerce (val ) == approx (val , nan_ok = True )
@@ -57,7 +58,7 @@ def test_acceptance_min_max(val, validator_min_max):
57
58
assert validator_min_max .validate_coerce (val ) == approx (val )
58
59
59
60
60
- @pytest .mark .parametrize ("val" , [- 1.01 , - 10 , 2.1 , 234 , - np . inf , np . nan , np . inf ])
61
+ @pytest .mark .parametrize ("val" , [- 1.01 , - 10 , 2.1 , 234 , - np_inf (), np_nan (), np_inf () ])
61
62
def test_rejection_min_max (val , validator_min_max ):
62
63
with pytest .raises (ValueError ) as validation_failure :
63
64
validator_min_max .validate_coerce (val )
@@ -66,12 +67,12 @@ def test_rejection_min_max(val, validator_min_max):
66
67
67
68
68
69
# ### With min only ###
69
- @pytest .mark .parametrize ("val" , [0 , 0.0 , - 0.5 , 99999 , np . inf ])
70
+ @pytest .mark .parametrize ("val" , [0 , 0.0 , - 0.5 , 99999 , np_inf () ])
70
71
def test_acceptance_min (val , validator_min ):
71
72
assert validator_min .validate_coerce (val ) == approx (val )
72
73
73
74
74
- @pytest .mark .parametrize ("val" , [- 1.01 , - np . inf , np . nan ])
75
+ @pytest .mark .parametrize ("val" , [- 1.01 , - np_inf (), np_nan () ])
75
76
def test_rejection_min (val , validator_min ):
76
77
with pytest .raises (ValueError ) as validation_failure :
77
78
validator_min .validate_coerce (val )
@@ -80,12 +81,12 @@ def test_rejection_min(val, validator_min):
80
81
81
82
82
83
# ### With max only ###
83
- @pytest .mark .parametrize ("val" , [0 , 0.0 , - np . inf , - 123456 , np .pi / 2 ])
84
+ @pytest .mark .parametrize ("val" , [0 , 0.0 , - np_inf () , - 123456 , np .pi / 2 ])
84
85
def test_acceptance_max (val , validator_max ):
85
86
assert validator_max .validate_coerce (val ) == approx (val )
86
87
87
88
88
- @pytest .mark .parametrize ("val" , [2.01 , np . inf , np . nan ])
89
+ @pytest .mark .parametrize ("val" , [2.01 , np_inf (), np_nan () ])
89
90
def test_rejection_max (val , validator_max ):
90
91
with pytest .raises (ValueError ) as validation_failure :
91
92
validator_max .validate_coerce (val )
@@ -142,7 +143,13 @@ def test_rejection_aok(val, validator_aok):
142
143
# ### Rejection by element ###
143
144
@pytest .mark .parametrize (
144
145
"val" ,
145
- [[- 1.6 , 0.0 ], [1 , 1.5 , 2 ], [- 0.1234 , 0.41 , np .nan ], [0 , np .inf ], [0 , - np .inf ]],
146
+ [
147
+ [- 1.6 , 0.0 ],
148
+ [1 , 1.5 , 2 ],
149
+ [- 0.1234 , 0.41 , np_nan ()],
150
+ [0 , np_inf ()],
151
+ [0 , - np_inf ()],
152
+ ],
146
153
)
147
154
def test_rejection_aok_min_max (val , validator_aok ):
148
155
with pytest .raises (ValueError ) as validation_failure :
0 commit comments