Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 10, 2024
1 parent 0dd8367 commit 3f3c383
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion pandas/core/computation/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ def where(cond, left_op, right_op, use_numexpr: bool = True):
Whether to try to use numexpr.
"""
assert _where is not None
return _where(cond, left_op, right_op) if use_numexpr else _where_standard(cond, left_op, right_op)
return (
_where(cond, left_op, right_op)
if use_numexpr
else _where_standard(cond, left_op, right_op)
)


def set_test_mode(v: bool = True) -> None:
Expand Down
4 changes: 3 additions & 1 deletion pandas/core/computation/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ def stringify(value):
# string quoting
return TermValue(conv_val, stringify(conv_val), "string")
else:
raise TypeError(f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column")
raise TypeError(
f"Cannot compare {conv_val} of type {type(conv_val)} to {kind} column"
)

def convert_values(self) -> None:
pass
Expand Down
5 changes: 2 additions & 3 deletions pandas/core/dtypes/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2277,9 +2277,8 @@ def numpy_dtype(self) -> np.dtype:
"""Return an instance of the related numpy dtype."""
# For string-like arrow dtypes, pa.string().to_pandas_dtype() = object
# so we handle them explicitly.
if (
pa.types.is_string(self.pyarrow_dtype)
or pa.types.is_large_string(self.pyarrow_dtype)
if pa.types.is_string(self.pyarrow_dtype) or pa.types.is_large_string(
self.pyarrow_dtype
):
return np.dtype(str)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/dtypes/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1103,16 +1103,16 @@ def test_update_dtype_errors(self, bad_dtype):
with pytest.raises(ValueError, match=msg):
dtype.update_dtype(bad_dtype)


class TestArrowDtype:
@pytest.mark.parametrize(
"tz",
["UTC", "America/New_York", "Europe/London", "Asia/Tokyo"]
"tz", ["UTC", "America/New_York", "Europe/London", "Asia/Tokyo"]
)
def test_pyarrow_timestamp_tz_preserved(self, tz):
pytest.importorskip("pyarrow")
s = Series(
pd.to_datetime(range(5), unit="h", utc=True).tz_convert(tz),
dtype=f"timestamp[ns, tz={tz}][pyarrow]"
dtype=f"timestamp[ns, tz={tz}][pyarrow]",
)

result = s.convert_dtypes(dtype_backend="pyarrow")
Expand Down

0 comments on commit 3f3c383

Please sign in to comment.