Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DeprecationWarning: Non-string object detected for the array ordering. Please pass in 'C', 'F', 'A', or 'K' instead

Tags:

python

3d

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()
like image 416
user3111801 Avatar asked Jul 17 '17 16:07

user3111801


1 Answers

Your code is assuming an older version of numpy.

Newer versions of numpy (mine is 1.14.0) you can check the docstring in IPython by typing

np.ndarray.flatten?

and what I'm getting is:

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'.

The equivalent of passing -1 is the 'F' option, i.e. the following snippet:

import numpy as np

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

produces True (and the DeprecationWarning you're asking about).

like image 134
ponadto Avatar answered Nov 19 '22 13:11

ponadto