-
Notifications
You must be signed in to change notification settings - Fork 0
What a dummy argument may say: local-parameter bounds, lower bounds, generics, where masks, elementwise logicals #25
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
base: constant-intrinsics
Are you sure you want to change the base?
Changes from all commits
b0162e8
349106a
db9f255
6af10a1
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 |
|---|---|---|
|
|
@@ -352,7 +352,9 @@ def binary(self, left: Any, operator: str, right: Any) -> str: | |
| return self._comparison(spelling, left, right, rendered_left, rendered_right) | ||
|
|
||
| if spelling in LOGICAL_OPS: | ||
| if self.vector_boolean and spelling in (".AND.", ".OR."): | ||
| if spelling in (".AND.", ".OR.") and ( | ||
| self.vector_boolean or self._array_valued(left) or self._array_valued(right) | ||
| ): | ||
| return f"({rendered_left} {'&' if spelling == '.AND.' else '|'} {rendered_right})" | ||
| return f"({rendered_left} {LOGICAL_OPS[spelling]} {rendered_right})" | ||
|
|
||
|
|
@@ -409,10 +411,21 @@ def _not(self, node: Any) -> str: | |
| operator, operand = node.children | ||
| if str(operator).upper() != ".NOT.": | ||
| raise NoRule(f"unary logical operator {operator}") | ||
| if self.vector_boolean: | ||
| if self.vector_boolean or self._array_valued(operand): | ||
| return f"(~({self.render(operand)}))" | ||
| return f"(not {self.render(operand)})" | ||
|
|
||
| def _array_valued(self, node: Any) -> bool: | ||
| """Whether a logical operand is an array, so ``.NOT.`` / ``.AND.`` / | ||
| ``.OR.`` have to be elementwise -- ``any( .not. l_valid )`` over | ||
| ``logical, dimension(nz) :: l_valid`` (CLUBB's new_pdf), outside any | ||
| WHERE. Python's ``not`` on an array raises; ``~`` is the operator. | ||
| Unsettled ranks fall back to the scalar spelling, as before.""" | ||
| try: | ||
| return self.semantics.rank(node) > 0 | ||
| except Exception: # rank refuses what it cannot settle | ||
|
Member
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. Swallowing |
||
| return False | ||
|
|
||
| # -- references ----------------------------------------------------------- | ||
|
|
||
| def reference(self, node: Any) -> str: | ||
|
|
||
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.
Only a bare name folds, so
dimension(-nd:nd, ...)becomes{"lb": "- nd", "ub": "3"}; the new test'slhsassertion documents exactly this and its comment says the leftover is "the wrapper's to refuse", but nothing refuses it:f2py.py::_extentspells- nd:3into the wrapper verbatim (gfortran undeclared-symbol build failure, not an engine refusal) and bitexact.py harvestsndfrom the lb text as a free extent to redraw.-n:nis common Fortran (stencils, band matrices). Not a regression against main, but the description's "folded to the value" is half true for symmetric bounds. Suggest folding a negated name too, or refusing when one bound of an axis folded and the other did not.