Skip to content

Commit

Permalink
Ignore empty parameter values in Python kwargs for set_target
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhowe23 committed Apr 16, 2024
1 parent e5dfcbb commit a18113d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/runtime/cudaq/target/py_runtime_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ void bindRuntimeTarget(py::module &mod, LinkedLibraryHolder &holder) {
throw std::runtime_error(
"QPU kwargs config value must be cast-able to a string.");

config.emplace(key.cast<std::string>(), strValue);
// Ignore empty parameter values
if (!strValue.empty())
config.emplace(key.cast<std::string>(), strValue);
}
holder.setTarget(target.name, config);
},
Expand All @@ -108,7 +110,9 @@ void bindRuntimeTarget(py::module &mod, LinkedLibraryHolder &holder) {
throw std::runtime_error(
"QPU kwargs config value must be cast-able to a string.");

config.emplace(key.cast<std::string>(), strValue);
// Ignore empty parameter values
if (!strValue.empty())
config.emplace(key.cast<std::string>(), strValue);
}
holder.setTarget(name, config);
},
Expand Down

0 comments on commit a18113d

Please sign in to comment.