complex-range 1.0.0__py3-none-any.whl → 1.0.0.post1__py3-none-any.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: complex-range
3
- Version: 1.0.0
3
+ Version: 1.0.0.post1
4
4
  Summary: Generate ranges of complex numbers - rectangular grids and linear sequences in the complex plane
5
5
  Author-email: Daniele Gregori <dangregori@gmail.com>
6
6
  Maintainer-email: Daniele Gregori <dangregori@gmail.com>
@@ -71,15 +71,17 @@ line = complex_range([0, 3+3j])
71
71
  # [0j, (1+1j), (2+2j), (3+3j)]
72
72
  ```
73
73
 
74
- ## Features
74
+ ## Overview
75
+
76
+ `complex_range` generates ranges of complex numbers, extending Python's `range` functionality to the complex plane. It supports two modes:
77
+
78
+ - **Rectangular ranges**: Generate all points on a 2D grid spanning from minimum to maximum real and imaginary parts
79
+ - **Linear ranges**: Generate points along a line between two complex numbers
80
+
81
+ Step sizes can be specified as a complex number (e.g., `0.5+0.5j`) or as separate real and imaginary steps in list form (e.g., `[0.5, 0.5]`). By default, the imaginary part is incremented first throughout its range with the real part fixed, then the real part is incremented—this behavior can be reversed via the `increment_first` option.
82
+
83
+ The `farey_range` option enables a complex generalization of the Farey sequence, creating mathematically refined point distributions in the complex plane.
75
84
 
76
- - **Rectangular ranges**: Generate 2D grids of complex numbers
77
- - **Linear ranges**: Generate points along a line in the complex plane
78
- - **Flexible step sizes**: Control spacing independently for real and imaginary axes
79
- - **Negative steps**: Support for descending ranges with negative step values
80
- - **Farey sequence subdivision**: Create refined grids using number-theoretic sequences
81
- - **Iteration order control**: Choose whether to iterate real or imaginary component first
82
- - **Pure Python**: No dependencies required
83
85
 
84
86
  ## Usage
85
87
 
@@ -87,6 +89,16 @@ line = complex_range([0, 3+3j])
87
89
 
88
90
  Generate a grid of complex numbers between two corners:
89
91
 
92
+ ```
93
+ Im ↑
94
+ 3 │ · · ·
95
+ 2 │ · · ·
96
+ 1 │ · · ·
97
+ 0 │ · · ·
98
+ └──────────→ Re
99
+ 0 1 2
100
+ ```
101
+
90
102
  ```python
91
103
  from complex_range import complex_range
92
104
 
@@ -107,10 +119,25 @@ complex_range(0, 4+6j, [2, 3])
107
119
  # Real step = 2, Imaginary step = 3
108
120
  ```
109
121
 
122
+ With `increment_first='im'` (default), points are generated column by column:
123
+ `(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), ...`
124
+
110
125
  ### Linear Ranges
111
126
 
112
127
  Generate points along a line (diagonal) in the complex plane:
113
128
 
129
+ ```
130
+ Im ↑
131
+ 3 │ ·
132
+ 2 │ ·
133
+ 1 │ ·
134
+ 0 │·
135
+ └──────────→ Re
136
+ 0 1 2 3
137
+ ```
138
+
139
+ Points increment along both axes simultaneously.
140
+
114
141
  ```python
115
142
  # Linear from 0 to endpoint
116
143
  complex_range([3+3j])
@@ -168,11 +195,11 @@ farey_sequence(3)
168
195
  # [Fraction(0,1), Fraction(1,3), Fraction(1,2), Fraction(2,3), Fraction(1,1)]
169
196
  ```
170
197
 
171
- ## API Reference
198
+ ## Syntax
172
199
 
173
200
  ### `complex_range(z1, z2=None, step=None, *, increment_first='im', farey_range=False)`
174
201
 
175
- Generate a range of complex numbers.
202
+ Generates a range of complex numbers.
176
203
 
177
204
  **Parameters:**
178
205
 
@@ -200,41 +227,6 @@ Generate the Farey sequence of order n.
200
227
 
201
228
  **Returns:** `List[Fraction]` - Sorted list of fractions in [0, 1]
202
229
 
203
- ## Understanding the Ranges
204
-
205
- ### Rectangular Range
206
-
207
- A rectangular range generates all points on a 2D grid:
208
-
209
- ```
210
- Im ↑
211
- 3 │ · · ·
212
- 2 │ · · ·
213
- 1 │ · · ·
214
- 0 │ · · ·
215
- └──────────→ Re
216
- 0 1 2
217
- ```
218
-
219
- With `increment_first='im'` (default), points are generated column by column:
220
- `(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), ...`
221
-
222
- ### Linear Range
223
-
224
- A linear range generates points along a diagonal:
225
-
226
- ```
227
- Im ↑
228
- 3 │ ·
229
- 2 │ ·
230
- 1 │ ·
231
- 0 │·
232
- └──────────→ Re
233
- 0 1 2 3
234
- ```
235
-
236
- Points increment along both axes simultaneously.
237
-
238
230
  ## Examples
239
231
 
240
232
  ### Visualizing a Rectangular Grid
@@ -264,16 +256,19 @@ from complex_range import complex_range
264
256
  coarse = complex_range(0, 2+2j, 1+1j)
265
257
 
266
258
  # Refined grid using Farey sequence
267
- refined = complex_range(0, 2+2j, 2+2j, farey_range=True)
259
+ refined = complex_range(0, 2+2j, 3+3j, farey_range=True)
268
260
  print(f"Coarse: {len(coarse)} points, Refined: {len(refined)} points")
269
261
  ```
270
262
 
271
- ### Iterating Over Complex Regions
263
+ ## Applications
264
+
265
+ ### Mandelbrot Set Visualization
272
266
 
273
267
  ```python
274
268
  from complex_range import complex_range
269
+ import matplotlib.pyplot as plt
270
+ import numpy as np
275
271
 
276
- # Evaluate a function over a region of the complex plane
277
272
  def mandelbrot_escape(c, max_iter=100):
278
273
  z = 0
279
274
  for i in range(max_iter):
@@ -282,49 +277,40 @@ def mandelbrot_escape(c, max_iter=100):
282
277
  return i
283
278
  return max_iter
284
279
 
285
- # Create a grid and evaluate
286
- grid = complex_range(-2-1.5j, 1+1.5j, [0.1, 0.1])
287
- escapes = [mandelbrot_escape(c) for c in grid]
288
- ```
289
-
290
- ## Author
291
-
292
- **Daniele Gregori**
293
-
294
- - Original [Wolfram Language ComplexRange](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) function
295
- - Python implementation
280
+ # Grid parameters
281
+ re_min, re_max = -2, 1
282
+ im_min, im_max = -1.5, 1.5
283
+ step = 0.005
296
284
 
297
- ## Contributing
298
-
299
- Contributions are welcome! Please feel free to submit a Pull Request.
300
-
301
- ```bash
302
- # Clone the repository
303
- git clone https://github.com/Daniele-Gregori/PyPI-packages.git
304
- cd PyPI-packages/packages/complex-range
285
+ # Generate grid and compute escape times
286
+ grid = complex_range(re_min + im_min*1j, re_max + im_max*1j, [step, step])
287
+ escapes = [mandelbrot_escape(c) for c in grid]
305
288
 
306
- # Install development dependencies
307
- pip install -e ".[dev]"
289
+ # Reshape and plot
290
+ n_re = int((re_max - re_min) / step) + 1
291
+ n_im = int((im_max - im_min) / step) + 1
292
+ escape_array = np.array(escapes).reshape(n_re, n_im).T
308
293
 
309
- # Run tests
310
- pytest
294
+ plt.figure(figsize=(10, 8))
295
+ plt.imshow(escape_array, extent=[re_min, re_max, im_min, im_max],
296
+ origin='lower', cmap='hot', aspect='equal')
297
+ plt.colorbar(label='Escape iterations')
298
+ plt.xlabel('Real')
299
+ plt.ylabel('Imaginary')
300
+ plt.title('Mandelbrot Set')
301
+ plt.savefig('mandelbrot.png', dpi=150)
302
+ plt.show()
303
+ ```
311
304
 
312
- # Run type checking
313
- mypy src/complex_range
305
+ ![Mandelbrot Set](mandelbrot.png)
314
306
 
315
- # Format code
316
- black src tests
317
- isort src tests
318
- ```
319
307
 
320
308
  ## License
321
309
 
322
310
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
323
311
 
324
- ## Acknowledgments
312
+ ## See Also
325
313
 
326
- Original [Wolfram Language ComplexRange](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) resource function contributed by Daniele Gregori and reviewed by the Wolfram Review Team.
314
+ Original [Wolfram Language "ComplexRange"](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) resource function contributed by Daniele Gregori and reviewed by the Wolfram Review Team.
327
315
 
328
- ## Changelog
329
316
 
330
- See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
@@ -0,0 +1,10 @@
1
+ complex_range/__init__.py,sha256=hZC54Rv4f2Zvha7IDM-DngPqqwDYFugErkzGSLir7-Y,779
2
+ complex_range/core.py,sha256=pgq185F5KX3hjju7k4bGJoeMegarncoAHx2-Y20wd-Y,18196
3
+ complex_range/dev.py,sha256=I2uaDDWVMJoDfdRPZin-0XTKElRz3ianknT_7oOrPws,929
4
+ complex_range/farey.py,sha256=xDcZSJi1h2vMtghkP8TbaEc2dqHbGc4_C7UaD1H6qS0,2305
5
+ complex_range/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ complex_range-1.0.0.post1.dist-info/licenses/LICENSE,sha256=S2_QCHbwpFs9uShfKzzbIYGKLwPhrlcUUVZnpieCdDU,1072
7
+ complex_range-1.0.0.post1.dist-info/METADATA,sha256=thWiQketttG8tf13cct-praJ70iEHpv3YrOhJ0Ql228,9421
8
+ complex_range-1.0.0.post1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
+ complex_range-1.0.0.post1.dist-info/top_level.txt,sha256=AjyB3ZnFm0s9ReE4FvZzVKfwOJ62TI7NU_ieImIlutk,14
10
+ complex_range-1.0.0.post1.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- complex_range/__init__.py,sha256=hZC54Rv4f2Zvha7IDM-DngPqqwDYFugErkzGSLir7-Y,779
2
- complex_range/core.py,sha256=pgq185F5KX3hjju7k4bGJoeMegarncoAHx2-Y20wd-Y,18196
3
- complex_range/dev.py,sha256=I2uaDDWVMJoDfdRPZin-0XTKElRz3ianknT_7oOrPws,929
4
- complex_range/farey.py,sha256=xDcZSJi1h2vMtghkP8TbaEc2dqHbGc4_C7UaD1H6qS0,2305
5
- complex_range/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- complex_range-1.0.0.dist-info/licenses/LICENSE,sha256=S2_QCHbwpFs9uShfKzzbIYGKLwPhrlcUUVZnpieCdDU,1072
7
- complex_range-1.0.0.dist-info/METADATA,sha256=zcL9a78XhglVg2qIR1emviUJr7h8ey1tJFxtM-Kh-b4,9311
8
- complex_range-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
- complex_range-1.0.0.dist-info/top_level.txt,sha256=AjyB3ZnFm0s9ReE4FvZzVKfwOJ62TI7NU_ieImIlutk,14
10
- complex_range-1.0.0.dist-info/RECORD,,