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

bug fixes for prism with material function #1652

Merged
merged 1 commit into from
Jul 1, 2021
Merged
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
10 changes: 8 additions & 2 deletions python/typemap_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,10 @@ static int pymaterial_to_material(PyObject *po, material_type *mt) {
else if (PyFunction_Check(po)) {
PyObject *eps = PyObject_GetAttrString(po, "eps");
PyObject *py_do_averaging = PyObject_GetAttrString(po, "do_averaging");
PyErr_Clear(); // clear errors from attributes not present
bool do_averaging = false;
if (py_do_averaging) { do_averaging = PyObject_IsTrue(py_do_averaging); }
if (eps && eps == Py_True) { md = make_user_material(py_epsilon_func_wrap, po, do_averaging); }
if (eps && PyObject_IsTrue(eps)) { md = make_user_material(py_epsilon_func_wrap, po, do_averaging); }
else {
md = make_user_material(py_user_material_func_wrap, po, do_averaging);
}
Expand Down Expand Up @@ -714,9 +715,14 @@ static PyObject *material_to_py_material(material_type mat) {

return py_mat;
}
case meep_geom::material_data::MATERIAL_USER: {
PyObject *py_mat = (PyObject *) mat->user_data;
Py_INCREF(py_mat);
return py_mat;
}
default:
// Only Medium is supported at this time.
meep::abort("Can only convert C++ medium_struct to Python");
meep::abort("Can only convert C++ medium_struct subtype %d to Python", mat->which_subclass);
}
}

Expand Down