Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
nbelakovski committed Mar 18, 2024
1 parent 98fb9e3 commit c7c6ec0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions python/_prima.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ PYBIND11_MODULE(_prima, m) {
// Process options.
prima_options_t options;
prima_init_options(&options);
if (options_dict.is_none() == false) {
if ( ! options_dict.is_none()) {
if(options_dict.contains("ftarget")) { options.ftarget = options_dict["ftarget"].cast<double>(); }
if(options_dict.contains("iprint")) { options.iprint = options_dict["iprint"].cast<int>(); }
if(options_dict.contains("maxfev")) { options.maxfun = options_dict["maxfev"].cast<int>(); }
Expand Down Expand Up @@ -246,7 +246,7 @@ PYBIND11_MODULE(_prima, m) {
}

prima_callback_t cpp_callback_function_wrapper = nullptr;
if (python_callback_function_holder.is_none() == false) {
if ( ! python_callback_function_holder.is_none()) {
cpp_callback_function_wrapper = [](const int n, const double x[], const double f, int nf, int tr,
const double cstrv, int m_nlcon, const double nlconstr[], bool *terminate) {
// In order for xlist to not copy the data from x, we need to provide a dummy base object
Expand All @@ -264,7 +264,7 @@ PYBIND11_MODULE(_prima, m) {
//=====================
// Handle Bounds
//=====================
if (lb.is_none() == false && ub.is_none() == false) {
if (( ! lb.is_none()) && ( ! ub.is_none())) {
// Use the buffer protocol to avoid copying
py::buffer_info lb_buffer_info = lb.cast<py::buffer>().request();
if (lb_buffer_info.format != "d")
Expand All @@ -283,7 +283,7 @@ PYBIND11_MODULE(_prima, m) {
//==============================
// Handle Linear Constraints
//==============================
if(A_eq.is_none() == false) {
if( ! A_eq.is_none()) {
py::buffer_info A_eq_buffer_info = A_eq.cast<py::buffer>().request();
if (A_eq_buffer_info.format != "d")
{
Expand All @@ -298,7 +298,7 @@ PYBIND11_MODULE(_prima, m) {
}
problem.beq = (double*) b_eq_buffer_info.ptr;
}
if(A_ineq.is_none() == false) {
if( ! A_ineq.is_none()) {
py::buffer_info A_ineq_buffer_info = A_ineq.cast<py::buffer>().request();
if (A_ineq_buffer_info.format != "d")
{
Expand Down
2 changes: 1 addition & 1 deletion python/prima/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def minimize(fun, x0, args=(), method=None, bounds=None, constraints=(), callbac
m_nlcon = len(nlconstr0)
f0 = fun(x0)
else:
m_nlcon = None
m_nlcon = 0
f0 = None

return _minimize(
Expand Down
2 changes: 1 addition & 1 deletion python/prima/_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def process_bounds(bounds, lenx0):
'''
bounds can either be an object with the properties lb and ub, or a list of tuples
`bounds` can either be an object with the properties lb and ub, or a list of tuples
indicating a lower bound and an upper bound for each variable. If the list contains
fewer entries than the length of x0, the remaining entries will generated as -/+ infinity.
Some examples of valid lists of tuple, assuming len(x0) == 3:
Expand Down

0 comments on commit c7c6ec0

Please sign in to comment.