I currently have a volume spanned by a few million every unevenly spaced particles and each particle has an attribute (potential, for those who are curious) that I want to calculate the local force (acceleration) for.
np.gradient only works with evenly spaced data and I looked here: Second order gradient in numpy where interpolation is necessary but I could not find a 3D spline implementation in Numpy.
Some code that will produce representative data:
import numpy as np
from scipy.spatial …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个JointGrid图,但我在获得正确的宽高比方面遇到了一些麻烦.相关代码和图如下.不知道我做错了什么.
fig = plt.figure()
sns.set_style("ticks")
g = sns.JointGrid(X, Y, xlim=[0, max(X)], ylim=[0, max(Y)])
g.plot_marginals(sns.distplot, color=".5")
g.plot_joint(plt.hexbin, bins='log', gridsize=30, cmap=color)
Run Code Online (Sandbox Code Playgroud)
而输出数字:

我不确定我做错了什么; 我看了看这个:https://github.com/mwaskom/seaborn/issues/271但修复不起作用.
谢谢!
我有两个数据结构:列表和defaultdict字典.该列表包含300,000个数字的无序序列,并且字典包含与具有相应值(一些小整数)的键相同的数字(不是相同的顺序).例如,列表可能是这样的:l = [500,800,1500]然后相应的字典就像d = {800:3,1500:1,500:4}.我的目标是创建另一个列表,该列表只包含字典d中每个键的相应值,顺序为l.对于简单的例子,我想要返回[4,3,1](不是[3,1,4]).我有一些天真的代码可以运行,但需要花费很长时间来运行300,000个数字.
这就是我所拥有的:
for k,v in d.iteritems():
for i in xrange(len(l)):
if(l[i]==k):
out[i]=v
Run Code Online (Sandbox Code Playgroud)
有没有办法让这个更有效率?
python ×3
derivative ×1
dictionary ×1
list ×1
matplotlib ×1
numpy ×1
performance ×1
plot ×1
scipy ×1
seaborn ×1