Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy doesn't support anymore streamline plot #4232

Closed
ArthurTlprt opened this issue Jun 7, 2023 · 1 comment
Closed

Numpy doesn't support anymore streamline plot #4232

ArthurTlprt opened this issue Jun 7, 2023 · 1 comment

Comments

@ArthurTlprt
Copy link
Contributor

I tried running the streamline example in the doc, but it raised a warning and the figure was not plot:

import plotly.figure_factory as ff

import numpy as np

x = np.linspace(-3, 3, 100)
y = np.linspace(-3, 3, 100)
Y, X = np.meshgrid(x, y)

print(type(Y))
print(Y.shape)

u = -1 - X**2 + Y
v = 1 + X - Y**2

# Create streamline figure
fig = ff.create_streamline(x, y, u, v, arrow_scale=.1)
fig.show()
---------------------------------------------------------------------------
PendingDeprecationWarning                 Traceback (most recent call last)
Cell In[15], line 16
    13 v = 1 + X - Y**2
    15 # Create streamline figure
---> 16 fig = ff.create_streamline(x, y, u, v, arrow_scale=.1)
    17 fig.show()

File [~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:117](https://file+.vscode-resource.vscode-cdn.net/home/arthur/Documents/pyrotor/examples/~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:117), in create_streamline(x, y, u, v, density, angle, arrow_scale, **kwargs)
   114 validate_streamline(x, y)
   115 utils.validate_positive_scalars(density=density, arrow_scale=arrow_scale)
--> 117 streamline_x, streamline_y = _Streamline(
   118     x, y, u, v, density, angle, arrow_scale
   119 ).sum_streamlines()
   120 arrow_x, arrow_y = _Streamline(
   121     x, y, u, v, density, angle, arrow_scale
   122 ).get_streamline_arrows()
   124 streamline = graph_objs.Scatter(
   125     x=streamline_x + arrow_x, y=streamline_y + arrow_y, mode="lines", **kwargs
   126 )

File [~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:170](https://file+.vscode-resource.vscode-cdn.net/home/arthur/Documents/pyrotor/examples/~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:170), in _Streamline.__init__(self, x, y, u, v, density, angle, arrow_scale, **kwargs)
   168 self.get_streamlines()
   169 streamline_x, streamline_y = self.sum_streamlines()
--> 170 arrows_x, arrows_y = self.get_streamline_arrows()

File [~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:385](https://file+.vscode-resource.vscode-cdn.net/home/arthur/Documents/pyrotor/examples/~/Documents/pyrotor/env/lib/python3.9/site-packages/plotly/figure_factory/_streamline.py:385), in _Streamline.get_streamline_arrows(self)
   382 space[:] = np.nan
   384 # Combine arrays into matrix
--> 385 arrows_x = np.matrix([point1_x, arrow_end_x, point2_x, space])
   386 arrows_x = np.array(arrows_x)
   387 arrows_x = arrows_x.flatten("F")

File [~/Documents/pyrotor/env/lib/python3.9/site-packages/numpy/matrixlib/defmatrix.py:116](https://file+.vscode-resource.vscode-cdn.net/home/arthur/Documents/pyrotor/examples/~/Documents/pyrotor/env/lib/python3.9/site-packages/numpy/matrixlib/defmatrix.py:116), in matrix.__new__(subtype, data, dtype, copy)
   115 def __new__(subtype, data, dtype=None, copy=True):
--> 116     warnings.warn('the matrix subclass is not the recommended way to '
   117                   'represent matrices or deal with linear algebra (see '
   118                   'https://docs.scipy.org/doc/numpy/user/'
   119                   'numpy-for-matlab-users.html). '
   120                   'Please adjust your code to use regular ndarray.',
   121                   PendingDeprecationWarning, stacklevel=2)
   122     if isinstance(data, matrix):
   123         dtype2 = data.dtype

PendingDeprecationWarning: the matrix subclass is not the recommended way to represent matrices or deal with linear algebra (see https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html). Please adjust your code to use regular ndarray.```
@alexcjohnson
Copy link
Collaborator

Closed by #4233 - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants