File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -485,12 +485,20 @@ def parse_fill_value(
485485        pass 
486486    elif  fill_value  in  ["Infinity" , "-Infinity" ] and  not  np .isfinite (casted_value ):
487487        pass 
488-     elif  np_dtype .kind  in   "cf " :
488+     elif  np_dtype .kind  ==   "f " :
489489        # float comparison is not exact, especially when dtype <float64 
490-         # so we us  np.isclose for this comparison. 
490+         # so we use  np.isclose for this comparison. 
491491        # this also allows us to compare nan fill_values 
492492        if  not  np .isclose (fill_value , casted_value , equal_nan = True ):
493493            raise  ValueError (f"fill value { fill_value !r}   is not valid for dtype { data_type }  " )
494+     elif  np_dtype .kind  ==  "c" :
495+         # confusingly np.isclose(np.inf, np.inf + 0j) is False, so compare real and imag parts 
496+         # explicitly. 
497+         if  not  (
498+             np .isclose (np .real (fill_value ), np .real (casted_value ), equal_nan = True )
499+             and  np .isclose (np .imag (fill_value ), np .imag (casted_value ), equal_nan = True )
500+         ):
501+             raise  ValueError (f"fill value { fill_value !r}   is not valid for dtype { data_type }  " )
494502    else :
495503        if  fill_value  !=  casted_value :
496504            raise  ValueError (f"fill value { fill_value !r}   is not valid for dtype { data_type }  " )
Original file line number Diff line number Diff line change 11import  json 
2+ import  math 
23import  pickle 
34from  itertools  import  accumulate 
45from  typing  import  Any , Literal 
@@ -448,7 +449,7 @@ def test_array_create_order(
448449        (np .inf , ["Infinity" , 0.0 ]), 
449450        (np .inf  *  1j , ["NaN" , "Infinity" ]), 
450451        (- np .inf , ["-Infinity" , 0.0 ]), 
451-         #  (math.inf, ["Infinity", 0.0]), 
452+         (math .inf , ["Infinity" , 0.0 ]), 
452453    ], 
453454) 
454455async  def  test_special_complex_fill_values_roundtrip (fill_value : Any , expected : list [Any ]) ->  None :
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments