这是一个简单的情节:
1)如何禁用滴答?2)如何减少他们的数量?
这是一个示例代码:
from pylab import *
import numpy as np
x = [5e-05, 5e-06, 5e-07, 5e-08, 5e-09, 5e-10]
y = [-13, 14, 100, 120, 105, 93]
def myfunc(x,p):
sl,yt,yb,ec=p
y = yb + (yt-yb)/(1+np.power(10, sl*(np.log10(x)-np.log10(ec))))
return y
xp = np.power(10, np.linspace(np.log10(min(x)/10), np.log10(max(x)*10), 100))
pxp=myfunc(xp, [1,100,0,1e-6])
subplot(111,axisbg="#dfdfdf")
plt.plot(x, y, '.', xp, pxp, 'g-', linewidth=1)
plt.xscale('log')
plt.grid(True,ls="-", linewidth=0.4, color="#ffffff", alpha=0.5)
plt.draw()
plt.show()
Run Code Online (Sandbox Code Playgroud)
哪个产生:
我正在尝试使用多处理来计算和生成绘图.在Linux上,下面的代码运行正常,但在Mac(ML)上它没有运行,给出以下错误:
import multiprocessing
import matplotlib.pyplot as plt
import numpy as np
import rpy2.robjects as robjects
def main():
pool = multiprocessing.Pool()
num_figs = 2
# generate some random numbers
input = zip(np.random.randint(10,1000,num_figs),
range(num_figs))
pool.map(plot, input)
def plot(args):
num, i = args
fig = plt.figure()
data = np.random.randn(num).cumsum()
plt.plot(data)
main()
Run Code Online (Sandbox Code Playgroud)
Rpy2是rpy2 == 2.3.1,R是2.13.2(我无法在任何mac上安装R 3.0和rpy2最新版本而不会出现分段错误).
错误是:
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_COREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.
The process has forked and you cannot …
Run Code Online (Sandbox Code Playgroud) 我正在使用django-parler(django-hvad的衍生物)进行翻译.在管理员显示具有多种关系的Foreignkey字段时,django为每个字段运行一个查询:
因此,当有300个服务时,会有尽可能多的查询.
我认为get_queryset上的prefetch_related不适用于mantomany
过滤器/列表,如果我错了,请纠正我:
def get_queryset(self, request):
return super(DoctorAdmin, self).get_queryset(request).prefetch_related('translations', 'services__translations')
Run Code Online (Sandbox Code Playgroud)
对查询数量没有影响.启用缓存上parler(如笔者建议在这里)也于事无补,因为相同的查询不重复,但这些过滤器的每一项被称为在翻译项目查询(IDS每一次都是不同的).所以,我要找的是内部过滤器上的select_related/prefetch_related.如果您已经解决了这个问题,我也会同时审核您的应用程序.
这是我读取csv文件时的输入文件:
Sample Info D3S1358 1 D3S1358 2 TH01 1 TH01 2 D21S11 1 D21S11 2 D21S11 3
TEST_646 17 17 9 9.3 28 28 nan
TEST_647 18 18 7 7 29 30 30.2
TEST_648 16 16 9 9 31.2 31.2 nan
Run Code Online (Sandbox Code Playgroud)
我想将其转换为这样的形式:
Sample_name Marker mrk value
TEST_646 D3S1358 1 17
TEST_646 D3S1358 2 17
TEST_646 TH01 1 9
TEST_646 TH01 2 9.3
TEST_646 D21S11 1 28.0
TEST_646 D21S11 2 28.0
TEST_646 D21S11 3 nan
Run Code Online (Sandbox Code Playgroud)
PS.以下是逗号分隔形式的值,以方便您:
Sample Info, D3S1358 1, D3S1358 …
Run Code Online (Sandbox Code Playgroud) 我想根据其范围的有效性来选择我的原始数据。有一个仪器,最敏感的设置是C,然后是B,然后是A。所以从C开始,看看所有的值是否都小于阈值,如果是,那么完美,把这个灵敏度中的所有数据设置为best= 1.
from StringIO import StringIO
a = """category,val,sensitivity_level
x,20,A
x,31,B
x,60,C
x,20,A
x,25,B
x,60,C
y,20,A
y,40,B
y,60,C
y,20,A
y,24,B
y,30,C"""
df = pd.read_csv(StringIO(a))
def grp_1evel_1(x):
"""
return if all the elements are less than threshold
"""
return x<=30
def grp_1evel_0(x):
"""
Input: data grouped by category. Here I want to go through this categories, in an descending order,
that is C, B and then A, and wherever one of this categories has x<=30 valid for all elements select
that …
Run Code Online (Sandbox Code Playgroud) python ×5
matplotlib ×2
pandas ×2
django ×1
django-admin ×1
django-hvad ×1
group-by ×1
rpy2 ×1