@@ -327,31 +327,6 @@ def _not_in(x, y):
327
327
_binary_ops_dict .update (d )
328
328
329
329
330
- def _cast_inplace (terms , acceptable_dtypes , dtype ) -> None :
331
- """
332
- Cast an expression inplace.
333
-
334
- Parameters
335
- ----------
336
- terms : Op
337
- The expression that should cast.
338
- acceptable_dtypes : list of acceptable numpy.dtype
339
- Will not cast if term's dtype in this list.
340
- dtype : str or numpy.dtype
341
- The dtype to cast to.
342
- """
343
- dt = np .dtype (dtype )
344
- for term in terms :
345
- if term .type in acceptable_dtypes :
346
- continue
347
-
348
- try :
349
- new_value = term .value .astype (dt )
350
- except AttributeError :
351
- new_value = dt .type (term .value )
352
- term .update (new_value )
353
-
354
-
355
330
def is_term (obj ) -> bool :
356
331
return isinstance (obj , Term )
357
332
@@ -508,34 +483,6 @@ def _disallow_scalar_only_bool_ops(self) -> None:
508
483
raise NotImplementedError ("cannot evaluate scalar only bool ops" )
509
484
510
485
511
- def isnumeric (dtype ) -> bool :
512
- return issubclass (np .dtype (dtype ).type , np .number )
513
-
514
-
515
- class Div (BinOp ):
516
- """
517
- Div operator to special case casting.
518
-
519
- Parameters
520
- ----------
521
- lhs, rhs : Term or Op
522
- The Terms or Ops in the ``/`` expression.
523
- """
524
-
525
- def __init__ (self , lhs , rhs ) -> None :
526
- super ().__init__ ("/" , lhs , rhs )
527
-
528
- if not isnumeric (lhs .return_type ) or not isnumeric (rhs .return_type ):
529
- raise TypeError (
530
- f"unsupported operand type(s) for { self .op } : "
531
- f"'{ lhs .return_type } ' and '{ rhs .return_type } '"
532
- )
533
-
534
- # do not upcast float32s to float64 un-necessarily
535
- acceptable_dtypes = [np .float32 , np .float64 ]
536
- _cast_inplace (com .flatten (self ), acceptable_dtypes , np .float64 )
537
-
538
-
539
486
UNARY_OPS_SYMS = ("+" , "-" , "~" , "not" )
540
487
_unary_ops_funcs = (operator .pos , operator .neg , operator .invert , operator .invert )
541
488
_unary_ops_dict = dict (zip (UNARY_OPS_SYMS , _unary_ops_funcs ))
0 commit comments