Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: Fix f2py directives and --lower casing #28056

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

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion 7 numpy/f2py/auxfuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
'hasexternals', 'hasinitvalue', 'hasnote', 'hasresultnote',
'isallocatable', 'isarray', 'isarrayofstrings',
'ischaracter', 'ischaracterarray', 'ischaracter_or_characterarray',
'iscomplex',
'iscomplex', 'iscstyledirective',
'iscomplexarray', 'iscomplexfunction', 'iscomplexfunction_warn',
'isdouble', 'isdummyroutine', 'isexternal', 'isfunction',
'isfunction_wrap', 'isint1', 'isint1array', 'isinteger', 'isintent_aux',
Expand Down Expand Up @@ -423,6 +423,11 @@ def isrequired(var):
return not isoptional(var) and isintent_nothide(var)


def iscstyledirective(f2py_line):
directives = {"callstatement", "callprotoargument", "pymethoddef"}
return any(directive in f2py_line.lower() for directive in directives)


def isintent_in(var):
if 'intent' not in var:
return 1
Expand Down
8 changes: 3 additions & 5 deletions 8 numpy/f2py/crackfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,9 @@ def readfortrancode(ffile, dowithline=show, istop=1):
origfinalline = ''
else:
if localdolowercase:
# lines with intent() should be lowered otherwise
# TestString::test_char fails due to mixed case
# f2py directives without intent() should be left untouched
# gh-2547, gh-27697, gh-26681
finalline = ll.lower() if "intent" in ll.lower() or not is_f2py_directive else ll
# only skip lowering for C style constructs
# gh-2547, gh-27697, gh-26681, gh-28014
finalline = ll.lower() if not (is_f2py_directive and iscstyledirective(ll)) else ll
else:
finalline = ll
origfinalline = ll
Expand Down
5 changes: 5 additions & 0 deletions 5 numpy/f2py/tests/src/regression/lower_f2py_fortran.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
subroutine inquire_next(IU)
IMPLICIT NONE
integer :: IU
!f2py intent(in) IU
end subroutine
9 changes: 9 additions & 0 deletions 9 numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ def test_gh26148b(self):
assert res[0] == 8
assert res[1] == 15

class TestLowerF2PYDirectives(util.F2PyTest):
# Check variables are cased correctly
sources = [util.getpath("tests", "src", "regression", "lower_f2py_fortran.f90")]

@pytest.mark.slow
def test_gh28014(self):
self.module.inquire_next(3)
assert True

@pytest.mark.slow
def test_gh26623():
# Including libraries with . should not generate an incorrect meson.build
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.