Skip to content

Suggest non-existing default filename (Implement #3608) - #4221

Merged
tacaswell merged 6 commits into
matplotlib:masterfrom
umairidris:default_filename
Mar 17, 2015
Merged

tacaswell merged 6 commits into
matplotlib:masterfrom
umairidris:default_filename

Conversation

@umairidris

Copy link
Copy Markdown

No description provided.

@umairidris umairidris changed the title Suggest unexisting default filename (Implement #3608) Suggest non-existing default filename (Implement #3608) Mar 15, 2015
@tacaswell tacaswell added this to the next point release milestone Mar 15, 2015
Comment thread lib/matplotlib/backend_bases.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't use this type of string formatting. It was introduced in py2.7 and we support py2.6. You will need "{0}-{1}.{2}" instead.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the catch! It has been fixed via 4da2db8.

@tacaswell

Copy link
Copy Markdown
Member

Can you also add a test? I would suggest something like

import tempfile
@cleanup
def test_filename():
    test_dir = tempfile.mkdtemp()
    rcParams['saving.directory'] = test_dir
    target_name = os.path.join(test_dir, 'figure_1.png')
    target_name2 = os.path.join(test_dir, 'figure_1-1.png')
    fig = plt.figure()
    fn = fig.get_default_filename()
    assert_equal(fn, target_name)
    fig.save_fig(fn)
    fn2 = fig.get_default_filename()
    assert_equal(fn2, target_name2)

@umairidris

Copy link
Copy Markdown
Author

Done. Should the created temp directories/files be cleaned up after the test? From Python docs: "The user of mkdtemp() is responsible for deleting the temporary directory and its contents when done with it."

@tacaswell

Copy link
Copy Markdown
Member

Yes please to cleaning up the temp directory.

On Mon, Mar 16, 2015, 05:13 Umair Idris notifications@github.com wrote:

Done. Should the created temp directoies/files be cleaned up after the
test? From Python docs: "The user of mkdtemp() is responsible for deleting
the temporary directory and its contents when done with it."

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

@umairidris

Copy link
Copy Markdown
Author

Yes please to cleaning up the temp directory.

Done.

tacaswell added a commit that referenced this pull request Mar 17, 2015
ENH : Suggest non-existing default filename in gui save window

closes #3608
@tacaswell
tacaswell merged commit 51576d4 into matplotlib:master Mar 17, 2015
@tacaswell

Copy link
Copy Markdown
Member

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants