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 multiple modules in F2PY and COMMON handling #27780

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
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
TST: Multiple modules in single pyf for gh-27622
  • Loading branch information
HaoZeke authored and charris committed Nov 17, 2024
commit 9ab12dcbce38a06f16e54c82f00baef4e5e9f7dc
5 changes: 5 additions & 0 deletions 5 doc/release/upcoming_changes/27695.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
``f2py`` handles multiple modules and exposes variables again
-------------------------------------------------------------
A regression has been fixed which allows F2PY users to expose variables to
Python in modules with only assignments, and also fixes situations where
multiple modules are present within a single source file.
17 changes: 17 additions & 0 deletions 17 numpy/f2py/tests/src/regression/datonly.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module datonly
implicit none
integer, parameter :: max_value = 100
real, dimension(:), allocatable :: data_array
end module datonly

module dat
implicit none
integer, parameter :: max_= 1009
end module dat

subroutine simple_subroutine(ain, aout)
use dat, only: max_
integer, intent(in) :: ain
integer, intent(out) :: aout
aout = ain + max_
end subroutine simple_subroutine
12 changes: 12 additions & 0 deletions 12 numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ def test_inout(self):
assert np.allclose(x, [3, 1, 2])


class TestDataOnlyMultiModule(util.F2PyTest):
# Check that modules without subroutines work
sources = [util.getpath("tests", "src", "regression", "datonly.f90")]

@pytest.mark.slow
def test_mdat(self):
assert self.module.datonly.max_value == 100
assert self.module.dat.max_ == 1009
int_in = 5
assert self.module.simple_subroutine(5) == 1014


class TestNegativeBounds(util.F2PyTest):
# Check that negative bounds work correctly
sources = [util.getpath("tests", "src", "negative_bounds", "issue_20853.f90")]
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.