Skip to content

Accepting pathlib.Path as path inputs? #5968

Closed

Description

@michaelaye

pandas recently made the great effort to accept pathlib.Paths as inputs where traditionally strings would have to be provided for any path related requirements. Could this be done also for matplotlib?

Activity

  1. added this to the milestone on Feb 4, 2016
  2. WeatherGod commented on Feb 5, 2016

    @WeatherGod
    Member

    We don't do much in the way of path manipulations, and we do need to be
    compatible with the various backends we use, so internally, I don't see us
    using anything else but strings. That said, it is probably feasible to make
    sure that we cast those objects into strings.

    On Thu, Feb 4, 2016 at 4:42 PM, K.-Michael Aye notifications@github.com
    wrote:

    pandas recently made the great effort to accept pathlib.Paths as inputs
    where traditionally strings would have to be provided for any path related
    requirements. Could this be done also for matplotlib?

    —
    Reply to this email directly or view it on GitHub
    #5968.

  3. michaelaye commented on Feb 5, 2016

    @michaelaye
    Author

    That was all I was dreaming of so that I don't have to do the casting all the time! ;)

  4. WeatherGod commented on Feb 5, 2016

    @WeatherGod
    Member

    If you can come up with a list of functions that will need to do this
    casting, that would be a huge step towards getting a PR together.

    On Fri, Feb 5, 2016 at 2:55 PM, K.-Michael Aye notifications@github.com
    wrote:

    That was all I was dreaming of so that I don't have to do the casting all
    the time! ;)

    —
    Reply to this email directly or view it on GitHub
    #5968 (comment)
    .

  5. michaelaye commented on Feb 5, 2016

    @michaelaye
    Author

    I will, just not this month, which looks like the busiest of my life… ;)

    On Feb 5, 2016, at 13:03, Benjamin Root notifications@github.com wrote:

    If you can come up with a list of functions that will need to do this
    casting, that would be a huge step towards getting a PR together.

    On Fri, Feb 5, 2016 at 2:55 PM, K.-Michael Aye notifications@github.com
    wrote:

    That was all I was dreaming of so that I don't have to do the casting all
    the time! ;)

    —
    Reply to this email directly or view it on GitHub
    #5968 (comment)
    .

    —
    Reply to this email directly or view it on GitHub #5968 (comment).

  6. aragilar commented on Jun 5, 2016

    @aragilar
    Contributor

    It's worth noting that there's now a path protocol outlined in https://www.python.org/dev/peps/pep-0519/. Using it you call os.fspath on a path to get a string/bytes view of the path, and the function is easy enough to backport (I've done this for h5py already). I'll try to submit a pull request in the next few days which adds this, should it be against master, or would this be small enough to the maintenance branches?

  7. tacaswell commented on Jun 5, 2016

    @tacaswell
    Member

    Please target it at 2.x.

  8. modified the milestones: , on Oct 3, 2017
  9. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Jan 10, 2018
  10. anntzer commented on Jan 22, 2018

    @anntzer
    Contributor

    Closed by #10231.

  11. modified the milestones: , v2.2.0 on Feb 12, 2018
  12. LukeIreland1 commented on Mar 12, 2020

    @LukeIreland1

    I think this has regressed? I'm getting ValueError: fname must be a PathLike or file handle with plt.savefig(Path("fitness/fitness1.png")) works with plt.savefig(str(Path("fitness/fitness1.png")))

  13. tacaswell commented on Mar 12, 2020

    @tacaswell
    Member

    @LukeIreland1 Please open a new issue with your version details etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    New featureRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions