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

some new features because south america #46

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

bhbraswell
Copy link

@bhbraswell bhbraswell commented Nov 20, 2019

  • shifttime.pyx module in case the season starts at a weird time

  • trimyr.pyx module because shifttime can result in a trailing useless year (also could consider an option to shifttime, but this seemed potentially useful

  • Modules can now change the number of years they output (nyrout), e.g. trimyr.pyx

  • Regex can now contain a group besides the date, but if so, they need to be labeled (backwards compatible), in our use case that group is used to handle data from different locations mixed in the same directory

Copy link
Contributor

@ra-tolson ra-tolson left a comment

Choose a reason for hiding this comment

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

I don't really understand mt so I feel weirdly unqualified to do code reviews. I mean, yeah, I ported the thing to python 3, but mostly that was an automated process wherein I ran some tests and didn't get into the internals much.

So this is more an advisory review, things I'd change even though I recognize my position of relative ignorance.

step['nout'] = step['nin']
try:
step['nyrout'] = int(mod.get_nyrout(step['nyrin'], step['params']))
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to catch a specific exception type for safety.

Optional: Also, exceptions that pass silently are pretty rare; consider emitting a message to the user even if you don't re-raise.

if 'nin' in step:
assert step['nin'] == thisnin, "Number of inputs do not match"
else:
step['nin'] = thisnin
if 'nyrin' in step:
assert step['nyrin'] == thisnyrin, "Number of years do not match"
Copy link
Contributor

Choose a reason for hiding this comment

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

What would happen if the user disabled assertions when running this? That's how to tell if it should be a raise ValueError instead.

# secret way to test
results = [func(jobs[-nproc-1])]
else:
raise Exception("nproc can't be zero")
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't Exception, this is ValueError. Never raise Exception; either pick a subtype or make a new one.



@pytest.mark.parametrize("nproc", [1, 2])
def test_passthrough2(nproc, tmpdir):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copypasta is bad. Extend the parametrization scheme instead so the existing test covers more cases.

Also, if you do, then test_passthrough2 is going away as a name, but know that it's a much better idea to name your tests verbosely so people can see what went wrong in test reports. Long, sloppy names aren't so bad for tests, eg, test_passthrough_this_time_with_weird_regex.

Copy link
Contributor

Choose a reason for hiding this comment

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

PS you can instead move some common code into a fixture and call it from both, if the two tests are different enough to warrant it.

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.

2 participants