m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

6 months ago
  1. from numpy.distutils.from_template import process_str
  2. from numpy.testing import assert_equal
  3. pyf_src = """
  4. python module foo
  5. <_rd=real,double precision>
  6. interface
  7. subroutine <s,d>foosub(tol)
  8. <_rd>, intent(in,out) :: tol
  9. end subroutine <s,d>foosub
  10. end interface
  11. end python module foo
  12. """
  13. expected_pyf = """
  14. python module foo
  15. interface
  16. subroutine sfoosub(tol)
  17. real, intent(in,out) :: tol
  18. end subroutine sfoosub
  19. subroutine dfoosub(tol)
  20. double precision, intent(in,out) :: tol
  21. end subroutine dfoosub
  22. end interface
  23. end python module foo
  24. """
  25. def normalize_whitespace(s):
  26. """
  27. Remove leading and trailing whitespace, and convert internal
  28. stretches of whitespace to a single space.
  29. """
  30. return ' '.join(s.split())
  31. def test_from_template():
  32. """Regression test for gh-10712."""
  33. pyf = process_str(pyf_src)
  34. normalized_pyf = normalize_whitespace(pyf)
  35. normalized_expected_pyf = normalize_whitespace(expected_pyf)
  36. assert_equal(normalized_pyf, normalized_expected_pyf)