我尝试启动模拟器,但它输出到日志:
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request: GLXBadContext
Major opcode of failed request: 155 (GLX)
Minor opcode of failed request: 6 (X_GLXIsDirect)
Serial number of failed request: 47
Current serial number in output stream: 46
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL …Run Code Online (Sandbox Code Playgroud) 我有一个问题是在文件夹中解析1000个文本文件(每个文件大约3000行,大小约400KB).我确实用readlines读过它们,
for filename in os.listdir (input_dir) :
if filename.endswith(".gz"):
f = gzip.open(file, 'rb')
else:
f = open(file, 'rb')
file_content = f.readlines()
f.close()
len_file = len(file_content)
while i < len_file:
line = file_content[i].split(delimiter)
... my logic ...
i += 1
Run Code Online (Sandbox Code Playgroud)
这对我输入的样本(50,100个文件)完全没问题.当我在整个输入上运行超过5K的文件时,所花费的时间远不及线性增量.我计划进行性能分析并进行Cprofile分析.当输入达到7K文件时,更多文件以指数方式增加并且达到更差的速率所花费的时间.
这是readlines的累计时间,第一个 - > 354个文件(来自输入的样本)和第二个 - > 7473个文件(整个输入)
ncalls tottime percall cumtime percall filename:lineno(function)
354 0.192 0.001 **0.192** 0.001 {method 'readlines' of 'file' objects}
7473 1329.380 0.178 **1329.380** 0.178 {method 'readlines' of 'file' objects}
Run Code Online (Sandbox Code Playgroud)
因此,我的代码所花费的时间不会随着输入的增加而线性缩放.我阅读了一些文档说明readlines(),其中人们声称这readlines()会将整个文件内容读入内存,因此与readline()或相比通常消耗更多内存 …
根据Kotlin文档,?运算符表示"安全调用",这意味着如果它在方法调用链中使用,则整个链将返回null,如果它使用的任何值的值为null.
但是,如果在作业的左侧使用它呢?由于左侧不是"返回"任何东西,它似乎可能有不同的效果.这是我正在谈论的一个例子:
val myObj = SomeObj()
myObj?.property = SomeClass.someFunc() // What does ?. do in this context?
Run Code Online (Sandbox Code Playgroud) 我用d3.js制作了一个折线图(见附图1).
当鼠标悬停时,我设法在图形点上插入工具提示.我也想改变点的颜色和大小.我试过很多方面,但看起来真的很难.有帮助吗?这是一段代码:
svg.selectAll("dot")
.data(data)
.enter().append("circle")
.attr("r", 5.5)
.style("fill", "#fff8ee")
.style("opacity", .8) // set the element opacity
.style("stroke", "#f93") // set the line colour
.style("stroke-width", 3.5)
.attr("cx", function(d) { return x(d.date); })
.attr("cy", function(d) { return y(d.close); })
.on("mouseover", function(d) {
div.transition()
.duration(70)
.style("opacity", .7)
;
div .html(formatTime(d.date) + "<br/>" + d.close)
.style("left", (d3.event.pageX) + "px")
.style("top", (d3.event.pageY - 28) + "px");
})
.on("mouseout", function(d) {
div.transition()
.duration(200)
.style("opacity", 0);
});
Run Code Online (Sandbox Code Playgroud) 我想监视一些实时数据,并允许用户在与图表交互时选择自己的范围.我创建了这个小例子(从教程中得到)并且问题是,每次我更新绘图时,一切都会重置,因为update_graph_live()返回一个新的Plotly数字.(见下面的例子)
是否可以仅更新数据,因此图形不会重新加载并重置为默认视图/设置?之前我使用的是d3.js并通过websockets发送数据,因此我可以在浏览器中过滤数据.但是我想直接用Dash来做.
import dash
from dash.dependencies import Output, Event
import dash_core_components as dcc
import dash_html_components as html
from random import random
import plotly
app = dash.Dash(__name__)
app.layout = html.Div(
html.Div([
html.H4('Example'),
dcc.Graph(id='live-update-graph'),
dcc.Interval(
id='interval-component',
interval=1*1000
)
])
)
@app.callback(Output('live-update-graph', 'figure'),
events=[Event('interval-component', 'interval')])
def update_graph_live():
fig = plotly.tools.make_subplots(rows=2, cols=1, vertical_spacing=0.2)
fig['layout']['margin'] = {
'l': 30, 'r': 10, 'b': 30, 't': 10
}
fig['layout']['legend'] = {'x': 0, 'y': 1, 'xanchor': 'left'}
fig.append_trace({
'x': [1, 2, 3, 4, 5],
'y': [random() …Run Code Online (Sandbox Code Playgroud) 我正在使用 SimpleHTTPServer 的 do_POST 方法来接收文件。如果我使用 curl 上传 png 文件,脚本工作正常,但是每当我使用 python 请求库上传文件时,文件上传但会损坏。这是 SimpleHTTPServer 代码
#!/usr/bin/env python
# Simple HTTP Server With Upload.
import os
import posixpath
import BaseHTTPServer
import urllib
import cgi
import shutil
import mimetypes
import re
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# Simple HTTP request handler with POST commands.
def do_POST(self):
"""Serve a POST request."""
r, info = self.deal_post_data()
print r, info, "by: ", self.client_address
f = StringIO()
if r:
f.write("<strong>Success:</strong>") …Run Code Online (Sandbox Code Playgroud) 这是一个代码,我试图显示每个点的车速.
import plotly.plotly as py
from plotly.graph_objs import *
mapbox_access_token = 'MAPBOX API KEY'
data = Data([
Scattermapbox(
lat=dataframe_monday_morning['latitude'],
lon=dataframe_monday_morning['longitude'],
mode='markers',
marker=Marker(
size=5,
color =dataframe_monday_morning['speed'],
colorscale= 'YlOrRd',
#opacity=0.3,
symbol = 'circle',
),
)
])
layout = Layout(
autosize=True,
hovermode='closest',
width=1300,
margin=go.Margin(
l=0,
r=0,
b=0,
t=0
),
height=700,
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,#
center=dict(
lat=-36.7526,
lon=174.7274
),
pitch=0,
zoom=16.2,
style='dark',
),
)
fig = dict(data=data, layout=layout)
py.iplot(fig, filename='Multiple Mapbox')
Run Code Online (Sandbox Code Playgroud)
但是当我尝试
color =dataframe_monday_morning['speed']
Run Code Online (Sandbox Code Playgroud)
代码选择当前数据最小和最大速度然后给我一个图表.在数据中,一些速度数据间隙非常大,所以我想在我的速度值之间创建一个色标.(例如,如果您选择最高速度200公里/小时,您的其他30公里/小时和90公里/小时看起来颜色相似,但通常速度通常不同)
我的问题是如何创建一个用于选择速度颜色的比例?
编辑:
这是我编辑的数据示例.
13 1.464301e+10 2015-11-15 18:28:50 191 10051 76 …Run Code Online (Sandbox Code Playgroud) 我对通过烧瓶本地托管的情节和破折号的隐私感到困惑.
给定了一个向Flask托管仪表板的项目给我本地网络上的用户:
如果我根据部署用户指南(https://plot.ly/dash/deployment)使用Flask服务器部署Dash应用程序,即:
import flask
import dash
server = flask.Flask(__name__)
app = dash.Dash(__name__, server=server)
Run Code Online (Sandbox Code Playgroud)
如果我向破折号应用程序提供数据,是否可以在任何地方在线发布(即情节网站)?
如果我创建一个图形,如plotly.graph_objs.Figure在dash_core_components.Graph?服务于此数字的数据是否会在线发布?或者我是否必须指定使用plotly.offline.plot以确保它不连接到外部服务器,类似于使用plotly的笔记本?
下面的代码是从plotly教程https://plot.ly/python/filled-area-plots/复制的,除了带有设置的行opacity。
然而,这不起作用。如何设置填充区域的不透明度?
import plotly.plotly as py
import plotly.graph_objs as go
# Add original data
x = ['Winter', 'Spring', 'Summer', 'Fall']
trace0 = dict(
x=x,
y=[40, 60, 40, 10],
hoverinfo='x+y',
mode='lines',
##########
opacity = 0.5,
##########
line=dict(width=0.5,
color='rgb(131, 90, 241)'),
stackgroup='one'
)
trace1 = dict(
x=x,
y=[20, 10, 10, 60],
hoverinfo='x+y',
mode='lines',
##########
opacity = 0.5,
##########
line=dict(width=0.5,
color='rgb(111, 231, 219)'),
stackgroup='one'
)
trace2 = dict(
x=x,
y=[40, 30, 50, 30],
hoverinfo='x+y',
mode='lines',
##########
opacity = 0.5, …Run Code Online (Sandbox Code Playgroud) python ×7
plotly ×4
plotly-dash ×2
cgi ×1
d3.js ×1
file-upload ×1
javascript ×1
jquery ×1
kotlin ×1
mapbox ×1
memory ×1
performance ×1
python-2.6 ×1
readlines ×1
scikit-learn ×1
ubuntu-15.10 ×1