8000 BUG: Changed dump(a, F) so it would close file by orbit-stabilizer · Pull Request #10055 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Changed dump(a, F) so it would close file #10055

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 4 commits into from
Nov 20, 2017
Merged

BUG: Changed dump(a, F) so it would close file #10055

merged 4 commits into from
Nov 20, 2017

Conversation

orbit-stabilizer
Copy link
Contributor

See #10045

numpy/ma/core.py Outdated
with open (F, 'w') as F:
pickle.dump(a, F)
else:
pickle.dump(a, F)
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: 4-space indents, please.

There are other functions in this module that need the same fix, if you're going to fix this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, my bad.

I will fix any others I find.

I see now that I should have 'wb' instead of just 'w', as per #5491. Is there a way for me to change this without creating another pull request?

Copy link
Member

Choose a reason for hiding this comment

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

Leave the wb to a different PR - it's a separate problem, and I don't think we should fix it anyway.

Copy link
Member
@eric-wieser eric-wieser Nov 19, 2017

Choose a reason for hiding this comment

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

Is there a way for me to change this without creating another pull request?

I assume you're editing in the github web UI? You can navigate to your branch, and hit the edit button on the files there. It'll create a new commit, but we can squash them all together when you're done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't see your replies to this comment before I changed the wb. Yes, I'm using the Github web UI - I think I got it to work, thanks!

@eric-wieser
Copy link
Member

Commit message should start with BUG: too

@orbit-stabilizer
Copy link
Contributor Author

@eric-wieser Sorry, I will make sure they start with BUG: next time.

@eric-wieser
Copy link
Member

No worries, we can correct the prefix when we merge - I just pointed it out since I was expecting you to amend the commit to fixup np.ma.load as well, and it's easy to change it at the same time.

@eric-wieser
Copy link
Member

As an aside, you should avoid creating PRs from master in future too, since that makes it too tempting for you to commit unrelated stuff to it that ends up as part of this PR.

@orbit-stabilizer
Copy link
Contributor Author
orbit-stabilizer commented Nov 19, 2017

Oh, I didn't realize I could update this pull request. I can fix load and change 'w' to 'wb' now. Also, should the 'r' be changed to an 'rb'? I'm looking at this answer - but I do not know if we want a str or a byte object - or if encoding even matters.

Ah, I thought I had to create a personal repo since I can't directly modify the master branch. How else should I do it?

@eric-wieser
Copy link
Member
eric-wieser commented Nov 19, 2017

You did have to create a personal repo, but you also should have created a branch within that repo. Don't worry about it, you're fine as long as you don't do the same thing again to make another PR before this one is merged.

I've backed out the wb change and fixed your spacing, but otherwise looks good. You're correct that the fix to #5491 would require rb as well, but lets not fix that here.

@orbit-stabilizer
Copy link
Contributor Author
orbit-stabilizer commented Nov 20, 2017

I think I understand. After forking the repo, I should have created a branch within that repo. But after completing some edits, should I commit to my own master branch and then create a pull request or should I commit to my non-master branch and then create a pull request from that? And should the branch name correspond to the problem I'm fixing?

Sounds good. Why were some checks not successful for your commit? All you did was remove some whitespace and change wb to w.

@eric-wieser
Copy link
Member

Why were some checks not successful for your commit?

They were cancelled because I made a second commit.

@charris
Copy link
Member
charris commented Nov 20, 2017

You should make the PR from the branch by pushing the branch to your github repo, then making the PR from there.

@eric-wieser eric-wieser merged commit eac6056 into numpy:master Nov 20, 2017
@njsmith
Copy link
Member
njsmith commented Nov 20, 2017

@orbit-stabilizer You only have one personal fork of numpy, and your fork only has one master branch. So the problem happens if you ever want to submit two different PRs at the same time: how can you do that if they both need to change your fork's master branch? This is tricky because often people don't realize that they'll want to open a second PR at the time when you're opening the first one. Or... what if you submit a PR, and then it gets rejected. Now your master branch doesn't match numpy's master branch, so you have to somehow clean it up before you can make new PRs. So the general advice is to make your changes in your own branch inside your own fork, and then submit a PR from that; that way you won't get caught by surprise by one of these tricky issues later.

@orbit-stabilizer
Copy link
Contributor Author

Thanks for all of the help!

@njsmith Oh, that makes a lot of sense. Then I suppose I should merge my branches with my master branch each time my PR goes through and I should create a new branch for each new issue.

@eric-wieser
Copy link
Member
eric-wieser commented Nov 20, 2017

In practice, there're only three things worth doing with your numpy master branch - either:

  • Deleting it entirely, since it's not useful
  • Sync it up with numpy/master whenever you can
  • Use it if you need a version of numpy with all of your PRs merged, if upstream we're being too slow at merging them

Thanks for the patch, @orbit-stabilizer!

@charris
Copy link
Member
charris commented Nov 20, 2017

@orbit-stabilizer The development reference is at https://docs.scipy.org/doc/numpy-1.13.0/dev/gitwash/development_workflow.html. The recommended workflow varies among projects, but that manual also works for scipy.

@orbit-stabilizer
Copy link
Contributor Author

@eric-wieser Perfect, thank you.
@charris Thanks for the link, I'll make sure to follow the steps.

with open(F, 'r') as F:
pickle.load(F)
else:
pickle.load(F)
Copy link
Member

Choose a reason for hiding this comment

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

This is a regression - there needs to be a return here

Copy link
Member

Choose a reason for hiding this comment

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

eric-wieser added a commit to eric-wieser/numpy that referenced this pull request Dec 10, 2017
charris added a commit that referenced this pull request Dec 10, 2017
charris added a commit that referenced this pull request Dec 11, 2017
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.

5 participants
0