8000 BUG: Fix f2py derived types in modules by charris · Pull Request #29044 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fix f2py derived types in modules #29044

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 3 commits into from
May 23, 2025
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
Prev Previous commit
Next Next commit
TST: tests for modules with derived types
  • Loading branch information
zoghbi-a authored and charris committed May 23, 2025
commit 6208252e941dba3acdf274464e8a5266e3f1d1ab
23 changes: 23 additions & 0 deletions numpy/f2py/tests/src/regression/mod_derived_types.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module mtypes
implicit none
integer, parameter :: value1 = 100
type :: master_data
integer :: idat = 200
end type master_data
type(master_data) :: masterdata
end module mtypes


subroutine no_type_subroutine(ain, aout)
use mtypes, only: value1
integer, intent(in) :: ain
integer, intent(out) :: aout
aout = ain + value1
end subroutine no_type_subroutine

subroutine type_subroutine(ain, aout)
use mtypes, only: masterdata
integer, intent(in) :: ain
integer, intent(out) :: aout
aout = ain + masterdata%idat
end subroutine type_subroutine
10 changes: 10 additions & 0 deletions numpy/f2py/tests/test_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def test_mdat(self):
assert self.module.simple_subroutine(5) == 1014


class TestModuleWithDerivedType(util.F2PyTest):
# Check that modules with derived types work
sources = [util.getpath("tests", "src", "regression", "mod_derived_types.f90")]

@pytest.mark.slow
def test_mtypes(self):
assert self.module.no_type_subroutine(10) == 110
assert self.module.type_subroutine(10) == 210


class TestNegativeBounds(util.F2PyTest):
# Check that negative bounds work correctly
sources = [util.getpath("tests", "src", "negative_bounds", "issue_20853.f90")]
Expand Down
0