Skip to content

BUG: pathlib.Path in io #16292

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 11 commits into from
May 12, 2017
Merged

BUG: pathlib.Path in io #16292

merged 11 commits into from
May 12, 2017

Conversation

chris-b1
Copy link
Contributor

@chris-b1 chris-b1 commented May 9, 2017

@chris-b1 chris-b1 added Bug IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version labels May 9, 2017
@chris-b1 chris-b1 added this to the 0.20.2 milestone May 9, 2017
@@ -299,6 +300,15 @@ def test_pickle_v0_15_2():
tm.assert_categorical_equal(cat, pd.read_pickle(pickle_path))


def test_pickle_path_pathlib():
tm._skip_if_no_pathlib()
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of making a specific test can u add a general routine like we have for round_trip_pickle

Copy link
Contributor

Choose a reason for hiding this comment

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

and then use it here

ideally add tests for all of the io functions (and xfail id they don't work)

and test for localpath as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, let me know if what I just pushed is what you had in mind and I'll add to other io functions

Copy link
Contributor

Choose a reason for hiding this comment

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

yep exactly like this!

maybe put a little docs in the testing file above these 3 tests routines.



def test_pickle_path_localpath():
tm._skip_if_no_localpath()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move the skip routines to the actual test functions themselves (in util/testing)

Copy link
Contributor

Choose a reason for hiding this comment

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

ignore this, you can just use a skip importer below.



def round_trip_localpath(writer, reader, path=None):
from py.path import local as LocalPath
Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. here.

and you need an pytimportor.skip here (for both of these).

@codecov
Copy link

codecov bot commented May 9, 2017

Codecov Report

Merging #16292 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16292      +/-   ##
==========================================
- Coverage   90.39%   90.37%   -0.02%     
==========================================
  Files         161      161              
  Lines       50863    50880      +17     
==========================================
+ Hits        45977    45985       +8     
- Misses       4886     4895       +9
Flag Coverage Δ
#multiple 88.16% <100%> (ø) ⬆️
#single 40.31% <11.76%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/io/common.py 70.21% <100%> (+0.12%) ⬆️
pandas/util/testing.py 80.71% <100%> (+0.3%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/core/frame.py 97.59% <0%> (-0.1%) ⬇️
pandas/core/indexes/datetimes.py 95.23% <0%> (-0.1%) ⬇️
pandas/core/common.py 91.03% <0%> (+0.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80abd97...ae22641. Read the comment docs.

@codecov
Copy link

codecov bot commented May 9, 2017

Codecov Report

Merging #16292 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16292      +/-   ##
==========================================
- Coverage   90.39%   90.36%   -0.04%     
==========================================
  Files         161      161              
  Lines       50863    50885      +22     
==========================================
+ Hits        45977    45981       +4     
- Misses       4886     4904      +18
Flag Coverage Δ
#multiple 88.13% <100%> (-0.03%) ⬇️
#single 40.21% <85.71%> (-0.22%) ⬇️
Impacted Files Coverage Δ
pandas/util/testing.py 80.75% <100%> (+0.34%) ⬆️
pandas/io/formats/format.py 95.66% <100%> (ø) ⬆️
pandas/io/common.py 70.21% <100%> (+0.12%) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️
pandas/plotting/_converter.py 63.23% <0%> (-1.82%) ⬇️
pandas/core/util/hashing.py 90.35% <0%> (-1.69%) ⬇️
pandas/core/indexes/category.py 98.18% <0%> (-0.31%) ⬇️
pandas/core/indexes/multi.py 96.56% <0%> (-0.17%) ⬇️
pandas/core/series.py 94.71% <0%> (-0.1%) ⬇️
pandas/plotting/_core.py 81.87% <0%> (ø) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80abd97...f135e32. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

fantastic. thanks! (tiny comments). merge when ready.

@@ -314,6 +314,8 @@ def _get_handle(path_or_buf, mode, encoding=None, compression=None,

handles = list()
f = path_or_buf
# Convert pathlib.Path/py.path.local or string
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a blank line

@@ -33,6 +33,8 @@ Performance Improvements
Bug Fixes
~~~~~~~~~

- Bug in using ``pathlib.Path`` object with io functions (:issue:`16291`)
Copy link
Contributor

Choose a reason for hiding this comment

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

localpath too?


def test_pickle_path_localpath(self):
df = tm.makeDataFrame()
result = tm.round_trip_pathlib(df.to_csv,
Copy link
Member

Choose a reason for hiding this comment

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

round_trip_localpath ?

@jreback
Copy link
Contributor

jreback commented May 9, 2017

for those ones which xfail this, can you create an issue (put all in issue). Though might be one that just needs updating.

@@ -65,6 +65,26 @@ def test_from_iterator(self):
tm.assert_frame_equal(df, df0.iloc[2:5, :])
rdr.close()

def test_path_pathlib(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like needs xfailing here

@jreback
Copy link
Contributor

jreback commented May 10, 2017

can you add tests for feather-format as well (it should work I think, not sure)

@chris-b1
Copy link
Contributor Author

@jreback - this should be good now, looks like most of the xfails will be fixed by #16301

@TomAugspurger
Copy link
Contributor

There was a failure in one job: https://travis-ci.org/pandas-dev/pandas/jobs/231516184#L2140 but that looks unrelated.

@jreback jreback merged commit 4cd8458 into pandas-dev:master May 12, 2017
@jreback
Copy link
Contributor

jreback commented May 12, 2017

thanks!

pcluo pushed a commit to pcluo/pandas that referenced this pull request May 22, 2017
* BUG: pathlib.Path in io

* CLN: factor out pathlib roundtrip

* add localpath tests for other io

* fixup

* xfail SAS; type in parser

* missing import

* xfail for pandas-dev#14704

* fix to_csv

* lint

* lint cleanup

* add feather (xfail)
TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this pull request May 29, 2017
* BUG: pathlib.Path in io

* CLN: factor out pathlib roundtrip

* add localpath tests for other io

* fixup

* xfail SAS; type in parser

* missing import

* xfail for pandas-dev#14704

* fix to_csv

* lint

* lint cleanup

* add feather (xfail)

(cherry picked from commit 4cd8458)
TomAugspurger pushed a commit that referenced this pull request May 30, 2017
* BUG: pathlib.Path in io

* CLN: factor out pathlib roundtrip

* add localpath tests for other io

* fixup

* xfail SAS; type in parser

* missing import

* xfail for #14704

* fix to_csv

* lint

* lint cleanup

* add feather (xfail)

(cherry picked from commit 4cd8458)
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
* BUG: pathlib.Path in io

* CLN: factor out pathlib roundtrip

* add localpath tests for other io

* fixup

* xfail SAS; type in parser

* missing import

* xfail for pandas-dev#14704

* fix to_csv

* lint

* lint cleanup

* add feather (xfail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Data IO issues that don't fit into a more specific label Regression Functionality that used to work in a prior pandas version
Projects
None yet
4 participants