-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST(string dtype): Fix xfails in test_block_internals.py #60765
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
import numpy as np | ||
import pytest | ||
|
||
from pandas._config import using_string_dtype | ||
|
||
import pandas as pd | ||
from pandas import ( | ||
Categorical, | ||
|
@@ -162,21 +160,7 @@ def test_constructor_with_convert(self): | |
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)") | ||
def test_construction_with_mixed(self, float_string_frame, using_infer_string): | ||
# test construction edge cases with mixed types | ||
|
||
# f7u12, this does not work without extensive workaround | ||
data = [ | ||
[datetime(2001, 1, 5), np.nan, datetime(2001, 1, 2)], | ||
[datetime(2000, 1, 2), datetime(2000, 1, 3), datetime(2000, 1, 1)], | ||
] | ||
df = DataFrame(data) | ||
|
||
# check dtypes | ||
result = df.dtypes | ||
expected = Series({"datetime64[us]": 3}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would adding a tm.assertsimething pass here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No - adding The data provided is 3 dimensional so I'm not sure why the expected Series is just one element, unless it meant to do list multiplication instead of creating a dictionary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm happy to make that change if we want the list multiplication. I just can't figure out why its here in the first place though, so figured a good removal candidate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The data is 2 dimensional, so it creates the dataframe just fine?
But indeed the series should have three elements. And agreed that it looks like out of place to being tested here, I am fine with removing this |
||
# mixed-type frames | ||
float_string_frame["datetime"] = datetime.now() | ||
float_string_frame["timedelta"] = timedelta(days=1, seconds=1) | ||
|
@@ -196,13 +180,11 @@ def test_construction_with_mixed(self, float_string_frame, using_infer_string): | |
) | ||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)") | ||
def test_construction_with_conversions(self): | ||
# convert from a numpy array of non-ns timedelta64; as of 2.0 this does | ||
# *not* convert | ||
arr = np.array([1, 2, 3], dtype="timedelta64[s]") | ||
df = DataFrame(index=range(3)) | ||
df["A"] = arr | ||
df = DataFrame({"A": arr}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The failures in this module go back to the discussion in #60338 I don't think it is important for these tests to use that construction pattern |
||
expected = DataFrame( | ||
{"A": pd.timedelta_range("00:00:01", periods=3, freq="s")}, index=range(3) | ||
) | ||
|
@@ -220,11 +202,11 @@ def test_construction_with_conversions(self): | |
assert expected.dtypes["dt1"] == "M8[s]" | ||
assert expected.dtypes["dt2"] == "M8[s]" | ||
|
||
df = DataFrame(index=range(3)) | ||
df["dt1"] = np.datetime64("2013-01-01") | ||
df["dt2"] = np.array( | ||
dt1 = np.datetime64("2013-01-01") | ||
dt2 = np.array( | ||
["2013-01-01", "2013-01-02", "2013-01-03"], dtype="datetime64[D]" | ||
) | ||
df = DataFrame({"dt1": dt1, "dt2": dt2}) | ||
|
||
# df['dt3'] = np.array(['2013-01-01 00:00:01','2013-01-01 | ||
# 00:00:02','2013-01-01 00:00:03'],dtype='datetime64[s]') | ||
|
@@ -401,14 +383,16 @@ def test_update_inplace_sets_valid_block_values(): | |
assert isinstance(df._mgr.blocks[0].values, Categorical) | ||
|
||
|
||
@pytest.mark.xfail(using_string_dtype(), reason="TODO(infer_string)") | ||
def test_nonconsolidated_item_cache_take(): | ||
# https://github.com/pandas-dev/pandas/issues/35521 | ||
|
||
# create non-consolidated dataframe with object dtype columns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still non-consolidated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah nice catch - let me fix that |
||
df = DataFrame() | ||
df["col1"] = Series(["a"], dtype=object) | ||
df["col2"] = Series([0], dtype=object) | ||
df = DataFrame( | ||
{ | ||
"col1": Series(["a"], dtype=object), | ||
"col2": Series([0], dtype=object), | ||
} | ||
) | ||
|
||
# access column (item cache) | ||
df["col1"] == "A" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume something got lost in refactor, but the code removed here is not actually being tested. Both the
result
andexpected
variables are getting shadowed before they are compared