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