Skip to content
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

Fix template parameters in method default args #5

Closed
kwabenantim opened this issue Feb 2, 2024 · 1 comment · Fixed by #40
Closed

Fix template parameters in method default args #5

kwabenantim opened this issue Feb 2, 2024 · 1 comment · Fixed by #40
Assignees
Labels

Comments

@kwabenantim
Copy link
Member

Description

Template parameters are not correctly handled in some cases e.g.

.def(
"SetUpBoxCollection", 
(void(PeriodicNodesOnlyMesh3::*)(double, ::boost::numeric::ublas::c_vector<double, 6>, int, ::boost::numeric::ublas::c_vector<bool, 3>)) &PeriodicNodesOnlyMesh3::SetUpBoxCollection, " " , 
py::arg("cutOffLength"), 
py::arg("domainSize"), 
py::arg("numLocalRows") = -1, 
py::arg("isDimPeriodic") = zero_vector<bool(PeriodicNodesOnlyMesh::SPACE_DIM) )

should be instead (SPACE_DIM should be replaced):

.def(
"SetUpBoxCollection", 
(void(PeriodicNodesOnlyMesh3::*)(double, ::boost::numeric::ublas::c_vector<double, 6>, int, ::boost::numeric::ublas::c_vector<bool, 3>)) &PeriodicNodesOnlyMesh3::SetUpBoxCollection, " " , 
py::arg("cutOffLength"), 
py::arg("domainSize"), 
py::arg("numLocalRows") = -1, 
py::arg("isDimPeriodic") = zero_vector<bool>(3) )

Compile Error

~/Chaste/projects/PyChaste/dynamic/wrappers/mesh/PeriodicNodesOnlyMesh2.cppwg.cpp: In function ‘void register_PeriodicNodesOnlyMesh2_class(pybind11::module&)’:
~/Chaste/projects/PyChaste/dynamic/wrappers/mesh/PeriodicNodesOnlyMesh2.cppwg.cpp:78:141: error: expected primary-expression before ‘(’ token
   78 | g("domainSize"), py::arg("numLocalRows") = -1, py::arg("isDimPeriodic") = zero_vector<bool>(PeriodicNodesOnlyMesh::SPACE_DIM) )
      |                                                                                            ^

~/Chaste/projects/PyChaste/dynamic/wrappers/mesh/PeriodicNodesOnlyMesh2.cppwg.cpp:78:142: error: ‘template<unsigned int SPACE_DIM> class PeriodicNodesOnlyMesh’ used without template arguments
   78 | ("domainSize"), py::arg("numLocalRows") = -1, py::arg("isDimPeriodic") = zero_vector<bool>(PeriodicNodesOnlyMesh::SPACE_DIM) )
      |                                                                                            ^~~~~~~~~~~~~~~~~~~~~
@kwabenantim
Copy link
Member Author

kwabenantim commented Mar 20, 2024

There is some code in method_writer.py to do this which currently does the replacements for DIM template parameters only so doesn't catch the SPACE_DIM parameter.

TODO:

  • Update template replacements for default args in method_writer.py to catch template parameters in a more robust way.
  • Add template replacements for default args to constructor_writer.py as well.

@kwabenantim kwabenantim changed the title Fix template parameter handling Fix template parameters in default args May 2, 2024
@kwabenantim kwabenantim linked a pull request May 2, 2024 that will close this issue
@kwabenantim kwabenantim changed the title Fix template parameters in default args Fix template parameters in method default args May 2, 2024
kwabenantim added a commit that referenced this issue May 2, 2024
kwabenantim added a commit that referenced this issue May 2, 2024
kwabenantim added a commit that referenced this issue May 2, 2024
kwabenantim added a commit that referenced this issue May 2, 2024
kwabenantim added a commit that referenced this issue May 2, 2024
kwabenantim added a commit that referenced this issue May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant