Skip to content

valid_range fixes#40

Merged
Bobfrat merged 10 commits intoioos:masterfrom
benjwadams:valid_range_rebase
Oct 13, 2017
Merged

valid_range fixes#40
Bobfrat merged 10 commits intoioos:masterfrom
benjwadams:valid_range_rebase

Conversation

@benjwadams
Copy link
Copy Markdown
Contributor

No description provided.

Checks for valid_range. If it is not present, this is followed by valid_min
and valid_max check.  Implements ioos#38.
@benjwadams benjwadams requested a review from Bobfrat October 11, 2017 18:05
@ghost ghost assigned benjwadams Oct 11, 2017
self.base_check._check_min_max_range(var, tc2)
expected = ['{} attribute should exist, have the same type as pressure, and not be empty or valid_range should be defined'.format(v)
for v in ['valid_min', 'valid_max']]
self.assertEqual(expected, tc2.messages)
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.

Looking good. Can you add a docstring for these tests about the specific cases that are being tested?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do.

# otherwise compare the numpy types directly
else:
test_ctx.assert_true(v_bound.dtype == var.dtype, warn_msg)
return test_ctx
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just for readability and maintainability I think it would be better to see the two branches broken into individual methods.

if 'valid_range' in var.ncattrs():
    return self._check_valid_range_attr(var, test_ctx)
else:
    return self._check_valid_minmax(var, test_ctx)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The reason I did not do this is because it'd need that same boilerplate every time we wanted to check for {valid_range|valid_min,valid_max}.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since it appears 5 times in the ncei_base.py module, I prefer the function form.

Comment thread cc_plugin_ncei/ncei_base.py Outdated
test_ctx.assert_true(getattr(ncvar, 'valid_min', '') != '', 'valid_min should exist and not be empty')
test_ctx.assert_true(getattr(ncvar, 'valid_max', '') != '', 'valid_max should exist and not be empty')
test_ctx.assert_true(getattr(ncvar, 'valid_min', '') != '', 'valid_min should exist and not be empty or valid_range should be defined')
test_ctx.assert_true(getattr(ncvar, 'valid_max', '') != '', 'valid_max should exist and not be empty or valid_range should be defined')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this intentionally only run when ncvar does not have standard_name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops! I didn't realize there was this indent. I will fix that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This should actually be calling the function I defined instead.

@benjwadams
Copy link
Copy Markdown
Contributor Author

Conda stahp 🛑

@Bobfrat
Copy link
Copy Markdown
Contributor

Bobfrat commented Oct 13, 2017

@benjwadams @ocefpaf
Looks like its the python 3.4 tests that are failing. We removed them from the compliance-checker repo, can we do the same here?

ioos/compliance-checker#518

@ocefpaf
Copy link
Copy Markdown
Member

ocefpaf commented Oct 13, 2017

Safe to remove b/c that is package deps error and not a cc-plugin-ncei bug. Let me send a PR to fix that in a moment.

Comment thread .travis.yml
@@ -18,17 +18,16 @@ matrix:
env: TEST_TARGET=coding_standards

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Was necessary to add this to keep LXML from breaking due to a missing library. Might be worth looking at the latest LXML package in conda to see if it's an issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is certainly a bad dependency package on the conda side and we should not do that here.
I guess that is happening only with Python 3.4, which we dropped in #41, but if you do observe this in other Pythons then we should report it back to conda-forge.

@Bobfrat Bobfrat merged commit b89a5b5 into ioos:master Oct 13, 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.

4 participants