Skip to content

some new features because south america#46

Open
bhbraswell wants to merge 1 commit intoApplied-GeoSolutions:devfrom
indigo-ag:south-amer
Open

some new features because south america#46
bhbraswell wants to merge 1 commit intoApplied-GeoSolutions:devfrom
indigo-ag:south-amer

Conversation

@bhbraswell
Copy link
Copy Markdown

@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

@bhbraswell bhbraswell requested a review from ra-tolson November 20, 2019 03:04
Copy link
Copy Markdown
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.

Comment thread multitemporal/mt.py
step['nout'] = step['nin']
try:
step['nyrout'] = int(mod.get_nyrout(step['nyrin'], step['params']))
except:
Copy link
Copy Markdown
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.

Comment thread multitemporal/mt.py
else:
step['nin'] = thisnin
if 'nyrin' in step:
assert step['nyrin'] == thisnyrin, "Number of years do not match"
Copy link
Copy Markdown
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.

Comment thread multitemporal/mt.py
# secret way to test
results = [func(jobs[-nproc-1])]
else:
raise Exception("nproc can't be zero")
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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