-
Notifications
You must be signed in to change notification settings - Fork 67
Throw clearer error message when integer dimension indices are present; remove known ddt case sensitivity #662
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
Changes from 2 commits
2d1761c
f28b5d6
6e7098d
faff223
4f7230d
17442fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -101,7 +101,13 @@ def check_dimensions(test_val, prop_dict, error, max_len=0): | |||||
| >>> check_dimensions("hi_mom", None, True) #doctest: +IGNORE_EXCEPTION_DETAIL | ||||||
| Traceback (most recent call last): | ||||||
| CCPPError: 'hi_mom' is invalid; not a list | ||||||
| >>> check_dimensions(["1:dim1", "dim2name"], None, True) #doctest: +IGNORE_EXCEPTION_DETAIL | ||||||
| Traceback (most recent call last): | ||||||
| CCPPError: '1:dim1 is an invalid dimension name; integer dimension indices not supported | ||||||
| >>> check_dimensions(["ccpp_constant_one:1", "dim2name"], None, True) | ||||||
| ['ccpp_constant_one:1', 'dim2name'] | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this okay? Isn't
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a valid question! The problem I ran into is that sometimes the parse checker is called after the "ccpp_constant_one:" is prepended to the integer dimension (which I believe we're allowing) and sometimes it's called before. So, the metadata could specify I thought about diving deeper into figuring out what the specifics were of when we're calling what, but decided that
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is what is confusing: If "integer dimension indices not supported", how is the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically, it's only ok if you do As for when we started allowing integer sizes, i believe @dustinswales brought that in recently for his work in SCM - #652 |
||||||
| """ | ||||||
| info_msg = None | ||||||
| if not isinstance(test_val, list): | ||||||
| if error: | ||||||
| raise CCPPError("'{}' is invalid; not a list".format(test_val)) | ||||||
|
|
@@ -123,10 +129,24 @@ def check_dimensions(test_val, prop_dict, error, max_len=0): | |||||
| # end if | ||||||
| # Check possible dim styles (a, a:b, a:, :b, :, ::, a:b:c, a::c) | ||||||
| tdims = [x.strip() for x in isplit if len(x) > 0] | ||||||
| starts_at_one = False | ||||||
| if len(tdims) > 0 and tdims[0] == 'ccpp_constant_one': | ||||||
| starts_at_one = True | ||||||
| # end if | ||||||
| is_int = False | ||||||
| for tdim in tdims: | ||||||
| # Check numeric value first | ||||||
| try: | ||||||
| valid = isinstance(int(tdim), int) | ||||||
| is_int = isinstance(int(tdim), int) | ||||||
| # Allow integer dimensions, but not indices | ||||||
| if is_int: | ||||||
| valid = starts_at_one or len(tdims) == 1 | ||||||
| if not valid: | ||||||
| info_msg = 'integer dimension indices not supported' | ||||||
| # end if | ||||||
| else: | ||||||
| valid = False | ||||||
| # end if | ||||||
| except ValueError as ve: | ||||||
| # Not an integer, try a Fortran ID | ||||||
| valid = check_fortran_id(tdim, None, | ||||||
|
|
@@ -147,8 +167,12 @@ def check_dimensions(test_val, prop_dict, error, max_len=0): | |||||
| # End try | ||||||
| if not valid: | ||||||
| if error: | ||||||
| errmsg = "'{}' is an invalid dimension name" | ||||||
| raise CCPPError(errmsg.format(item)) | ||||||
| if info_msg: | ||||||
| errmsg = f"'{item} is an invalid dimension name; {info_msg}" | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good catch! fixed! |
||||||
| else: | ||||||
| errmsg = f"'{item}' is an invalid dimension name" | ||||||
| # end if | ||||||
| raise CCPPError(errmsg) | ||||||
| else: | ||||||
| test_val = None | ||||||
| # end if | ||||||
|
|
||||||
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.
Does this work if
self.__line_max == 132(Fortran maximum)?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.
Looking into this more, I'm going to back this out and open an issue because it's more complicated than I thought (as you've noticed).
Due to quotation marks and indenting, when a standard name is
line_continue = outstr[best+1:].lstrip()[0] != '!'ccpp_physics_suite_variablestries to split the standard name string like: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.
Is that not okay? I thought that is how you were supposed to split a character context across lines.
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.
oh! well, then, I suppose we're good on that front. i'm showing my fortran ignorance! so it's just the first issue that i'll look into a bit more tomorrow.
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.
Thanks again @gold2718
I took another stab at fixing the issue where the line is exactly equal to the max line length and doesn't need to be continued. If you have other ideas on how to fix it, I'm all ears!