complexplorer 0.1.2__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.
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Igor Kuvychko
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.1
2
+ Name: complexplorer
3
+ Version: 0.1.2
4
+ Summary: Complex function visualizations inspired by Elias Wegert's 'Visual Complex Functions - An Introduction with Phase Portraits'
5
+ Author-email: Igor Kuvychko <igor.kuvychko@gmail.com>
6
+ Project-URL: Homepage, https://github.com/kuvychko/complexplorer
7
+ Project-URL: Bug Tracker, https://github.com/kuvychko/complexplorer/issues
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Programming Language :: Python :: 3.8
10
+ Classifier: Programming Language :: Python :: 3.9
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: License :: OSI Approved :: BSD License
14
+ Classifier: Topic :: Scientific/Engineering :: Visualization
15
+ Classifier: Topic :: Multimedia :: Graphics
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Framework :: Matplotlib
18
+ Requires-Python: >=3.7
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy>=1.20
22
+ Requires-Dist: matplotlib>=3.6
23
+
24
+ # Complexplorer
25
+
26
+ *We cannot directly see the minute details of a Dedekind cut, nor is it clear that arbitrarily great or
27
+ arbitrarily tiny times or lengths actually exist in nature. One could say that
28
+ the so-called ‘real numbers’ are as much a product of mathematicians’
29
+ imaginations as are the complex numbers. Yet we shall find that complex
30
+ numbers, as much as reals, and perhaps even more, find a unity with
31
+ nature that is truly remarkable. It is as though Nature herself is as
32
+ impressed by the scope and consistency of the complex-number system
33
+ as we are ourselves, and has entrusted to these numbers the precise
34
+ operations of her world at its minutest scales.* ...
35
+
36
+ *Moreover, to refer just to the scope and to the consistency of complex
37
+ numbers does not do justice to this system. There is something more
38
+ which, in my view, can only be referred to as ‘magic’.*
39
+
40
+ [Road to Reality](https://www.ams.org/notices/200606/rev-blank.pdf), Chapter 4 - Magical Complex Numbers, Sir Roger Penrose
41
+
42
+ Complexplorer is a Python library for visualization of complex functions.
43
+ The library was insipred by Elias Wegert's book ["Visual Complex Functions - An Introduction with Phase Portraits"](https://link.springer.com/book/10.1007/978-3-0348-0180-5) and it greatly benefitted from discussions and feedback that Elias kindly provided. The library supports enhanced phase portraits and
44
+ several other visual styles.
45
+
46
+ The library provides classes and functions to:
47
+
48
+ * Create complex domains and corresponding complex-valued 2D arrays (meshes)
49
+ * Convert complex-valued 2D arrays to HSV and RGB color maps according to various schemes (Enhanced Phase Portrait, Chessboard, PolarChessboard, LogRings)
50
+ * Visualize complex-valued 2D arrays as 2D and 3D plots (2D image, 3D analytic landscape, 3D Riemann sphere)
51
+
52
+ Design choices of this library enable:
53
+
54
+ * Simple composability: any domain can be used with any plot and any color map, yielding a multitude of different visualizations.
55
+ * Deferred evaluation of domain meshes. Meshing is typically performed during plotting (and not during domain instanciation). This allows for quick iteration of mesh period for best visual results.
56
+ * Different domain instances can be composed using union and intersection operations to create complex domains.
57
+
58
+ One exception from the composability ideal is Riemann sphere 3D plot. It has its own meshing algorithm to balance point density between the poles and equator.
59
+
60
+ Complexplorer is designed to be very light-weight in terms of its dependencies. It requires only numpy and matplotlib, which comes at a cost.
61
+ Matplotlib is not a 3D rendering library, so 3D visualizations are painfully slow. This is especially true for Riemann sphere plot which uses
62
+ a custom rectangular mesh that wastes a lot of points at the poles. A triangular mesh would be the right tool here, but I have not figured out how to achieve arbitrary point coloring in matplotlib.
63
+
64
+ ## Library overview
65
+
66
+ The library contains following classes and functions.
67
+
68
+ ### Domains
69
+
70
+ * `Domain`: This class serves as the base class for defining complex domains. It encapsulates
71
+ the meshing and masking functionality of a `Domain` instance.
72
+
73
+ * `Rectangle`: A subclass of `Domain`, the `Rectangle` class allows the creation of rectangular domains centered at a given point.
74
+ It takes the length (real and imaginary) of the rectangle and the center point as input.
75
+
76
+ * `Disk`: Another subclass of `Domain`, the `Disk` class enables the creation of circular domains (disks) centered at a given point.
77
+ It requires specifying the radius of the disk and the center point.
78
+
79
+ * `Annulus`: The `Annulus` class, also a subclass of `Domain`, enables the creation of annular domains (rings) centered at a given point.
80
+ It requires specifying the inner and outer radii and the center point.
81
+
82
+ ### Color maps
83
+
84
+ * `Cmap`: This class serves as a base class for color maps and defines
85
+ an informal interface for child color map classes. It implements
86
+ the `*.hsv()` and `*.rgb()` methods which are used to convert
87
+ input complex values to HSV and RGB-valued arrays.
88
+
89
+ * `Phase`: This class implements a phase color map. It can be used
90
+ to generate regular phase color maps or enhanced phase color maps.
91
+
92
+ * `Chessboard`: This class implements a chessboard color map.
93
+
94
+ * `PolarChessboard`: This class implements a polar chessboard color map.
95
+
96
+ * `LogRings`: This class implements a logarithmic black and white rings color map.
97
+
98
+ ### 2D plotting functions
99
+
100
+ * `plot`: plot complex function as pullback of the color map of the co-domain to the domain.
101
+
102
+ * `pair_plot`: plot color maps of the domain and the pullback of the co-domain of the function.
103
+
104
+ * `riemann_chart`: plot the phase portrait of a complex function projected from the Riemann hemisphere.
105
+
106
+ * `riemann_hemispheres`: plot a pair of phase portraits corresponding to the upper and lower hemispheres of the Riemann sphere.
107
+
108
+ ### 3D plotting functions
109
+
110
+ * `plot_landscape`: plot a complex function as a 3D landscape on the complex plane.
111
+
112
+ * `pair_plot_landscape`: - plot analytic landscapes of the domain and the pullback of the co-domain of the function.
113
+
114
+ * `riemann`: plot a complex function as a phase portrait on the Riemann sphere.
115
+
116
+ ### Supporting functions
117
+
118
+ * `phase`: return a phase of complex input mapped to [0, 2*pi) interval.
119
+
120
+ * `sawtooth`: return a sawtooth wave of input x.
121
+
122
+ * `stereographic`: return a (x,y,z) tuple corresponding to stereographic projection of complex input z.
123
+
124
+ ## Installation
125
+
126
+ Install using pip:
127
+
128
+ ```
129
+ pip install complexplorer
130
+ ```
131
+
132
+ ## Documentation
133
+
134
+ Every module, class, and function of the library is documented via a docstring. Use `help` or `?` to view them.
135
+
136
+ ## Example notebooks
137
+
138
+ * [Basic functionality overview](https://github.com/kuvychko/complexplorer/tree/main/examples/plot_example.ipynb)
139
+
140
+ * [Domains and color maps](https://github.com/kuvychko/complexplorer/tree/main/examples/domains_cmaps_example.ipynb)
141
+
142
+ ## Gallery
143
+
144
+ Examples below use a test function $f(z) = \frac{z - 1}{z^2 + z + 1}$, a standard example from ["Visual Complex Functions - An Introduction with Phase Portraits"](https://link.springer.com/book/10.1007/978-3-0348-0180-5). Different color maps and plot types are shown. For the code used to generate these plots see this [example Jupyter notebook](https://github.com/kuvychko/complexplorer/tree/main/examples/plot_example.ipynb)
145
+
146
+ ### Phase portraits (domain and co-domain side-by-side)
147
+
148
+ ![Phase portraint](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_2d.png?raw=true)
149
+
150
+
151
+ ![Phase portraint phase enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_phase_enhanced_2d.png?raw=true)
152
+
153
+ ![Phase portraint modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_modulus_enhanced_2d.png?raw=true)
154
+
155
+ ![Enhanced phase portraint phase and modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Enhanced_phase_portrait_phase_and_modulus_enhanced_2d.png?raw=true)
156
+
157
+ ![Polar chessboard linear](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_linear_modulus_spacing_2d.png?raw=true)
158
+
159
+ ![Polar chessboard log](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_log_modulus_spacing_2d.png?raw=true)
160
+
161
+ ![Logarithmic rings](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Logarithmic_rings_2d.png?raw=true)
162
+
163
+ ### Analytic landscapes (domain and co-domain side-by-side)
164
+
165
+ ![Phase portraint](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_3d.png?raw=true)
166
+
167
+ ![Phase portraint phase enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_phase_enhanced_3d.png?raw=true)
168
+
169
+ ![Phase portraint modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_modulus_enhanced_3d.png?raw=true)
170
+
171
+ ![Enhanced phase portraint phase and modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Enhanced_phase_portrait_phase_and_modulus_enhanced_3d.png?raw=true)
172
+
173
+ ![Polar chessboard linear](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_linear_modulus_spacing_3d.png?raw=true)
174
+
175
+ ![Polar chessboard log](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_log_modulus_spacing_3d.png?raw=true)
176
+
177
+ ![Logarithmic rings](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Logarithmic_rings_3d.png?raw=true)
178
+
179
+ ### 2D Riemann chart (projected hemispheres)
180
+
181
+ ![Riemann charts](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/riemann_chart_2d.png?raw=true)
182
+
183
+ ### Riemann sphere
184
+
185
+ ![Riemann sphere](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/riemann_sphere_3d.png?raw=true)
@@ -0,0 +1,162 @@
1
+ # Complexplorer
2
+
3
+ *We cannot directly see the minute details of a Dedekind cut, nor is it clear that arbitrarily great or
4
+ arbitrarily tiny times or lengths actually exist in nature. One could say that
5
+ the so-called ‘real numbers’ are as much a product of mathematicians’
6
+ imaginations as are the complex numbers. Yet we shall find that complex
7
+ numbers, as much as reals, and perhaps even more, find a unity with
8
+ nature that is truly remarkable. It is as though Nature herself is as
9
+ impressed by the scope and consistency of the complex-number system
10
+ as we are ourselves, and has entrusted to these numbers the precise
11
+ operations of her world at its minutest scales.* ...
12
+
13
+ *Moreover, to refer just to the scope and to the consistency of complex
14
+ numbers does not do justice to this system. There is something more
15
+ which, in my view, can only be referred to as ‘magic’.*
16
+
17
+ [Road to Reality](https://www.ams.org/notices/200606/rev-blank.pdf), Chapter 4 - Magical Complex Numbers, Sir Roger Penrose
18
+
19
+ Complexplorer is a Python library for visualization of complex functions.
20
+ The library was insipred by Elias Wegert's book ["Visual Complex Functions - An Introduction with Phase Portraits"](https://link.springer.com/book/10.1007/978-3-0348-0180-5) and it greatly benefitted from discussions and feedback that Elias kindly provided. The library supports enhanced phase portraits and
21
+ several other visual styles.
22
+
23
+ The library provides classes and functions to:
24
+
25
+ * Create complex domains and corresponding complex-valued 2D arrays (meshes)
26
+ * Convert complex-valued 2D arrays to HSV and RGB color maps according to various schemes (Enhanced Phase Portrait, Chessboard, PolarChessboard, LogRings)
27
+ * Visualize complex-valued 2D arrays as 2D and 3D plots (2D image, 3D analytic landscape, 3D Riemann sphere)
28
+
29
+ Design choices of this library enable:
30
+
31
+ * Simple composability: any domain can be used with any plot and any color map, yielding a multitude of different visualizations.
32
+ * Deferred evaluation of domain meshes. Meshing is typically performed during plotting (and not during domain instanciation). This allows for quick iteration of mesh period for best visual results.
33
+ * Different domain instances can be composed using union and intersection operations to create complex domains.
34
+
35
+ One exception from the composability ideal is Riemann sphere 3D plot. It has its own meshing algorithm to balance point density between the poles and equator.
36
+
37
+ Complexplorer is designed to be very light-weight in terms of its dependencies. It requires only numpy and matplotlib, which comes at a cost.
38
+ Matplotlib is not a 3D rendering library, so 3D visualizations are painfully slow. This is especially true for Riemann sphere plot which uses
39
+ a custom rectangular mesh that wastes a lot of points at the poles. A triangular mesh would be the right tool here, but I have not figured out how to achieve arbitrary point coloring in matplotlib.
40
+
41
+ ## Library overview
42
+
43
+ The library contains following classes and functions.
44
+
45
+ ### Domains
46
+
47
+ * `Domain`: This class serves as the base class for defining complex domains. It encapsulates
48
+ the meshing and masking functionality of a `Domain` instance.
49
+
50
+ * `Rectangle`: A subclass of `Domain`, the `Rectangle` class allows the creation of rectangular domains centered at a given point.
51
+ It takes the length (real and imaginary) of the rectangle and the center point as input.
52
+
53
+ * `Disk`: Another subclass of `Domain`, the `Disk` class enables the creation of circular domains (disks) centered at a given point.
54
+ It requires specifying the radius of the disk and the center point.
55
+
56
+ * `Annulus`: The `Annulus` class, also a subclass of `Domain`, enables the creation of annular domains (rings) centered at a given point.
57
+ It requires specifying the inner and outer radii and the center point.
58
+
59
+ ### Color maps
60
+
61
+ * `Cmap`: This class serves as a base class for color maps and defines
62
+ an informal interface for child color map classes. It implements
63
+ the `*.hsv()` and `*.rgb()` methods which are used to convert
64
+ input complex values to HSV and RGB-valued arrays.
65
+
66
+ * `Phase`: This class implements a phase color map. It can be used
67
+ to generate regular phase color maps or enhanced phase color maps.
68
+
69
+ * `Chessboard`: This class implements a chessboard color map.
70
+
71
+ * `PolarChessboard`: This class implements a polar chessboard color map.
72
+
73
+ * `LogRings`: This class implements a logarithmic black and white rings color map.
74
+
75
+ ### 2D plotting functions
76
+
77
+ * `plot`: plot complex function as pullback of the color map of the co-domain to the domain.
78
+
79
+ * `pair_plot`: plot color maps of the domain and the pullback of the co-domain of the function.
80
+
81
+ * `riemann_chart`: plot the phase portrait of a complex function projected from the Riemann hemisphere.
82
+
83
+ * `riemann_hemispheres`: plot a pair of phase portraits corresponding to the upper and lower hemispheres of the Riemann sphere.
84
+
85
+ ### 3D plotting functions
86
+
87
+ * `plot_landscape`: plot a complex function as a 3D landscape on the complex plane.
88
+
89
+ * `pair_plot_landscape`: - plot analytic landscapes of the domain and the pullback of the co-domain of the function.
90
+
91
+ * `riemann`: plot a complex function as a phase portrait on the Riemann sphere.
92
+
93
+ ### Supporting functions
94
+
95
+ * `phase`: return a phase of complex input mapped to [0, 2*pi) interval.
96
+
97
+ * `sawtooth`: return a sawtooth wave of input x.
98
+
99
+ * `stereographic`: return a (x,y,z) tuple corresponding to stereographic projection of complex input z.
100
+
101
+ ## Installation
102
+
103
+ Install using pip:
104
+
105
+ ```
106
+ pip install complexplorer
107
+ ```
108
+
109
+ ## Documentation
110
+
111
+ Every module, class, and function of the library is documented via a docstring. Use `help` or `?` to view them.
112
+
113
+ ## Example notebooks
114
+
115
+ * [Basic functionality overview](https://github.com/kuvychko/complexplorer/tree/main/examples/plot_example.ipynb)
116
+
117
+ * [Domains and color maps](https://github.com/kuvychko/complexplorer/tree/main/examples/domains_cmaps_example.ipynb)
118
+
119
+ ## Gallery
120
+
121
+ Examples below use a test function $f(z) = \frac{z - 1}{z^2 + z + 1}$, a standard example from ["Visual Complex Functions - An Introduction with Phase Portraits"](https://link.springer.com/book/10.1007/978-3-0348-0180-5). Different color maps and plot types are shown. For the code used to generate these plots see this [example Jupyter notebook](https://github.com/kuvychko/complexplorer/tree/main/examples/plot_example.ipynb)
122
+
123
+ ### Phase portraits (domain and co-domain side-by-side)
124
+
125
+ ![Phase portraint](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_2d.png?raw=true)
126
+
127
+
128
+ ![Phase portraint phase enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_phase_enhanced_2d.png?raw=true)
129
+
130
+ ![Phase portraint modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_modulus_enhanced_2d.png?raw=true)
131
+
132
+ ![Enhanced phase portraint phase and modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Enhanced_phase_portrait_phase_and_modulus_enhanced_2d.png?raw=true)
133
+
134
+ ![Polar chessboard linear](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_linear_modulus_spacing_2d.png?raw=true)
135
+
136
+ ![Polar chessboard log](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_log_modulus_spacing_2d.png?raw=true)
137
+
138
+ ![Logarithmic rings](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Logarithmic_rings_2d.png?raw=true)
139
+
140
+ ### Analytic landscapes (domain and co-domain side-by-side)
141
+
142
+ ![Phase portraint](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_3d.png?raw=true)
143
+
144
+ ![Phase portraint phase enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_phase_enhanced_3d.png?raw=true)
145
+
146
+ ![Phase portraint modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Phase_portrait_modulus_enhanced_3d.png?raw=true)
147
+
148
+ ![Enhanced phase portraint phase and modulus enhanced](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Enhanced_phase_portrait_phase_and_modulus_enhanced_3d.png?raw=true)
149
+
150
+ ![Polar chessboard linear](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_linear_modulus_spacing_3d.png?raw=true)
151
+
152
+ ![Polar chessboard log](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Polar_chessboard_log_modulus_spacing_3d.png?raw=true)
153
+
154
+ ![Logarithmic rings](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/Logarithmic_rings_3d.png?raw=true)
155
+
156
+ ### 2D Riemann chart (projected hemispheres)
157
+
158
+ ![Riemann charts](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/riemann_chart_2d.png?raw=true)
159
+
160
+ ### Riemann sphere
161
+
162
+ ![Riemann sphere](https://github.com/kuvychko/complexplorer/blob/main/examples/gallery/riemann_sphere_3d.png?raw=true)
@@ -0,0 +1,5 @@
1
+ from complexplorer.domain import *
2
+ from complexplorer.cmap import *
3
+ from complexplorer.plots_2d import *
4
+ from complexplorer.plots_3d import *
5
+ from complexplorer.funcs import *