-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
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
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. |
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) |
There was a problem hiding this comment.
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 ?
It should be a bit tidier now. |
output = io.BytesIO() | ||
else: | ||
output = io.StringIO() | ||
np.savetxt(output,obj, delimiter='\t') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
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') |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :-)
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. |
Make "copy" work better with numpy arrays
This is a follow up to PR spyder-ide#2577
…t is not numeric This is a simple fix after PR spyder-ide#2577
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 middleof 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