Skip to content
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

Make "copy" work better with numpy arrays #2577

Merged
merged 3 commits into from
Oct 7, 2015

Conversation

da-woods
Copy link

@da-woods da-woods commented Aug 1, 2015

Previously, if you go to variable explorer, right clicked
on a (large) numpy array and clicked copy if copied in the form
[[1.0, 2.0 ... 3.0 ]] (i.e. with dots in place of the middle
of the array)

Now it copies the whole array with as a tab separated string.
This is more useful since you can paste directly into Spyder
or into a spreadsheet, and no data is omitted.

The downside is that the clipboard can get quite large

Previously, if you go to variable explorer, right clicked
on a (large) numpy array and clicked copy if copied in the form
[[1.0, 2.0 ... 3.0 ]] (i.e. with dots in place of the middle
of the array)

Now it copies the whole array with as a tab separated string.
This is more useful since you can paste directly into Spyder
or into a spreadsheet, and no data is omitted.

The downside is that the clipboard can get quite large
@da-woods
Copy link
Author

da-woods commented Aug 1, 2015

I have one additional issue with copying arrays from Spyder (under slightly different circumstances) that I'd like to fix, but it's a bit more complicated, so will have have to wait. It'll come under a different pull request I think.

@goanpeca
Copy link
Member

goanpeca commented Aug 1, 2015

Thanks @da-woods :-)

@@ -48,7 +48,8 @@
from spyderlib.widgets.texteditor import TextEditor
from spyderlib.widgets.importwizard import ImportWizard
from spyderlib.py3compat import (to_text_string, to_binary_string,
is_text_string, is_binary_string, getcwd, u)
is_text_string, is_binary_string, getcwd, u,
PY3,io)
Copy link
Member

Choose a reason for hiding this comment

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

Can you add an space between io and PY3 ?

@da-woods
Copy link
Author

da-woods commented Aug 1, 2015

It should be a bit tidier now.

output = io.BytesIO()
else:
output = io.StringIO()
np.savetxt(output,obj, delimiter='\t')
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a space after the coma.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

@Nodd
Copy link
Contributor

Nodd commented Sep 23, 2015

That was just a quick code style review, I didn't check the functionality.

else:
output = io.StringIO()
np.savetxt(output, obj, delimiter='\t')
obj = output.getvalue().decode('utf-8')
Copy link
Member

Choose a reason for hiding this comment

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

This line is not needed. That's why you're using to_text_string below.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, forget my comment, this is really necessary :-)

@ccordoba12
Copy link
Member

Thanks a lot for your work @da-woods! I'm going to merge it as it is because I need it for other improvements I've done to the Variable Explorer.

ccordoba12 added a commit that referenced this pull request Oct 7, 2015
Make "copy" work better with numpy arrays
@ccordoba12 ccordoba12 merged commit 520321b into spyder-ide:master Oct 7, 2015
ccordoba12 added a commit to ccordoba12/spyder that referenced this pull request Oct 7, 2015
ccordoba12 added a commit to ccordoba12/spyder that referenced this pull request Oct 7, 2015
@da-woods da-woods deleted the copy1 branch October 8, 2015 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants