passagemath-plot 10.6.31rc3__cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-plot might be problematic. Click here for more details.

Files changed (81) hide show
  1. passagemath_plot-10.6.31rc3.dist-info/METADATA +172 -0
  2. passagemath_plot-10.6.31rc3.dist-info/RECORD +81 -0
  3. passagemath_plot-10.6.31rc3.dist-info/WHEEL +6 -0
  4. passagemath_plot-10.6.31rc3.dist-info/top_level.txt +2 -0
  5. passagemath_plot.libs/libgfortran-e1b7dfc8.so.5.0.0 +0 -0
  6. passagemath_plot.libs/libgsl-e3525837.so.28.0.0 +0 -0
  7. passagemath_plot.libs/libopenblasp-r0-4c5b64b1.3.29.so +0 -0
  8. sage/all__sagemath_plot.py +15 -0
  9. sage/ext_data/threejs/animation.css +195 -0
  10. sage/ext_data/threejs/animation.html +85 -0
  11. sage/ext_data/threejs/animation.js +273 -0
  12. sage/ext_data/threejs/fat_lines.js +48 -0
  13. sage/ext_data/threejs/threejs-version.txt +1 -0
  14. sage/ext_data/threejs/threejs_template.html +597 -0
  15. sage/interfaces/all__sagemath_plot.py +1 -0
  16. sage/interfaces/gnuplot.py +196 -0
  17. sage/interfaces/jmoldata.py +208 -0
  18. sage/interfaces/povray.py +56 -0
  19. sage/plot/all.py +42 -0
  20. sage/plot/animate.py +1796 -0
  21. sage/plot/arc.py +504 -0
  22. sage/plot/arrow.py +671 -0
  23. sage/plot/bar_chart.py +205 -0
  24. sage/plot/bezier_path.py +400 -0
  25. sage/plot/circle.py +435 -0
  26. sage/plot/colors.py +1606 -0
  27. sage/plot/complex_plot.cpython-314-aarch64-linux-gnu.so +0 -0
  28. sage/plot/complex_plot.pyx +1446 -0
  29. sage/plot/contour_plot.py +1792 -0
  30. sage/plot/density_plot.py +318 -0
  31. sage/plot/disk.py +373 -0
  32. sage/plot/ellipse.py +375 -0
  33. sage/plot/graphics.py +3580 -0
  34. sage/plot/histogram.py +354 -0
  35. sage/plot/hyperbolic_arc.py +404 -0
  36. sage/plot/hyperbolic_polygon.py +416 -0
  37. sage/plot/hyperbolic_regular_polygon.py +296 -0
  38. sage/plot/line.py +626 -0
  39. sage/plot/matrix_plot.py +629 -0
  40. sage/plot/misc.py +509 -0
  41. sage/plot/multigraphics.py +1294 -0
  42. sage/plot/plot.py +4183 -0
  43. sage/plot/plot3d/all.py +23 -0
  44. sage/plot/plot3d/base.cpython-314-aarch64-linux-gnu.so +0 -0
  45. sage/plot/plot3d/base.pxd +12 -0
  46. sage/plot/plot3d/base.pyx +3378 -0
  47. sage/plot/plot3d/implicit_plot3d.py +659 -0
  48. sage/plot/plot3d/implicit_surface.cpython-314-aarch64-linux-gnu.so +0 -0
  49. sage/plot/plot3d/implicit_surface.pyx +1453 -0
  50. sage/plot/plot3d/index_face_set.cpython-314-aarch64-linux-gnu.so +0 -0
  51. sage/plot/plot3d/index_face_set.pxd +32 -0
  52. sage/plot/plot3d/index_face_set.pyx +1873 -0
  53. sage/plot/plot3d/introduction.py +131 -0
  54. sage/plot/plot3d/list_plot3d.py +649 -0
  55. sage/plot/plot3d/parametric_plot3d.py +1130 -0
  56. sage/plot/plot3d/parametric_surface.cpython-314-aarch64-linux-gnu.so +0 -0
  57. sage/plot/plot3d/parametric_surface.pxd +12 -0
  58. sage/plot/plot3d/parametric_surface.pyx +893 -0
  59. sage/plot/plot3d/platonic.py +601 -0
  60. sage/plot/plot3d/plot3d.py +1442 -0
  61. sage/plot/plot3d/plot_field3d.py +162 -0
  62. sage/plot/plot3d/point_c.pxi +148 -0
  63. sage/plot/plot3d/revolution_plot3d.py +309 -0
  64. sage/plot/plot3d/shapes.cpython-314-aarch64-linux-gnu.so +0 -0
  65. sage/plot/plot3d/shapes.pxd +22 -0
  66. sage/plot/plot3d/shapes.pyx +1382 -0
  67. sage/plot/plot3d/shapes2.py +1512 -0
  68. sage/plot/plot3d/tachyon.py +1779 -0
  69. sage/plot/plot3d/texture.py +453 -0
  70. sage/plot/plot3d/transform.cpython-314-aarch64-linux-gnu.so +0 -0
  71. sage/plot/plot3d/transform.pxd +21 -0
  72. sage/plot/plot3d/transform.pyx +268 -0
  73. sage/plot/plot3d/tri_plot.py +589 -0
  74. sage/plot/plot_field.py +362 -0
  75. sage/plot/point.py +624 -0
  76. sage/plot/polygon.py +562 -0
  77. sage/plot/primitive.py +249 -0
  78. sage/plot/scatter_plot.py +199 -0
  79. sage/plot/step.py +85 -0
  80. sage/plot/streamline_plot.py +328 -0
  81. sage/plot/text.py +432 -0
@@ -0,0 +1,328 @@
1
+ # sage_setup: distribution = sagemath-plot
2
+ # sage.doctest: needs sage.symbolic
3
+ """
4
+ Streamline plots
5
+ """
6
+ # ****************************************************************************
7
+ # Copyright (C) 2006 Alex Clemesha <clemesha@gmail.com>,
8
+ # William Stein <wstein@gmail.com>,
9
+ # 2008 Mike Hansen <mhansen@gmail.com>,
10
+ #
11
+ # Distributed under the terms of the GNU General Public License (GPL)
12
+ #
13
+ # This code is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ # General Public License for more details.
17
+ #
18
+ # The full text of the GPL is available at:
19
+ #
20
+ # https://www.gnu.org/licenses/
21
+ # ****************************************************************************
22
+ from sage.plot.primitive import GraphicPrimitive
23
+ from sage.misc.decorators import options
24
+ from sage.arith.srange import xsrange
25
+
26
+
27
+ class StreamlinePlot(GraphicPrimitive):
28
+ """
29
+ Primitive class that initializes the StreamlinePlot graphics type
30
+ """
31
+ def __init__(self, xpos_array, ypos_array, xvec_array, yvec_array, options):
32
+ """
33
+ Create the graphics primitive StreamlinePlot. This sets options
34
+ and the array to be plotted as attributes.
35
+
36
+ EXAMPLES::
37
+
38
+ sage: x, y = var('x y')
39
+ sage: R = streamline_plot((sin(x), cos(y)), (x,0,1), (y,0,1), plot_points=2)
40
+ sage: r = R[0]
41
+ sage: r.options()['plot_points']
42
+ 2
43
+ sage: r.xpos_array
44
+ array([0., 1.])
45
+ sage: r.yvec_array
46
+ masked_array(
47
+ data=[[1.0, 1.0],
48
+ [0.5403023058681398, 0.5403023058681398]],
49
+ mask=[[False, False],
50
+ [False, False]],
51
+ fill_value=1e+20)
52
+
53
+ TESTS:
54
+
55
+ We test dumping and loading a plot::
56
+
57
+ sage: x, y = var('x y')
58
+ sage: P = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
59
+ sage: Q = loads(dumps(P))
60
+ """
61
+ self.xpos_array = xpos_array
62
+ self.ypos_array = ypos_array
63
+ self.xvec_array = xvec_array
64
+ self.yvec_array = yvec_array
65
+ GraphicPrimitive.__init__(self, options)
66
+
67
+ def get_minmax_data(self):
68
+ """
69
+ Return a dictionary with the bounding box data.
70
+
71
+ EXAMPLES::
72
+
73
+ sage: x, y = var('x y')
74
+ sage: import numpy # to ensure numpy 2.0 compatibility
75
+ sage: if int(numpy.version.short_version[0]) > 1:
76
+ ....: _ = numpy.set_printoptions(legacy="1.25")
77
+ sage: d = streamline_plot((.01*x, x+y), (x,10,20), (y,10,20))[0].get_minmax_data()
78
+ sage: d['xmin']
79
+ 10.0
80
+ sage: d['ymin']
81
+ 10.0
82
+ """
83
+ from sage.plot.plot import minmax_data
84
+ return minmax_data(self.xpos_array, self.ypos_array, dict=True)
85
+
86
+ def _allowed_options(self):
87
+ """
88
+ Return a dictionary with allowed options for ``StreamlinePlot``.
89
+
90
+ EXAMPLES::
91
+
92
+ sage: x, y = var('x y')
93
+ sage: P = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
94
+ sage: d = P[0]._allowed_options()
95
+ sage: d['density']
96
+ 'Controls the closeness of streamlines'
97
+ """
98
+ return {'plot_points': 'How many points to use for plotting precision',
99
+ 'color': 'The color of the arrows',
100
+ 'density': 'Controls the closeness of streamlines',
101
+ 'start_points': 'Coordinates of starting points for the streamlines',
102
+ 'zorder': 'The layer level in which to draw'}
103
+
104
+ def _repr_(self):
105
+ """
106
+ String representation of StreamlinePlot graphics primitive.
107
+
108
+ EXAMPLES::
109
+
110
+ sage: x, y = var('x y')
111
+ sage: P = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
112
+ sage: P[0]
113
+ StreamlinePlot defined by a 20 x 20 vector grid
114
+
115
+ TESTS::
116
+
117
+ sage: x, y = var('x y')
118
+ sage: P = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3), wrong_option='nonsense')
119
+ sage: P[0].options()['plot_points']
120
+ verbose 0 (...: primitive.py, options) WARNING: Ignoring option 'wrong_option'=nonsense
121
+ verbose 0 (...: primitive.py, options)
122
+ The allowed options for StreamlinePlot defined by a 20 x 20 vector grid are:
123
+ color The color of the arrows
124
+ density Controls the closeness of streamlines
125
+ plot_points How many points to use for plotting precision
126
+ start_points Coordinates of starting points for the streamlines
127
+ zorder The layer level in which to draw
128
+ <BLANKLINE>
129
+ 20
130
+ """
131
+ return "StreamlinePlot defined by a {} x {} vector grid".format(
132
+ self._options['plot_points'], self._options['plot_points'])
133
+
134
+ def _render_on_subplot(self, subplot):
135
+ """
136
+ TESTS::
137
+
138
+ sage: x, y = var('x y')
139
+ sage: P = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
140
+ """
141
+ options = self.options()
142
+ streamplot_options = options.copy()
143
+ streamplot_options.pop('plot_points')
144
+ subplot.streamplot(self.xpos_array, self.ypos_array,
145
+ self.xvec_array, self.yvec_array,
146
+ **streamplot_options)
147
+
148
+
149
+ @options(plot_points=20, density=1., frame=True)
150
+ def streamline_plot(f_g, xrange, yrange, **options):
151
+ r"""
152
+ Return a streamline plot in a vector field.
153
+
154
+ ``streamline_plot`` can take either one or two functions. Consider
155
+ two variables `x` and `y`.
156
+
157
+ If given two functions `(f(x,y), g(x,y))`, then this function plots
158
+ streamlines in the vector field over the specified ranges with ``xrange``
159
+ being of `x`, denoted by ``xvar`` below, between ``xmin`` and ``xmax``,
160
+ and ``yrange`` similarly (see below). ::
161
+
162
+ streamline_plot((f, g), (xvar, xmin, xmax), (yvar, ymin, ymax))
163
+
164
+ Similarly, if given one function `f(x, y)`, then this function plots
165
+ streamlines in the slope field `dy/dx = f(x,y)` over the specified
166
+ ranges as given above.
167
+
168
+ PLOT OPTIONS:
169
+
170
+ - ``plot_points`` -- (default: 200) the minimal number of plot points
171
+
172
+ - ``density`` -- float (default: 1.); controls the closeness of
173
+ streamlines
174
+
175
+ - ``start_points`` -- (optional) list of coordinates of starting
176
+ points for the streamlines; coordinate pairs can be tuples or lists
177
+
178
+ EXAMPLES:
179
+
180
+ Plot some vector fields involving `\sin` and `\cos`::
181
+
182
+ sage: x, y = var('x y')
183
+ sage: streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
184
+ Graphics object consisting of 1 graphics primitive
185
+
186
+ .. PLOT::
187
+
188
+ x, y = var('x y')
189
+ g = streamline_plot((sin(x), cos(y)), (x,-3,3), (y,-3,3))
190
+ sphinx_plot(g)
191
+
192
+ ::
193
+
194
+ sage: streamline_plot((y, (cos(x)-2) * sin(x)), (x,-pi,pi), (y,-pi,pi))
195
+ Graphics object consisting of 1 graphics primitive
196
+
197
+ .. PLOT::
198
+
199
+ x, y = var('x y')
200
+ g = streamline_plot((y, (cos(x)-2) * sin(x)), (x,-pi,pi), (y,-pi,pi))
201
+ sphinx_plot(g)
202
+
203
+ We increase the density of the plot::
204
+
205
+ sage: streamline_plot((y, (cos(x)-2) * sin(x)),
206
+ ....: (x,-pi,pi), (y,-pi,pi), density=2)
207
+ Graphics object consisting of 1 graphics primitive
208
+
209
+ .. PLOT::
210
+
211
+ x, y = var('x y')
212
+ g = streamline_plot((y, (cos(x)-2) * sin(x)), (x,-pi,pi), (y,-pi,pi), density=2)
213
+ sphinx_plot(g)
214
+
215
+ We ignore function values that are infinite or NaN::
216
+
217
+ sage: x, y = var('x y')
218
+ sage: streamline_plot((-x/sqrt(x^2+y^2), -y/sqrt(x^2+y^2)),
219
+ ....: (x,-10,10), (y,-10,10))
220
+ Graphics object consisting of 1 graphics primitive
221
+
222
+ .. PLOT::
223
+
224
+ x, y = var('x y')
225
+ g = streamline_plot((-x/sqrt(x**2+y**2), -y/sqrt(x**2+y**2)), (x,-10,10), (y,-10,10))
226
+ sphinx_plot(g)
227
+
228
+ Extra options will get passed on to :func:`show()`, as long as they
229
+ are valid::
230
+
231
+ sage: streamline_plot((x, y), (x,-2,2), (y,-2,2), xmax=10)
232
+ Graphics object consisting of 1 graphics primitive
233
+ sage: streamline_plot((x, y), (x,-2,2), (y,-2,2)).show(xmax=10) # These are equivalent
234
+
235
+ .. PLOT::
236
+
237
+ x, y = var('x y')
238
+ g = streamline_plot((x, y), (x,-2,2), (y,-2,2), xmax=10)
239
+ sphinx_plot(g)
240
+
241
+ We can also construct streamlines in a slope field::
242
+
243
+ sage: x, y = var('x y')
244
+ sage: streamline_plot((x + y) / sqrt(x^2 + y^2), (x,-3,3), (y,-3,3))
245
+ Graphics object consisting of 1 graphics primitive
246
+
247
+ .. PLOT::
248
+
249
+ x, y = var('x y')
250
+ g = streamline_plot((x + y) / sqrt(x**2 + y**2), (x,-3,3), (y,-3,3))
251
+ sphinx_plot(g)
252
+
253
+ We choose some particular points the streamlines pass through::
254
+
255
+ sage: pts = [[1, 1], [-2, 2], [1, -3/2]]
256
+ sage: g = streamline_plot((x + y) / sqrt(x^2 + y^2),
257
+ ....: (x,-3,3), (y,-3,3), start_points=pts)
258
+ sage: g += point(pts, color='red')
259
+ sage: g
260
+ Graphics object consisting of 2 graphics primitives
261
+
262
+ .. PLOT::
263
+
264
+ x, y = var('x y')
265
+ pts = [[1, 1], [-2, 2], [1, -3/2]]
266
+ g = streamline_plot((x + y) / sqrt(x**2 + y**2), (x,-3,3), (y,-3,3), start_points=pts)
267
+ g += point(pts, color='red')
268
+ sphinx_plot(g)
269
+
270
+ .. NOTE::
271
+
272
+ Streamlines currently pass close to ``start_points`` but do
273
+ not necessarily pass directly through them. That is part of
274
+ the behavior of matplotlib, not an error on your part.
275
+ """
276
+ # Parse the function input
277
+ if isinstance(f_g, (list, tuple)):
278
+ (f,g) = f_g
279
+ else:
280
+ from sage.misc.functional import sqrt
281
+ from sage.misc.sageinspect import is_function_or_cython_function
282
+ if is_function_or_cython_function(f_g):
283
+ f = lambda x,y: 1 / sqrt(f_g(x, y)**2 + 1)
284
+ g = lambda x,y: f_g(x, y) * f(x, y)
285
+ else:
286
+ f = 1 / sqrt(f_g**2 + 1)
287
+ g = f_g * f
288
+
289
+ from sage.plot.all import Graphics
290
+ from sage.plot.misc import setup_for_eval_on_grid
291
+ z, ranges = setup_for_eval_on_grid([f,g], [xrange,yrange], options['plot_points'])
292
+ f, g = z
293
+
294
+ # The density values must be floats
295
+ if isinstance(options['density'], (list, tuple)):
296
+ options['density'] = [float(x) for x in options['density']]
297
+ else:
298
+ options['density'] = float(options['density'])
299
+
300
+ ypos_array, xvec_array, yvec_array = [], [], []
301
+ xpos_array = list(xsrange(*ranges[0], include_endpoint=True))
302
+ for y in xsrange(*ranges[1], include_endpoint=True):
303
+ ypos_array.append(y)
304
+ xvec_row, yvec_row = [], []
305
+ for x in xsrange(*ranges[0], include_endpoint=True):
306
+ xvec_row.append(f(x, y))
307
+ yvec_row.append(g(x, y))
308
+ xvec_array.append(xvec_row)
309
+ yvec_array.append(yvec_row)
310
+
311
+ import numpy
312
+ xpos_array = numpy.array(xpos_array, dtype=float)
313
+ ypos_array = numpy.array(ypos_array, dtype=float)
314
+ xvec_array = numpy.ma.masked_invalid(numpy.array(xvec_array, dtype=float))
315
+ yvec_array = numpy.ma.masked_invalid(numpy.array(yvec_array, dtype=float))
316
+
317
+ if 'start_points' in options:
318
+ xstart_array, ystart_array = [], []
319
+ for point in options['start_points']:
320
+ xstart_array.append(point[0])
321
+ ystart_array.append(point[1])
322
+ options['start_points'] = numpy.array([xstart_array, ystart_array]).T
323
+
324
+ g = Graphics()
325
+ g._set_extra_kwds(Graphics._extract_kwds_for_show(options))
326
+ g.add_primitive(StreamlinePlot(xpos_array, ypos_array,
327
+ xvec_array, yvec_array, options))
328
+ return g