-
Notifications
You must be signed in to change notification settings - Fork 33
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
add tests for changes in tsutils #297
Conversation
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.
Nice, generally looks really good, just left a couple of minor comments
with pytest.warns(match='Time unit'): | ||
(datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='unknown') | ||
assert direction == 'prograde' | ||
|
||
with pytest.warns(match='Time unit'): | ||
(datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='age') | ||
assert direction == 'retrograde' |
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.
why not check datum
and exponent
too?
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.
Those are handled in the following tests (there is code following the time_name
bit that modifies datum
and exponent
). This test set is trying to exclusively look at the time_name
options and implications. There was no way to isolate it well, but its an attempt.
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.
@khider and I are confused about what this test does. Can you explain the goal?
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.
I think it's just to check what happens when some invalid time_unit
is passed
still though, I'd suggest adding
assert datum == 0
assert exponent == 0
, it's only 2 lines of code, makes it consistent with the code above, and the logic inside time_unit_to_datum_exp_dir
may well change someday such that time_name
also affects datum
and exponent
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.
The goal of any test suite is to hit 100% coverage. That means we want the test suite to go down every pathway - every if/else, raise etc.
So this test in particular checks to make sure we get the appropriate warning when
- time_unit is some unknown string, time_name is None
- time_unit is some unknown string, time_name is some unknown string
- time_unit is some unknown string, time_name is "age"
with pytest.warns(match='Time unit'): | ||
(datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='unknown') | ||
assert direction == 'prograde' | ||
|
||
with pytest.warns(match='Time unit'): | ||
(datum, exponent, direction) = tsutils.time_unit_to_datum_exp_dir(time_unit, time_name='age') | ||
assert direction == 'retrograde' |
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.
I think it's just to check what happens when some invalid time_unit
is passed
still though, I'd suggest adding
assert datum == 0
assert exponent == 0
, it's only 2 lines of code, makes it consistent with the code above, and the logic inside time_unit_to_datum_exp_dir
may well change someday such that time_name
also affects datum
and exponent
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.
Looks good to me, over to USC
This is stretching my Python knowledge a bit (I'd never heard of frozen sets), but it generally looks good. However, I decided to streamline BTW, @khider pointed out that those conversion functions should be in tsbase.py, not tsutils.py, see #299. When do you think it safest to move them over? |
Specifically, I removed the if/then statement having to do with |
Sorry if the back&forth makes things difficult for your test-writing ; I don't always see the whole picture when I'm writing the code, but this gave me the opportunity to think about it more, hence the changes. |
The way its currently written (can't remember who coded this), it will warn if it doesn't match the input
So "years BP" must be input as time_unit of one of these: |
The way I wrote it, ['yr BP', 'yrs BP', 'years BP'] will be caught by the clause |
Hi @kcpevey , I starting debugging the merge from 'new_objects' into Development and found a few bugs in the way I cast the logical net over "time_units". My latest commit (in a new branch, see a1fa119) makes it explicit that the |
I'd like @CommonClimate or @khider to review the expected values in the tests to ensure that things are working as expected.