Python:numpy和scipy最小化:使用序列最小化设置数组元素

时间:2017-05-22 10:05:46

标签: python arrays numpy scipy minimize

我正在尝试最小化该功能,但得到一个

  

ValueError:使用序列设置数组元素。

在以下代码中:

from bokeh.layouts import widgetbox
from bokeh.models import CustomJS, TextInput, Paragraph
from bokeh.plotting import output_file, show

# SAVE
output_file('Sample_Application.html',mode='inline',root_dir=None)

# PREP DATA
welcome_message = 'You have selected: (none)'

# TAKE ONLY OUTPUT
text_banner = Paragraph(text=welcome_message, width=200, height=100)

# CALLBACKS
def callback_print(text_banner=text_banner):
    user_input = str(cb_obj.value)
    welcome_message = 'You have selected: ' + user_input
    text_banner.text = welcome_message

# USER INTERACTIONS
text_input = TextInput(value="", title="Enter row number:",             
callback=CustomJS.from_py_func(callback_print))

# LAYOUT
widg = widgetbox(text_input, text_banner)
show(widg)

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

在最小化期间​​检查函数f()内的x和其返回值的尺寸,当您发现问题时,函数flatten()可能会有所帮助。