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

[MRG] make cell_response.write more robust #456

Merged
merged 4 commits into from Jan 24, 2022

Conversation

jasmainak
Copy link
Collaborator

I was just trying to use this with Michael Hines and realized that it throws an error for a regular string. I think it should instead append the trial index instead of throwing an error.

@jasmainak jasmainak changed the title make cell_response.write more robust [MRG] make cell_response.write more robust Jan 13, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2022

Codecov Report

Merging #456 (cd14470) into master (ad06968) will decrease coverage by 0.01%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #456      +/-   ##
==========================================
- Coverage   88.51%   88.49%   -0.02%     
==========================================
  Files          18       18              
  Lines        3316     3329      +13     
==========================================
+ Hits         2935     2946      +11     
- Misses        381      383       +2     
Impacted Files Coverage Δ
hnn_core/cell_response.py 84.53% <85.71%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad06968...cd14470. Read the comment docs.

@jasmainak
Copy link
Collaborator Author

any reviews or comments @cjayb @ntolley @rythorpe ?

Comment on lines +379 to +382
String format (e.g., 'spk_%d.txt' or 'spk_{0}.txt') of the
path to the output spike file(s). If no string format
is provided, the trial index will be automatically
appended to the file name.
Copy link
Contributor

Choose a reason for hiding this comment

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

So it is now impossible for a user to specify a filename without a trial number contained somewhere in it? I get that this prevents the user from accidentally overwriting multiples trials, however, I'm not sure how I feel about automatically modifying user input. Feel free to override this opinion as I see a valid argument either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was not possible before this PR also. This PR just automatically appends a trial number if the user doesn't specify it. Other option is to throw an explicit error (as opposed to the cryptic error we get now) if the user provides a filename without a format specifier when there are multiple trials.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm leaning towards the explicit error being best. Especially since you're writing the full file name 'blah.txt' as opposed to a generic name with no '.txt'at the end.

I think it'd be ok if the user use provided 'filenamehere' and then the '_1.txt' was appended automatically.

Copy link
Contributor

@rythorpe rythorpe left a comment

Choose a reason for hiding this comment

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

Pending resolution of my one minor comment above, let's merge!

@jasmainak
Copy link
Collaborator Author

I made the writing more verbose to not surprise the user: cd14470

Let me know if you're fine with this @rythorpe or you prefer the other option

@@ -44,6 +44,8 @@ def test_cell_response(tmpdir):
empty_spike = CellResponse(spike_times=[[], []], spike_gids=[[], []],
spike_types=[[], []])
empty_spike.write(tmpdir.join('empty_spk_%d.txt'))
empty_spike.write(tmpdir.join('empty_spk.txt'))
empty_spike.write(tmpdir.join('empty_spk_{0}.txt'))
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this overwrite the files? Then L49 is only testing the previous line

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah the others are smoke tests

@rythorpe
Copy link
Contributor

I made the writing more verbose to not surprise the user: cd14470

Let me know if you're fine with this @rythorpe or you prefer the other option

This is a good solution, thanks @jasmainak!

@rythorpe rythorpe merged commit 1d2df73 into jonescompneurolab:master Jan 24, 2022
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.

None yet

4 participants