gpt4 book ai didi

python - DeprecationWarning : Non-string object detected for the array ordering. 请改为传入 'C' 、 'F' 、 'A' 或 'K'

转载 作者:太空狗 更新时间:2023-10-30 01:32:08 25 4
gpt4 key购买 nike

from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot

# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)

# Load the STL files and add the vectors to the plot
your_mesh = mesh.Mesh.from_file("/home/niroz/stl files/bottle/binary.stl")

axes.add_collection3d(mplot3d.art3d.Poly3DCollection(your_mesh.vectors))

# Auto scale to the mesh size
scale = your_mesh.points.flatten(-1)
axes.auto_scale_xyz(scale, scale, scale)

# Show the plot to the screen
pyplot.show()

最佳答案

您的代码采用旧版本的 numpy

较新版本的 numpy(我的是 1.14.0)您可以通过键入在 IPython 中检查文档字符串

np.ndarray.flatten?

我得到的是:

Docstring:
a.flatten(order='C')

Return a copy of the array collapsed into one dimension.

Parameters
----------
order : {'C', 'F', 'A', 'K'}, optional
'C' means to flatten in row-major (C-style) order.
'F' means to flatten in column-major (Fortran-
style) order. 'A' means to flatten in column-major
order if `a` is Fortran *contiguous* in memory,
row-major order otherwise. 'K' means to flatten
`a` in the order the elements occur in memory.
The default is 'C'.

传递 -1 的等效项是 'F' 选项,即以下代码段:

import numpy as np

foo = np.array([[1,2,3], [3,4,5]])
print (foo.flatten(-1) == foo.flatten('F')).all()

产生 True(以及您询问的 DeprecationWarning)。

关于python - DeprecationWarning : Non-string object detected for the array ordering. 请改为传入 'C' 、 'F' 、 'A' 或 'K',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45149122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com