我正在使用小部件来参数化一些数据的生成。我想捕获数据,而不输出它。这可能吗?在D/NuPlayerDriver( 1144): start(0xb6250ca0)
I/GenericSource( 1144): start
I/Process ( 1498): Sending signal. PID: 1588 SIG: 3
I/Process ( 1498): Sending signal. PID: 1498 SIG: 3
I/art ( 1498): Thread[3,tid=1503,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x12c02080,"Signal Catcher"]: reacting to signal 3
W/art ( 1498): Suspending all threads took: 76.883ms
D/NuPlayerDriver( 1144): reset(0xb6250ca0)
I/art ( 1588): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1588): Thread[3,tid=1591,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x12c210e0,"Signal Catcher"]: reacting to signal 3
W/art ( 1588): Suspending all threads took: 60.021ms
I/art ( 1633): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1588): Wrote stack traces to '/data/anr/traces.txt'
I/DownloadManager( 1633): Upgrading downloads database from version 0 to version 109, which will destroy all old data
I/dumpstate( 1800): begin
I/art ( 1552): Thread[3,tid=1563,WaitingInMainSignalCatcherLoop,Thread*=0xb1505400,peer=0x746a5080,"Signal Catcher"]: reacting to signal 3
I/art ( 1552): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1588): Thread[3,tid=1591,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x12c210e0,"Signal Catcher"]: reacting to signal 3
I/art ( 1613): Thread[3,tid=1618,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x12c07080,"Signal Catcher"]: reacting to signal 3
I/art ( 1588): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1633): Thread[3,tid=1641,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x22c12080,"Signal Catcher"]: reacting to signal 3
I/art ( 1739): Thread[3,tid=1749,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x22c07080,"Signal Catcher"]: reacting to signal 3
I/art ( 1613): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1763): Thread[3,tid=1775,WaitingInMainSignalCatcherLoop,Thread*=0xafc0d400,peer=0x22c06140,"Signal Catcher"]: reacting to signal 3
I/art ( 1739): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1763): Wrote stack traces to '/data/anr/traces.txt'
I/art ( 1633): Wrote stack traces to '/data/anr/traces.txt'
# Stopped here
之后添加;
不起作用。例如:
interact()
答案 0 :(得分:2)
您可以修改全局变量,而不是在generate_data()
中返回值。它可以避免打印输出,您可以稍后在代码中使用val
。
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed
import numpy as np
val = None
def generate_data(n, p, s):
global val
val = np.random.negative_binomial(n, p, s)
w_n = widgets.IntSlider(min=1, max=10000, step=1)
w_p = widgets.FloatSlider(min=0.01, max=1, step = 0.01)
w_s = widgets.IntSlider(min=500,max=10000,step=50)
interact(generate_data, n = w_n, p = w_p, s = w_s)
答案 1 :(得分:2)
我已经向ipywidgets提交了解决此问题的拉取请求:
https://github.com/ipython/ipywidgets/pull/712
这些变化实际上非常简单。使用此版本,您只需将额外的kwarg传递给interact
:
data = interact(generate_data, n = w_n, p = w_p, s = w_s,
__output_result=False)