Skip to content

TST: address TODOs/FIXMES/noqas #44960

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

Merged
merged 2 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

try:
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
except ImportError as e: # pragma: no cover
module = e.name
except ImportError as err: # pragma: no cover
module = err.name
raise ImportError(
f"C extension: {module} not built. If you want to import "
"pandas from the source directory, you may need to run "
"'python setup.py build_ext --force' to build the C extensions first."
) from e
) from err
else:
del _tslib, _lib, _hashtable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think this is a big deal

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but it came up when i tried to remove the # noqa at the top of the file so i figured why not

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i c, ok that's fine then (prob should think about the other private modules in that case then)


from pandas._config import (
get_option,
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,9 @@ class TestPDApi(Base):
# private modules in pandas namespace
private_modules = [
"_config",
"_hashtable",
"_lib",
"_libs",
"_is_numpy_dev",
"_testing",
"_tslib",
"_typing",
"_version",
]
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/internals/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,16 +494,13 @@ def test_copy(self, mgr):

def test_sparse(self):
mgr = create_mgr("a: sparse-1; b: sparse-2")
# what to test here?
assert mgr.as_array().dtype == np.float64

def test_sparse_mixed(self):
mgr = create_mgr("a: sparse-1; b: sparse-2; c: f8")
assert len(mgr.blocks) == 3
assert isinstance(mgr, BlockManager)

# TODO: what to test here?

@pytest.mark.parametrize(
"mgr_string, dtype",
[("c: f4; d: f2", np.float32), ("c: f4; d: f2; e: f8", np.float64)],
Expand Down
88 changes: 52 additions & 36 deletions pandas/tests/io/formats/test_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,43 +452,59 @@ def test_to_html_invalid_justify(justify):
df.to_html(justify=justify)


def test_to_html_index(datapath):
# TODO: split this test
index = ["foo", "bar", "baz"]
df = DataFrame(
{"A": [1, 2, 3], "B": [1.2, 3.4, 5.6], "C": ["one", "two", np.nan]},
columns=["A", "B", "C"],
index=index,
)
expected_with_index = expected_html(datapath, "index_1")
assert df.to_html() == expected_with_index

expected_without_index = expected_html(datapath, "index_2")
result = df.to_html(index=False)
for i in index:
assert i not in result
assert result == expected_without_index
df.index = Index(["foo", "bar", "baz"], name="idx")
expected_with_index = expected_html(datapath, "index_3")
assert df.to_html() == expected_with_index
assert df.to_html(index=False) == expected_without_index

tuples = [("foo", "car"), ("foo", "bike"), ("bar", "car")]
df.index = MultiIndex.from_tuples(tuples)

expected_with_index = expected_html(datapath, "index_4")
assert df.to_html() == expected_with_index
class TestHTMLIndex:
@pytest.fixture
def df(self):
index = ["foo", "bar", "baz"]
df = DataFrame(
{"A": [1, 2, 3], "B": [1.2, 3.4, 5.6], "C": ["one", "two", np.nan]},
columns=["A", "B", "C"],
index=index,
)
return df

result = df.to_html(index=False)
for i in ["foo", "bar", "car", "bike"]:
assert i not in result
# must be the same result as normal index
assert result == expected_without_index

df.index = MultiIndex.from_tuples(tuples, names=["idx1", "idx2"])
expected_with_index = expected_html(datapath, "index_5")
assert df.to_html() == expected_with_index
assert df.to_html(index=False) == expected_without_index
@pytest.fixture
def expected_without_index(self, datapath):
return expected_html(datapath, "index_2")

def test_to_html_flat_index_without_name(
self, datapath, df, expected_without_index
):
expected_with_index = expected_html(datapath, "index_1")
assert df.to_html() == expected_with_index

result = df.to_html(index=False)
for i in df.index:
assert i not in result
assert result == expected_without_index

def test_to_html_flat_index_with_name(self, datapath, df, expected_without_index):
df.index = Index(["foo", "bar", "baz"], name="idx")
expected_with_index = expected_html(datapath, "index_3")
assert df.to_html() == expected_with_index
assert df.to_html(index=False) == expected_without_index

def test_to_html_multiindex_without_names(
self, datapath, df, expected_without_index
):
tuples = [("foo", "car"), ("foo", "bike"), ("bar", "car")]
df.index = MultiIndex.from_tuples(tuples)

expected_with_index = expected_html(datapath, "index_4")
assert df.to_html() == expected_with_index

result = df.to_html(index=False)
for i in ["foo", "bar", "car", "bike"]:
assert i not in result
# must be the same result as normal index
assert result == expected_without_index

def test_to_html_multiindex_with_names(self, datapath, df, expected_without_index):
tuples = [("foo", "car"), ("foo", "bike"), ("bar", "car")]
df.index = MultiIndex.from_tuples(tuples, names=["idx1", "idx2"])
expected_with_index = expected_html(datapath, "index_5")
assert df.to_html() == expected_with_index
assert df.to_html(index=False) == expected_without_index


@pytest.mark.parametrize("classes", ["sortable draggable", ["sortable", "draggable"]])
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/io/json/test_json_table_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,11 @@ def test_as_json_table_type_date_dtypes(self, date_dtype):
def test_as_json_table_type_timedelta_dtypes(self, td_dtype):
assert as_json_table_type(td_dtype) == "duration"

@pytest.mark.parametrize("str_dtype", [object]) # TODO
@pytest.mark.parametrize("str_dtype", [object]) # TODO(GH#14904) flesh out dtypes?
def test_as_json_table_type_string_dtypes(self, str_dtype):
assert as_json_table_type(str_dtype) == "string"

def test_as_json_table_type_categorical_dtypes(self):
# TODO: I think before is_categorical_dtype(Categorical)
# returned True, but now it's False. Figure out why or
# if it matters
assert as_json_table_type(pd.Categorical(["a"]).dtype) == "any"
assert as_json_table_type(CategoricalDtype()) == "any"

Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/parser/common/test_file_buffer_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

@tm.network
def test_url(all_parsers, csv_dir_path):
# TODO: FTP testing
parser = all_parsers
kwargs = {"sep": "\t"}

Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/io/pytables/test_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,8 @@ def test_columns_multiindex_modified(setup_path):
)
cols2load = list("BCD")
cols2load_original = list(cols2load)
df_loaded = read_hdf(path, "df", columns=cols2load) # noqa
# GH#10055 make sure read_hdf call does not alter cols2load inplace
read_hdf(path, "df", columns=cols2load)
assert cols2load_original == cols2load


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,7 @@ def test_get_engine_auto_error_message(self):
# Expect different error messages from get_engine(engine="auto")
# if engines aren't installed vs. are installed but bad version
pass
# TODO fill this in when we add more engines
# TODO(GH#36893) fill this in when we add more engines


class _TestSQLAlchemyConn(_EngineToConnMixin, _TestSQLAlchemy):
Expand Down
7 changes: 3 additions & 4 deletions pandas/tests/reductions/test_stat_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ def test_dt64_mean(self, tz_naive_fixture, box):
assert obj.mean(skipna=False) is pd.NaT

@pytest.mark.parametrize("box", [Series, pd.Index, PeriodArray])
def test_period_mean(self, box):
@pytest.mark.parametrize("freq", ["S", "H", "D", "W", "B"])
def test_period_mean(self, box, freq):
# GH#24757
dti = pd.date_range("2001-01-01", periods=11)
# shuffle so that we are not just working with monotone-increasing
dti = dti.take([4, 1, 3, 10, 9, 7, 8, 5, 0, 2, 6])

# use hourly frequency to avoid rounding errors in expected results
# TODO: flesh this out with different frequencies
parr = dti._data.to_period("H")
parr = dti._data.to_period(freq)
obj = box(parr)
with pytest.raises(TypeError, match="ambiguous"):
obj.mean()
Expand Down
Loading