44from _plotly_utils .basevalidators import NumberValidator
55import numpy as np
66import pandas as pd
7+ from plotly .tests .test_optional .test_utils .test_utils import np_nan , np_inf
78
89# Fixtures
910# --------
@@ -36,7 +37,7 @@ def validator_aok():
3637# ------------
3738# ### Acceptance ###
3839@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 () ]
4041)
4142def test_acceptance (val , validator ):
4243 assert validator .validate_coerce (val ) == approx (val , nan_ok = True )
@@ -57,7 +58,7 @@ def test_acceptance_min_max(val, validator_min_max):
5758 assert validator_min_max .validate_coerce (val ) == approx (val )
5859
5960
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 () ])
6162def test_rejection_min_max (val , validator_min_max ):
6263 with pytest .raises (ValueError ) as validation_failure :
6364 validator_min_max .validate_coerce (val )
@@ -66,12 +67,12 @@ def test_rejection_min_max(val, validator_min_max):
6667
6768
6869# ### 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 () ])
7071def test_acceptance_min (val , validator_min ):
7172 assert validator_min .validate_coerce (val ) == approx (val )
7273
7374
74- @pytest .mark .parametrize ("val" , [- 1.01 , - np . inf , np . nan ])
75+ @pytest .mark .parametrize ("val" , [- 1.01 , - np_inf (), np_nan () ])
7576def test_rejection_min (val , validator_min ):
7677 with pytest .raises (ValueError ) as validation_failure :
7778 validator_min .validate_coerce (val )
@@ -80,12 +81,12 @@ def test_rejection_min(val, validator_min):
8081
8182
8283# ### 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 ])
8485def test_acceptance_max (val , validator_max ):
8586 assert validator_max .validate_coerce (val ) == approx (val )
8687
8788
88- @pytest .mark .parametrize ("val" , [2.01 , np . inf , np . nan ])
89+ @pytest .mark .parametrize ("val" , [2.01 , np_inf (), np_nan () ])
8990def test_rejection_max (val , validator_max ):
9091 with pytest .raises (ValueError ) as validation_failure :
9192 validator_max .validate_coerce (val )
@@ -142,7 +143,13 @@ def test_rejection_aok(val, validator_aok):
142143# ### Rejection by element ###
143144@pytest .mark .parametrize (
144145 "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+ ],
146153)
147154def test_rejection_aok_min_max (val , validator_aok ):
148155 with pytest .raises (ValueError ) as validation_failure :
0 commit comments