sympy-plot-backends 4.2.0__tar.gz → 4.2.1__tar.gz
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.
- {sympy_plot_backends-4.2.0/sympy_plot_backends.egg-info → sympy_plot_backends-4.2.1}/PKG-INFO +1 -1
- sympy_plot_backends-4.2.1/spb/_version.py +1 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/functions_2d.py +224 -17
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/functions_2d.py +97 -4
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1/sympy_plot_backends.egg-info}/PKG-INFO +1 -1
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_functions_2d.py +152 -3
- sympy_plot_backends-4.2.0/spb/_version.py +0 -1
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/LICENSE +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/MANIFEST.in +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/README.md +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/setup.cfg +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/setup.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/animation/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/animation/ipywidgets.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/animation/panel.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/base_backend.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/base_renderer.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/bokeh.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/arrow2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/complex.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/contour.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/generic.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/geometry.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/hvline.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/line2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/mcircles.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/ngrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/nichols.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/nyquist.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/polezero.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/root_locus.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/sgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/vector2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/bokeh/renderers/zgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/k3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/arrow3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/complex.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/geometry.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/implicit3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/line3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/surface.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/k3d/renderers/vector3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/matplotlib.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/_sgrid_helper.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/arrow2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/arrow3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/complex.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/contour.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/generic.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/geometry.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/hvline.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/implicit2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/implicit3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/line2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/line3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/mcircles.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/ngrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/nichols.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/nyquist.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/polezero.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/renderer.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/root_locus.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/sgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/surface.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/vector2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/vector3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/matplotlib/renderers/zgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/plotly.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/arrow2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/complex.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/contour.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/generic.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/geometry.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/hvline.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/implicit3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/line2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/line3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/surface.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/vector2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/plotly/renderers/vector3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/backends/utils.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/defaults.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/doc_utils/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/doc_utils/docstrings.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/doc_utils/html.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/doc_utils/ipython.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/complex_analysis.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/control.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/functions_3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/graphics.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/utils.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/vector_transforms.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/graphics/vectors.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/bootstrap_spb/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/bootstrap_spb/bootstrap.css +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/bootstrap_spb/bootstrap.html +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/ipywidgets.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/interactive/panel.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/complex_analysis.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/control.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/functions_3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plot_functions/vectors.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/plotgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/base.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/complex_analysis.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/control.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/evaluator.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/series_2d_3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/series/vectors.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/utils.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/spb/wegert.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/sympy_plot_backends.egg-info/SOURCES.txt +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/sympy_plot_backends.egg-info/dependency_links.txt +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/sympy_plot_backends.egg-info/not-zip-safe +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/sympy_plot_backends.egg-info/requires.txt +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/sympy_plot_backends.egg-info/top_level.txt +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/animation/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/animation/test_animation.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/animation/test_panel_ipywidgets.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/make_tests.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_base_backend.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_bokeh.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_color_utils.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_k3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_matplotlib.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/backends/test_plotly.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/doc_utils/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/doc_utils/test_html.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/doc_utils/test_ipython.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_complex_analysis.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_control.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_control_min_module.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_functions_2d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_functions_3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_graphics.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_vector_transformation.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/graphics/test_vectors.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/interactive/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/interactive/test_interactive.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/interactive/test_ipywidgets.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/interactive/test_panel.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/__init__.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_complex.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_control.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_functions_3d.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_vectors.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/test_defaults.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/test_plotgrid.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/test_series.py +0 -0
- {sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/test_utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "4.2.1"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
from sympy import (
|
|
2
2
|
sin, cos, Piecewise, piecewise_fold, Interval, Union,
|
|
3
|
-
FiniteSet, Eq, Ne, Expr, Plane, Curve, Point3D
|
|
3
|
+
FiniteSet, Eq, Ne, Expr, Plane, Curve, Point3D,
|
|
4
|
+
And, Heaviside, ceiling, degree, floor, frac, limit, sign, solveset,
|
|
5
|
+
together, oo, S
|
|
4
6
|
)
|
|
7
|
+
from sympy.calculus.singularities import singularities
|
|
5
8
|
from sympy.core.relational import Relational
|
|
6
9
|
from sympy.geometry.line import LinearEntity3D
|
|
7
10
|
# NOTE: from sympy import EmptySet is a different thing!!!
|
|
@@ -20,6 +23,30 @@ from spb.utils import (
|
|
|
20
23
|
import warnings
|
|
21
24
|
|
|
22
25
|
|
|
26
|
+
def _zero_length_as_point(_set):
|
|
27
|
+
# with a float range SymPy may keep an interval such as
|
|
28
|
+
# Interval(3, 3.0), which holds a single point
|
|
29
|
+
if isinstance(_set, Interval) and (_set.end - _set.start).is_zero:
|
|
30
|
+
if _set.left_open or _set.right_open:
|
|
31
|
+
return S.EmptySet
|
|
32
|
+
return FiniteSet(_set.start)
|
|
33
|
+
return _set
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _dot_at(range_end, data_end, cond):
|
|
37
|
+
# whether to draw a dot at an end of a piece: always inside the plotting
|
|
38
|
+
# range, and at an end of the range only where the piece itself starts
|
|
39
|
+
# or ends (``cond`` is the set of the piece)
|
|
40
|
+
# NOTE: starting with SymPy 1.13, == means structural
|
|
41
|
+
# equality also for Float/Integer/Rational
|
|
42
|
+
if not range_end.equals(data_end):
|
|
43
|
+
return True
|
|
44
|
+
try:
|
|
45
|
+
return cond.boundary.contains(range_end) is S.true
|
|
46
|
+
except Exception:
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
|
|
23
50
|
def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
24
51
|
"""
|
|
25
52
|
Extract the pieces of an univariate Piecewise function and create the
|
|
@@ -51,7 +78,8 @@ def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
|
51
78
|
filled_series = []
|
|
52
79
|
dots = kwargs.pop("dots", True)
|
|
53
80
|
|
|
54
|
-
def func(expr, _set, c, from_union=False):
|
|
81
|
+
def func(expr, _set, c, from_union=False, cond=S.EmptySet):
|
|
82
|
+
_set = _zero_length_as_point(_set)
|
|
55
83
|
if isinstance(_set, Interval):
|
|
56
84
|
start, end = _set.args[0], _set.args[1]
|
|
57
85
|
|
|
@@ -64,7 +92,7 @@ def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
|
64
92
|
while diff < 1:
|
|
65
93
|
diff *= 10
|
|
66
94
|
e -= 1
|
|
67
|
-
offset *= e
|
|
95
|
+
offset *= 10**e
|
|
68
96
|
|
|
69
97
|
# prevent NaNs from happening at the ends of the interval
|
|
70
98
|
if _set.left_open:
|
|
@@ -78,16 +106,14 @@ def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
|
78
106
|
|
|
79
107
|
if dots:
|
|
80
108
|
xx, yy = main_series.get_data()
|
|
81
|
-
|
|
82
|
-
# equality also for Float/Integer/Rational
|
|
83
|
-
if not _range[1].equals(xx[0]):
|
|
109
|
+
if _dot_at(_range[1], xx[0], cond):
|
|
84
110
|
correct_list = series if _set.left_open else filled_series
|
|
85
111
|
correct_list.append(
|
|
86
112
|
List2DSeries(
|
|
87
113
|
[xx[0]], [yy[0]], is_scatter=True,
|
|
88
114
|
fill=not _set.left_open, **kwargs)
|
|
89
115
|
)
|
|
90
|
-
if
|
|
116
|
+
if _dot_at(_range[2], xx[-1], cond):
|
|
91
117
|
correct_list = series if _set.right_open else filled_series
|
|
92
118
|
correct_list.append(
|
|
93
119
|
List2DSeries(
|
|
@@ -95,17 +121,18 @@ def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
|
95
121
|
fill=not _set.right_open, **kwargs)
|
|
96
122
|
)
|
|
97
123
|
elif isinstance(_set, FiniteSet):
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
if dots:
|
|
125
|
+
loc, val = [], []
|
|
126
|
+
for _loc in _set.args:
|
|
127
|
+
loc.append(float(_loc))
|
|
128
|
+
val.append(float(expr.evalf(subs={_range[0]: _loc})))
|
|
129
|
+
filled_series.append(
|
|
130
|
+
List2DSeries(loc, val, is_scatter=True, fill=True, **kwargs))
|
|
131
|
+
if not from_union:
|
|
132
|
+
c += 1
|
|
106
133
|
elif isinstance(_set, Union):
|
|
107
134
|
for _s in _set.args:
|
|
108
|
-
c = func(expr, _s, c, from_union=True)
|
|
135
|
+
c = func(expr, _s, c, from_union=True, cond=cond)
|
|
109
136
|
elif isinstance(_set, EmptySet):
|
|
110
137
|
# in this case, some pieces are outside of the provided range.
|
|
111
138
|
# don't add any series, but increase the counter nonetheless so
|
|
@@ -128,12 +155,190 @@ def _process_piecewise(piecewise, _range, label, **kwargs):
|
|
|
128
155
|
# for the label, attach the number of the piece
|
|
129
156
|
count = 1
|
|
130
157
|
for expr, cond in expr_cond:
|
|
131
|
-
count = func(expr, irange.intersection(cond), count)
|
|
158
|
+
count = func(expr, irange.intersection(cond), count, cond=cond)
|
|
132
159
|
|
|
133
160
|
series += filled_series
|
|
134
161
|
return series
|
|
135
162
|
|
|
136
163
|
|
|
164
|
+
def _jumps_to_piecewise(expr, _range, max_pieces=100):
|
|
165
|
+
"""
|
|
166
|
+
Rewrite sign, Heaviside, floor, ceiling and frac as Piecewise over the
|
|
167
|
+
plotting range, so that their jumps are drawn with dots.
|
|
168
|
+
|
|
169
|
+
floor, ceiling and frac are rewritten only when their argument is linear
|
|
170
|
+
in the plotting variable and the range covers at most ``max_pieces``
|
|
171
|
+
integer steps. Otherwise they are left unchanged.
|
|
172
|
+
"""
|
|
173
|
+
x, a, b = _range
|
|
174
|
+
|
|
175
|
+
def steps(g, kind):
|
|
176
|
+
if not g.is_polynomial(x) or degree(g, x) != 1:
|
|
177
|
+
return None
|
|
178
|
+
lo, hi = sorted([g.subs(x, a), g.subs(x, b)])
|
|
179
|
+
if hi - lo > max_pieces:
|
|
180
|
+
return None
|
|
181
|
+
if kind == "floor":
|
|
182
|
+
return Piecewise(*[
|
|
183
|
+
(k, (g >= k) & (g < k + 1))
|
|
184
|
+
for k in range(int(floor(lo)), int(floor(hi)) + 1)])
|
|
185
|
+
return Piecewise(*[
|
|
186
|
+
(k, (g > k - 1) & (g <= k))
|
|
187
|
+
for k in range(int(ceiling(lo)), int(ceiling(hi)) + 1)])
|
|
188
|
+
|
|
189
|
+
def rewrite(e):
|
|
190
|
+
g = e.args[0]
|
|
191
|
+
if isinstance(e, sign):
|
|
192
|
+
# the plotting variable is real; SymPy only rewrites sign of a
|
|
193
|
+
# real argument, so build the same Piecewise here
|
|
194
|
+
return Piecewise((1, g > 0), (-1, g < 0), (0, True))
|
|
195
|
+
if isinstance(e, Heaviside):
|
|
196
|
+
return e.rewrite(Piecewise)
|
|
197
|
+
new = steps(g, "ceiling" if isinstance(e, ceiling) else "floor")
|
|
198
|
+
if new is None:
|
|
199
|
+
return e
|
|
200
|
+
# frac(g) = g - floor(g)
|
|
201
|
+
return g - new if isinstance(e, frac) else new
|
|
202
|
+
|
|
203
|
+
def is_jump(e):
|
|
204
|
+
jump_types = (sign, Heaviside, floor, ceiling, frac)
|
|
205
|
+
return isinstance(e, jump_types) and e.has(x)
|
|
206
|
+
|
|
207
|
+
return piecewise_fold(expr.replace(is_jump, rewrite))
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
def _removable_points(expr, _range, max_points=20):
|
|
211
|
+
"""
|
|
212
|
+
Return the points of the plotting range where ``expr`` is undefined
|
|
213
|
+
(a zero of its denominator) but both one-sided limits are finite, as
|
|
214
|
+
for the hole of (x**2 - 1) / (x - 1) at x = 1 or the jump of
|
|
215
|
+
Abs(x) / x at x = 0. Poles are not returned.
|
|
216
|
+
|
|
217
|
+
Only denominators that are polynomials in the plotting variable are
|
|
218
|
+
examined. For a Piecewise, each piece is examined in the set where it
|
|
219
|
+
applies.
|
|
220
|
+
"""
|
|
221
|
+
x, a, b = _range
|
|
222
|
+
if isinstance(expr, Piecewise):
|
|
223
|
+
points = set()
|
|
224
|
+
for e, s in expr.as_expr_set_pairs():
|
|
225
|
+
points.update(
|
|
226
|
+
c for c in _removable_points(e, _range, max_points)
|
|
227
|
+
if c in s)
|
|
228
|
+
return sorted(points)
|
|
229
|
+
|
|
230
|
+
den = together(expr).as_numer_denom()[1]
|
|
231
|
+
if not den.has(x) or not den.is_polynomial(x):
|
|
232
|
+
return []
|
|
233
|
+
|
|
234
|
+
# NOTE/TODO: solveset is prone to hanging
|
|
235
|
+
zeros = solveset(den, x, Interval(a, b))
|
|
236
|
+
if not isinstance(zeros, FiniteSet) or len(zeros) > max_points:
|
|
237
|
+
return []
|
|
238
|
+
|
|
239
|
+
points = []
|
|
240
|
+
for c in sorted(zeros):
|
|
241
|
+
sides = (["-"] if c > a else []) + (["+"] if c < b else [])
|
|
242
|
+
try:
|
|
243
|
+
limits = [limit(expr, x, c, side) for side in sides]
|
|
244
|
+
except (NotImplementedError, ValueError, TypeError):
|
|
245
|
+
continue
|
|
246
|
+
if limits and all(lim.is_finite for lim in limits):
|
|
247
|
+
points.append(c)
|
|
248
|
+
return points
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _pieces_and_sets(expr, _range):
|
|
252
|
+
"""The pieces of ``expr``, each with the set where it applies, after
|
|
253
|
+
the functions that jump are rewritten as Piecewise."""
|
|
254
|
+
expr = _jumps_to_piecewise(expr, _range)
|
|
255
|
+
if isinstance(expr, Piecewise):
|
|
256
|
+
return expr.as_expr_set_pairs()
|
|
257
|
+
return [(expr, S.Reals)]
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _real_singularities(e, x, domain):
|
|
261
|
+
"""singularities(e, x, domain), without calling it for a polynomial."""
|
|
262
|
+
if e.is_polynomial(x):
|
|
263
|
+
return S.EmptySet
|
|
264
|
+
return singularities(e, x, domain)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _piece_ends(expr, _range):
|
|
268
|
+
"""The ends of the pieces of ``expr`` in the plotting range."""
|
|
269
|
+
x, a, b = _range
|
|
270
|
+
ends = set()
|
|
271
|
+
try:
|
|
272
|
+
for e, s in _pieces_and_sets(expr, _range):
|
|
273
|
+
boundary = s.intersect(Interval(a, b)).boundary
|
|
274
|
+
if isinstance(boundary, FiniteSet):
|
|
275
|
+
ends.update(boundary)
|
|
276
|
+
except Exception:
|
|
277
|
+
pass
|
|
278
|
+
return ends
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def _infinite_limit(e, x, s, c):
|
|
282
|
+
"""Whether a one-sided limit of ``e`` at ``c`` is infinite, from a side
|
|
283
|
+
of ``c`` where the set ``s`` of the piece applies."""
|
|
284
|
+
for d, t in (("-", c - 1), ("+", c + 1)):
|
|
285
|
+
if s.intersect(Interval(*sorted([c, t]))).measure:
|
|
286
|
+
if limit(e, x, c, d).has(oo, -oo, S.ComplexInfinity):
|
|
287
|
+
return True
|
|
288
|
+
return False
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def _vertical_asymptotes(expr, _range, max_points=50):
|
|
292
|
+
"""Points inside the plotting range where a one-sided limit of ``expr``
|
|
293
|
+
is infinite. Empty if they cannot be computed."""
|
|
294
|
+
x, a, b = _range
|
|
295
|
+
window = Interval(a, b)
|
|
296
|
+
points = set()
|
|
297
|
+
try:
|
|
298
|
+
# quick exit, before the pieces are computed
|
|
299
|
+
if _real_singularities(expr, x, window).is_empty:
|
|
300
|
+
return []
|
|
301
|
+
except Exception:
|
|
302
|
+
pass
|
|
303
|
+
try:
|
|
304
|
+
for e, s in _pieces_and_sets(expr, _range):
|
|
305
|
+
s = s.intersect(window)
|
|
306
|
+
if s.is_empty:
|
|
307
|
+
continue
|
|
308
|
+
candidates = _real_singularities(e, x, window).intersect(
|
|
309
|
+
s.closure)
|
|
310
|
+
if candidates.is_empty:
|
|
311
|
+
continue
|
|
312
|
+
if (
|
|
313
|
+
not isinstance(candidates, FiniteSet)
|
|
314
|
+
or len(candidates) > max_points
|
|
315
|
+
):
|
|
316
|
+
return []
|
|
317
|
+
points.update(
|
|
318
|
+
c for c in candidates
|
|
319
|
+
if c not in (a, b) and _infinite_limit(e, x, s, c))
|
|
320
|
+
except Exception:
|
|
321
|
+
return []
|
|
322
|
+
return sorted(points)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _prepare_piecewise(expr, _range):
|
|
326
|
+
"""
|
|
327
|
+
Prepare an expression for ``_process_piecewise``: rewrite the functions
|
|
328
|
+
that jump, and remove from the domain the points where the expression is
|
|
329
|
+
undefined but has finite one-sided limits, so that they get empty dots.
|
|
330
|
+
"""
|
|
331
|
+
# rewrite first: SymPy's limit can hang on an expression containing
|
|
332
|
+
# Heaviside, for example sin(x)/x + Heaviside(x - 1) at x = 0
|
|
333
|
+
expr = _jumps_to_piecewise(expr, _range)
|
|
334
|
+
points = _removable_points(expr, _range)
|
|
335
|
+
if points:
|
|
336
|
+
x = _range[0]
|
|
337
|
+
expr = piecewise_fold(
|
|
338
|
+
Piecewise((expr, And(*[Ne(x, c) for c in points]))))
|
|
339
|
+
return expr
|
|
340
|
+
|
|
341
|
+
|
|
137
342
|
def _build_line_series(expr, r, label, **kwargs):
|
|
138
343
|
"""
|
|
139
344
|
Loop over the provided arguments. If a piecewise function is found,
|
|
@@ -141,6 +346,8 @@ def _build_line_series(expr, r, label, **kwargs):
|
|
|
141
346
|
"""
|
|
142
347
|
series = []
|
|
143
348
|
pp = kwargs.get("process_piecewise", False)
|
|
349
|
+
if not callable(expr) and pp:
|
|
350
|
+
expr = _prepare_piecewise(expr, r)
|
|
144
351
|
if not callable(expr) and expr.has(Piecewise) and pp:
|
|
145
352
|
series += _process_piecewise(expr, r, label, **kwargs)
|
|
146
353
|
else:
|
|
@@ -23,6 +23,7 @@ from spb.graphics import (
|
|
|
23
23
|
graphics, line, line_parametric_2d,
|
|
24
24
|
surface, contour, implicit_2d, list_2d, geometry
|
|
25
25
|
)
|
|
26
|
+
from spb.graphics.functions_2d import _piece_ends, _vertical_asymptotes
|
|
26
27
|
from spb.series import (
|
|
27
28
|
Parametric2DLineSeries, PlaneSeries, GenericDataSeries,
|
|
28
29
|
LineOver1DRangeSeries, List2DSeries, ImplicitSeries, ContourSeries,
|
|
@@ -1700,11 +1701,76 @@ def plot_list(*args, **kwargs):
|
|
|
1700
1701
|
return graphics(*series, **kwargs)
|
|
1701
1702
|
|
|
1702
1703
|
|
|
1704
|
+
def _split_range(expr, _range, asymptotes):
|
|
1705
|
+
"""Split the plotting range at the vertical asymptotes that are inside a
|
|
1706
|
+
piece, so that the curve is not joined across them. (At the ends of the
|
|
1707
|
+
pieces the curve is already split.)"""
|
|
1708
|
+
if not asymptotes:
|
|
1709
|
+
return [_range]
|
|
1710
|
+
x, start, end = _range
|
|
1711
|
+
ends = _piece_ends(expr, _range)
|
|
1712
|
+
cuts = [c for c in asymptotes if c not in ends]
|
|
1713
|
+
if not cuts:
|
|
1714
|
+
return [_range]
|
|
1715
|
+
offset = (end - start) * 1e-6
|
|
1716
|
+
bounds = [start] + [b for c in cuts for b in (c - offset, c + offset)]
|
|
1717
|
+
bounds.append(end)
|
|
1718
|
+
return [(x, bounds[i], bounds[i + 1]) for i in range(0, len(bounds), 2)]
|
|
1719
|
+
|
|
1720
|
+
|
|
1721
|
+
def _line_split_at_asymptotes(expr, r, lbl, rkw, **kwargs):
|
|
1722
|
+
"""The series of ``line`` for ``expr``, with the plotting range split at
|
|
1723
|
+
its vertical asymptotes, and the asymptotes."""
|
|
1724
|
+
asymptotes = _vertical_asymptotes(expr, r)
|
|
1725
|
+
series = []
|
|
1726
|
+
for sub_range in _split_range(expr, r, asymptotes):
|
|
1727
|
+
series += line(expr, sub_range, lbl, rkw, **kwargs)
|
|
1728
|
+
return series, asymptotes
|
|
1729
|
+
|
|
1730
|
+
|
|
1731
|
+
def _ylim_away_from_asymptotes(groups):
|
|
1732
|
+
"""y-limits from the values of the curves that are not close to a
|
|
1733
|
+
vertical asymptote: the values close to it would hide the rest of the
|
|
1734
|
+
plot. ``groups`` holds (series, asymptotes, distance) for each
|
|
1735
|
+
expression. None if there are no vertical asymptotes."""
|
|
1736
|
+
if not any(g[1] for g in groups):
|
|
1737
|
+
return None
|
|
1738
|
+
np = import_module("numpy")
|
|
1739
|
+
values = []
|
|
1740
|
+
for series, asymptotes, distance in groups:
|
|
1741
|
+
for s in series:
|
|
1742
|
+
if not isinstance(s, (LineOver1DRangeSeries, List2DSeries)):
|
|
1743
|
+
continue
|
|
1744
|
+
xx, yy = s.get_data()[:2]
|
|
1745
|
+
xx = np.asarray(xx, dtype=float)
|
|
1746
|
+
yy = np.asarray(yy, dtype=float)
|
|
1747
|
+
keep = np.isfinite(yy)
|
|
1748
|
+
for c in asymptotes:
|
|
1749
|
+
keep &= np.abs(xx - float(c)) > float(distance)
|
|
1750
|
+
values.append(yy[keep])
|
|
1751
|
+
values = np.concatenate(values) if values else np.array([])
|
|
1752
|
+
if values.size == 0:
|
|
1753
|
+
return None
|
|
1754
|
+
low, high = float(values.min()), float(values.max())
|
|
1755
|
+
margin = 0.1 * (high - low) if high > low else 1
|
|
1756
|
+
return (low - margin, high + margin)
|
|
1757
|
+
|
|
1758
|
+
|
|
1703
1759
|
@modify_plot_functions_doc(LineOver1DRangeSeries, replace=_repl)
|
|
1704
1760
|
def plot_piecewise(*args, **kwargs):
|
|
1705
1761
|
"""
|
|
1706
1762
|
Plots univariate piecewise functions.
|
|
1707
1763
|
|
|
1764
|
+
Jumps are shown with filled and empty dots. Expressions containing
|
|
1765
|
+
``sign``, ``Heaviside``, ``floor``, ``ceiling`` or ``frac`` are rewritten
|
|
1766
|
+
as piecewise functions over the plotting range; for ``floor``,
|
|
1767
|
+
``ceiling`` and ``frac`` this requires an argument that is linear in the
|
|
1768
|
+
plotting variable. Points where the expression is undefined but has
|
|
1769
|
+
finite one-sided limits, such as ``x = 1`` for ``(x**2 - 1) / (x - 1)``,
|
|
1770
|
+
get empty dots. The curve is not joined across a vertical asymptote, such
|
|
1771
|
+
as ``x = 1`` for ``1 / (x - 1)``; if ``ylim`` is not given, the y-limits
|
|
1772
|
+
are chosen from the values that are not close to the vertical asymptotes.
|
|
1773
|
+
|
|
1708
1774
|
Typical usage examples are in the followings:
|
|
1709
1775
|
|
|
1710
1776
|
- Plotting a single expression with the default range (-10, 10):
|
|
@@ -1776,6 +1842,24 @@ def plot_piecewise(*args, **kwargs):
|
|
|
1776
1842
|
[0]: cartesian line: 0 for x over (-10, 0)
|
|
1777
1843
|
[1]: cartesian line: 1 for x over (1.00000000000000e-6, 10)
|
|
1778
1844
|
|
|
1845
|
+
Functions with jumps, such as ``floor``, are rewritten as piecewise
|
|
1846
|
+
functions:
|
|
1847
|
+
|
|
1848
|
+
.. plot::
|
|
1849
|
+
:context: close-figs
|
|
1850
|
+
:format: doctest
|
|
1851
|
+
:include-source: True
|
|
1852
|
+
|
|
1853
|
+
>>> from sympy import floor
|
|
1854
|
+
>>> plot_piecewise(floor(x), (x, -1, 1))
|
|
1855
|
+
Plot object containing:
|
|
1856
|
+
[0]: cartesian line: -1 for x over (-1, -1.00000000000000e-6)
|
|
1857
|
+
[1]: 2D list plot
|
|
1858
|
+
[2]: cartesian line: 0 for x over (0, 0.999999000000000)
|
|
1859
|
+
[3]: 2D list plot
|
|
1860
|
+
[4]: 2D list plot
|
|
1861
|
+
[5]: 2D list plot
|
|
1862
|
+
|
|
1779
1863
|
Plot multiple expressions in which the second piecewise expression has
|
|
1780
1864
|
a dotted line style. Use the ``label`` keyword argument to set the
|
|
1781
1865
|
appropriate entries for the legend:
|
|
@@ -1799,11 +1883,12 @@ def plot_piecewise(*args, **kwargs):
|
|
|
1799
1883
|
[3]: 2D list plot
|
|
1800
1884
|
[4]: cartesian line: sin(x) for x over (-8, -5.00000100000000)
|
|
1801
1885
|
[5]: 2D list plot
|
|
1802
|
-
[6]: cartesian line:
|
|
1886
|
+
[6]: cartesian line: 1/x for x over (-5, -1.60000000000000e-5)
|
|
1803
1887
|
[7]: 2D list plot
|
|
1804
|
-
[8]: cartesian line:
|
|
1888
|
+
[8]: cartesian line: cos(x) for x over (5.00000100000000, 8)
|
|
1805
1889
|
[9]: 2D list plot
|
|
1806
|
-
[10]:
|
|
1890
|
+
[10]: cartesian line: 1/x for x over (1.60000000000000e-5, 5)
|
|
1891
|
+
[11]: 2D list plot
|
|
1807
1892
|
|
|
1808
1893
|
See Also
|
|
1809
1894
|
========
|
|
@@ -1844,9 +1929,12 @@ def plot_piecewise(*args, **kwargs):
|
|
|
1844
1929
|
# If a user want to set custom rendering keywords, just use the notation
|
|
1845
1930
|
# (expr, range, label [optional], rendering_kw [optional])
|
|
1846
1931
|
color_series_dict = dict()
|
|
1932
|
+
window_groups = []
|
|
1847
1933
|
for i, a in enumerate(plot_expr):
|
|
1848
1934
|
expr, r, lbl, rkw = a
|
|
1849
|
-
series =
|
|
1935
|
+
series, asymptotes = _line_split_at_asymptotes(
|
|
1936
|
+
expr, r, lbl, rkw, **kwargs)
|
|
1937
|
+
window_groups.append((list(series), asymptotes, (r[2] - r[1]) / 50))
|
|
1850
1938
|
if i < len(labels):
|
|
1851
1939
|
# this solve issue 32:
|
|
1852
1940
|
# https://github.com/Davide-sd/sympy-plot-backends/issues/32
|
|
@@ -1859,6 +1947,11 @@ def plot_piecewise(*args, **kwargs):
|
|
|
1859
1947
|
s.label = ""
|
|
1860
1948
|
color_series_dict[i] = series
|
|
1861
1949
|
|
|
1950
|
+
# the y-limits come from the values that are not close to a vertical
|
|
1951
|
+
# asymptote
|
|
1952
|
+
if "ylim" not in kwargs:
|
|
1953
|
+
kwargs["ylim"] = _ylim_away_from_asymptotes(window_groups)
|
|
1954
|
+
|
|
1862
1955
|
# NOTE: let's overwrite this keyword argument: the dictionary will be used
|
|
1863
1956
|
# by the backend to assign the proper colors to the pieces
|
|
1864
1957
|
kwargs["process_piecewise"] = color_series_dict
|
{sympy_plot_backends-4.2.0 → sympy_plot_backends-4.2.1}/tests/plot_functions/test_functions_2d.py
RENAMED
|
@@ -20,7 +20,7 @@ from sympy import (
|
|
|
20
20
|
And, Or, Eq, Ne, Interval, Sum, oo, I, pi, S,
|
|
21
21
|
sympify, Integral, Circle, Point, Ellipse, Rational,
|
|
22
22
|
Polygon, Curve, Segment, Point2D, Point3D, Line3D, Plane, IndexedBase,
|
|
23
|
-
Function
|
|
23
|
+
Function, sign, floor, ceiling, frac
|
|
24
24
|
)
|
|
25
25
|
from sympy.testing.pytest import skip
|
|
26
26
|
from sympy.external import import_module
|
|
@@ -606,8 +606,8 @@ def test_plot_piecewise_dot_false(p_options):
|
|
|
606
606
|
|
|
607
607
|
f = Piecewise((x**2, x < 2), (5, Eq(x, 2)), (10 - x, True))
|
|
608
608
|
p = plot_piecewise(f, (x, -2, 5), dots=False, **p_options)
|
|
609
|
-
assert len(p.series) ==
|
|
610
|
-
assert len([t for t in p.series if isinstance(t, List2DSeries)]) ==
|
|
609
|
+
assert len(p.series) == 2
|
|
610
|
+
assert len([t for t in p.series if isinstance(t, List2DSeries)]) == 0
|
|
611
611
|
|
|
612
612
|
|
|
613
613
|
def test_plot_piecewise_lambda_functions(p_options):
|
|
@@ -634,6 +634,155 @@ def test_plot_piecewise_multiple_functions(p_options):
|
|
|
634
634
|
assert len([s for s in p.series if s.get_label(True)]) == 2
|
|
635
635
|
|
|
636
636
|
|
|
637
|
+
def _dots(p):
|
|
638
|
+
# (x, y, filled) of every dot of a plot, rounded and sorted
|
|
639
|
+
return sorted(
|
|
640
|
+
(round(float(t.get_data()[0][i]), 3) + 0.0,
|
|
641
|
+
round(float(t.get_data()[1][i]), 3) + 0.0, t.is_filled)
|
|
642
|
+
for t in p.series if isinstance(t, List2DSeries)
|
|
643
|
+
for i in range(len(t.get_data()[0])))
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
def test_plot_piecewise_jump_functions(p_options):
|
|
647
|
+
# Verify that sign, Heaviside, floor, ceiling and frac are rewritten as
|
|
648
|
+
# Piecewise, so that their jumps get filled and empty dots instead of
|
|
649
|
+
# vertical lines.
|
|
650
|
+
|
|
651
|
+
x = symbols("x")
|
|
652
|
+
p = plot_piecewise(sign(x), (x, -2, 2), **p_options)
|
|
653
|
+
assert _dots(p) == [(0, -1, False), (0, 0, True), (0, 1, False)]
|
|
654
|
+
|
|
655
|
+
p = plot_piecewise(Heaviside(x), (x, -2, 2), **p_options)
|
|
656
|
+
assert _dots(p) == [(0, 0, False), (0, 0.5, True), (0, 1, False)]
|
|
657
|
+
|
|
658
|
+
p = plot_piecewise(floor(x), (x, -1, 2), **p_options)
|
|
659
|
+
assert _dots(p) == [
|
|
660
|
+
(-1, -1, True), (0, -1, False), (0, 0, True), (1, 0, False),
|
|
661
|
+
(1, 1, True), (2, 1, False), (2, 2, True)]
|
|
662
|
+
|
|
663
|
+
p = plot_piecewise(ceiling(x), (x, -1, 1), **p_options)
|
|
664
|
+
assert _dots(p) == [(-1, -1, True), (-1, 0, False), (0, 0, True),
|
|
665
|
+
(0, 1, False), (1, 1, True)]
|
|
666
|
+
|
|
667
|
+
p = plot_piecewise(frac(x), (x, 0, 2), **p_options)
|
|
668
|
+
assert _dots(p) == [(0, 0, True), (1, 0, True), (1, 1, False),
|
|
669
|
+
(2, 0, True), (2, 1, False)]
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def test_plot_piecewise_dot_at_range_end(p_options):
|
|
673
|
+
# Verify that a dot is drawn at an end of the plotting range where a
|
|
674
|
+
# piece starts or ends, but not where the range only cuts a piece.
|
|
675
|
+
|
|
676
|
+
x = symbols("x")
|
|
677
|
+
floor_dots = [
|
|
678
|
+
(-2, -2, True), (-1, -2, False), (-1, -1, True), (0, -1, False),
|
|
679
|
+
(0, 0, True), (1, 0, False), (1, 1, True), (2, 1, False),
|
|
680
|
+
(2, 2, True), (3, 2, False), (3, 3, True)]
|
|
681
|
+
p = plot_piecewise(floor(x), (x, -2, 3), **p_options)
|
|
682
|
+
assert _dots(p) == floor_dots
|
|
683
|
+
|
|
684
|
+
# float limits give the same dots
|
|
685
|
+
p = plot_piecewise(floor(x), (x, -2.0, 3.0), **p_options)
|
|
686
|
+
assert _dots(p) == floor_dots
|
|
687
|
+
|
|
688
|
+
# the range cuts the piece [-3, -2) at -2.5: no dot there
|
|
689
|
+
p = plot_piecewise(floor(x), (x, -2.5, 3), **p_options)
|
|
690
|
+
assert _dots(p) == [(-2, -3, False)] + floor_dots
|
|
691
|
+
|
|
692
|
+
# both pieces continue past the ends of the range
|
|
693
|
+
f = Piecewise((x, x < 0), (x**2, True))
|
|
694
|
+
p = plot_piecewise(f, (x, -1, 1), **p_options)
|
|
695
|
+
assert _dots(p) == [(0, 0, False), (0, 0, True)]
|
|
696
|
+
|
|
697
|
+
# a piece that touches the range at a single float point
|
|
698
|
+
f = Piecewise((1, x < 3), (2, True))
|
|
699
|
+
p = plot_piecewise(f, (x, -2.0, 3.0), **p_options)
|
|
700
|
+
assert _dots(p) == [(3, 1, False), (3, 2, True)]
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
def test_plot_piecewise_undefined_points(p_options):
|
|
704
|
+
# Verify that points where the expression is undefined, but both
|
|
705
|
+
# one-sided limits are finite, get empty dots: a hole, or the two ends
|
|
706
|
+
# of a jump.
|
|
707
|
+
|
|
708
|
+
x = symbols("x")
|
|
709
|
+
p = plot_piecewise((x**2 - 1) / (x - 1), (x, -1, 3), **p_options)
|
|
710
|
+
assert _dots(p) == [(1, 2, False), (1, 2, False)]
|
|
711
|
+
|
|
712
|
+
p = plot_piecewise(sin(x) / x, (x, -3, 3), **p_options)
|
|
713
|
+
assert _dots(p) == [(0, 1, False), (0, 1, False)]
|
|
714
|
+
|
|
715
|
+
p = plot_piecewise(Abs(x) / x, (x, -2, 2), **p_options)
|
|
716
|
+
assert _dots(p) == [(0, -1, False), (0, 1, False)]
|
|
717
|
+
|
|
718
|
+
# a hole together with a jump: the jump is rewritten first, and the
|
|
719
|
+
# hole is found inside a piece
|
|
720
|
+
p = plot_piecewise(sin(x) / x + Heaviside(x - 1), (x, -3, 3), **p_options)
|
|
721
|
+
assert _dots(p) == [(0, 1, False), (0, 1, False), (1, 0.841, False),
|
|
722
|
+
(1, 1.341, True), (1, 1.841, False)]
|
|
723
|
+
|
|
724
|
+
p = plot_piecewise(floor(x) + Abs(x) / x, (x, -0.5, 0.5), **p_options)
|
|
725
|
+
assert _dots(p) == [(0, -2, False), (0, 1, False)]
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
def test_plot_piecewise_unchanged_cases(p_options):
|
|
729
|
+
# Verify that floor of a nonlinear argument is left as before
|
|
730
|
+
|
|
731
|
+
x = symbols("x")
|
|
732
|
+
p = plot_piecewise(floor(x**2), (x, -1, 1), **p_options)
|
|
733
|
+
assert len(p.series) == 1
|
|
734
|
+
assert isinstance(p.series[0], LineOver1DRangeSeries)
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
def _line_ranges(p):
|
|
738
|
+
return [(round(float(s.ranges[0][1]), 4), round(float(s.ranges[0][2]), 4))
|
|
739
|
+
for s in p.series if isinstance(s, LineOver1DRangeSeries)]
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def test_plot_piecewise_vertical_asymptotes(p_options):
|
|
743
|
+
# Verify that the curve is not joined across a vertical asymptote, and
|
|
744
|
+
# that the y-limits leave out the values close to it, unless ylim is
|
|
745
|
+
# given.
|
|
746
|
+
|
|
747
|
+
x = symbols("x")
|
|
748
|
+
p = plot_piecewise(1 / (x - 1), (x, -1, 3), **p_options)
|
|
749
|
+
assert _line_ranges(p) == [(-1, 1), (1, 3)]
|
|
750
|
+
low, high = p.ylim
|
|
751
|
+
assert -15 < low < -2 and 2 < high < 15
|
|
752
|
+
|
|
753
|
+
p = plot_piecewise(1 / (x - 1), (x, -1, 3), ylim=(-1, 1), **p_options)
|
|
754
|
+
assert tuple(p.ylim) == (-1, 1)
|
|
755
|
+
|
|
756
|
+
p = plot_piecewise(tan(x), (x, -4, 4), **p_options)
|
|
757
|
+
assert len(_line_ranges(p)) == 3
|
|
758
|
+
|
|
759
|
+
# a hole and a jump are not asymptotes; without asymptotes, ylim is
|
|
760
|
+
# left to the backend
|
|
761
|
+
p = plot_piecewise(sin(x) / x + Heaviside(x - 1), (x, -3, 3), **p_options)
|
|
762
|
+
assert p.ylim is None
|
|
763
|
+
|
|
764
|
+
# an asymptote at the end of a piece: the pieces are already split
|
|
765
|
+
f = Piecewise((x, x < 0), (1 / x, True))
|
|
766
|
+
p = plot_piecewise(f, (x, -2, 2), **p_options)
|
|
767
|
+
assert len(_line_ranges(p)) == 2
|
|
768
|
+
assert p.ylim is not None
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
def test_plot_piecewise_short_open_interval(p_options):
|
|
772
|
+
# Verify that the open end of a piece shorter than one unit is evaluated
|
|
773
|
+
# inside the piece, so that its empty dot has a finite value.
|
|
774
|
+
|
|
775
|
+
x = symbols("x")
|
|
776
|
+
f = Piecewise((sqrt(Rational(1, 2) - x), x < Rational(1, 2)), (1, True))
|
|
777
|
+
p = plot_piecewise(f, (x, 0, 1), **p_options)
|
|
778
|
+
empty = [t for t in p.series
|
|
779
|
+
if isinstance(t, List2DSeries) and not t.is_filled]
|
|
780
|
+
assert len(empty) == 1
|
|
781
|
+
xx, yy = empty[0].get_data()
|
|
782
|
+
assert xx[0] < 0.5
|
|
783
|
+
assert np.isfinite(yy[0])
|
|
784
|
+
|
|
785
|
+
|
|
637
786
|
@pytest.mark.skipif(ipy is None, reason="ipywidgets is not installed")
|
|
638
787
|
@pytest.mark.filterwarnings("ignore:The following keyword arguments are unused.")
|
|
639
788
|
def test_functions_iplot_integration(pi_options):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "4.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|