complex-range 1.0.0__tar.gz → 1.0.0.post1__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.
Files changed (20) hide show
  1. {complex_range-1.0.0/src/complex_range.egg-info → complex_range-1.0.0.post1}/PKG-INFO +68 -82
  2. {complex_range-1.0.0 → complex_range-1.0.0.post1}/README.md +67 -81
  3. {complex_range-1.0.0 → complex_range-1.0.0.post1}/pyproject.toml +1 -1
  4. {complex_range-1.0.0 → complex_range-1.0.0.post1/src/complex_range.egg-info}/PKG-INFO +68 -82
  5. {complex_range-1.0.0 → complex_range-1.0.0.post1}/CHANGELOG.md +0 -0
  6. {complex_range-1.0.0 → complex_range-1.0.0.post1}/LICENSE +0 -0
  7. {complex_range-1.0.0 → complex_range-1.0.0.post1}/MANIFEST.in +0 -0
  8. {complex_range-1.0.0 → complex_range-1.0.0.post1}/pytest.ini +0 -0
  9. {complex_range-1.0.0 → complex_range-1.0.0.post1}/setup.cfg +0 -0
  10. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range/__init__.py +0 -0
  11. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range/core.py +0 -0
  12. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range/dev.py +0 -0
  13. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range/farey.py +0 -0
  14. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range/py.typed +0 -0
  15. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range.egg-info/SOURCES.txt +0 -0
  16. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range.egg-info/dependency_links.txt +0 -0
  17. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range.egg-info/requires.txt +0 -0
  18. {complex_range-1.0.0 → complex_range-1.0.0.post1}/src/complex_range.egg-info/top_level.txt +0 -0
  19. {complex_range-1.0.0 → complex_range-1.0.0.post1}/tests/__init__.py +0 -0
  20. {complex_range-1.0.0 → complex_range-1.0.0.post1}/tests/test_complex_range.py +0 -0
@@ -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.
@@ -28,15 +28,17 @@ line = complex_range([0, 3+3j])
28
28
  # [0j, (1+1j), (2+2j), (3+3j)]
29
29
  ```
30
30
 
31
- ## Features
31
+ ## Overview
32
+
33
+ `complex_range` generates ranges of complex numbers, extending Python's `range` functionality to the complex plane. It supports two modes:
34
+
35
+ - **Rectangular ranges**: Generate all points on a 2D grid spanning from minimum to maximum real and imaginary parts
36
+ - **Linear ranges**: Generate points along a line between two complex numbers
37
+
38
+ 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.
39
+
40
+ The `farey_range` option enables a complex generalization of the Farey sequence, creating mathematically refined point distributions in the complex plane.
32
41
 
33
- - **Rectangular ranges**: Generate 2D grids of complex numbers
34
- - **Linear ranges**: Generate points along a line in the complex plane
35
- - **Flexible step sizes**: Control spacing independently for real and imaginary axes
36
- - **Negative steps**: Support for descending ranges with negative step values
37
- - **Farey sequence subdivision**: Create refined grids using number-theoretic sequences
38
- - **Iteration order control**: Choose whether to iterate real or imaginary component first
39
- - **Pure Python**: No dependencies required
40
42
 
41
43
  ## Usage
42
44
 
@@ -44,6 +46,16 @@ line = complex_range([0, 3+3j])
44
46
 
45
47
  Generate a grid of complex numbers between two corners:
46
48
 
49
+ ```
50
+ Im ↑
51
+ 3 │ · · ·
52
+ 2 │ · · ·
53
+ 1 │ · · ·
54
+ 0 │ · · ·
55
+ └──────────→ Re
56
+ 0 1 2
57
+ ```
58
+
47
59
  ```python
48
60
  from complex_range import complex_range
49
61
 
@@ -64,10 +76,25 @@ complex_range(0, 4+6j, [2, 3])
64
76
  # Real step = 2, Imaginary step = 3
65
77
  ```
66
78
 
79
+ With `increment_first='im'` (default), points are generated column by column:
80
+ `(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), ...`
81
+
67
82
  ### Linear Ranges
68
83
 
69
84
  Generate points along a line (diagonal) in the complex plane:
70
85
 
86
+ ```
87
+ Im ↑
88
+ 3 │ ·
89
+ 2 │ ·
90
+ 1 │ ·
91
+ 0 │·
92
+ └──────────→ Re
93
+ 0 1 2 3
94
+ ```
95
+
96
+ Points increment along both axes simultaneously.
97
+
71
98
  ```python
72
99
  # Linear from 0 to endpoint
73
100
  complex_range([3+3j])
@@ -125,11 +152,11 @@ farey_sequence(3)
125
152
  # [Fraction(0,1), Fraction(1,3), Fraction(1,2), Fraction(2,3), Fraction(1,1)]
126
153
  ```
127
154
 
128
- ## API Reference
155
+ ## Syntax
129
156
 
130
157
  ### `complex_range(z1, z2=None, step=None, *, increment_first='im', farey_range=False)`
131
158
 
132
- Generate a range of complex numbers.
159
+ Generates a range of complex numbers.
133
160
 
134
161
  **Parameters:**
135
162
 
@@ -157,41 +184,6 @@ Generate the Farey sequence of order n.
157
184
 
158
185
  **Returns:** `List[Fraction]` - Sorted list of fractions in [0, 1]
159
186
 
160
- ## Understanding the Ranges
161
-
162
- ### Rectangular Range
163
-
164
- A rectangular range generates all points on a 2D grid:
165
-
166
- ```
167
- Im ↑
168
- 3 │ · · ·
169
- 2 │ · · ·
170
- 1 │ · · ·
171
- 0 │ · · ·
172
- └──────────→ Re
173
- 0 1 2
174
- ```
175
-
176
- With `increment_first='im'` (default), points are generated column by column:
177
- `(0,0), (0,1), (0,2), (0,3), (1,0), (1,1), ...`
178
-
179
- ### Linear Range
180
-
181
- A linear range generates points along a diagonal:
182
-
183
- ```
184
- Im ↑
185
- 3 │ ·
186
- 2 │ ·
187
- 1 │ ·
188
- 0 │·
189
- └──────────→ Re
190
- 0 1 2 3
191
- ```
192
-
193
- Points increment along both axes simultaneously.
194
-
195
187
  ## Examples
196
188
 
197
189
  ### Visualizing a Rectangular Grid
@@ -221,16 +213,19 @@ from complex_range import complex_range
221
213
  coarse = complex_range(0, 2+2j, 1+1j)
222
214
 
223
215
  # Refined grid using Farey sequence
224
- refined = complex_range(0, 2+2j, 2+2j, farey_range=True)
216
+ refined = complex_range(0, 2+2j, 3+3j, farey_range=True)
225
217
  print(f"Coarse: {len(coarse)} points, Refined: {len(refined)} points")
226
218
  ```
227
219
 
228
- ### Iterating Over Complex Regions
220
+ ## Applications
221
+
222
+ ### Mandelbrot Set Visualization
229
223
 
230
224
  ```python
231
225
  from complex_range import complex_range
226
+ import matplotlib.pyplot as plt
227
+ import numpy as np
232
228
 
233
- # Evaluate a function over a region of the complex plane
234
229
  def mandelbrot_escape(c, max_iter=100):
235
230
  z = 0
236
231
  for i in range(max_iter):
@@ -239,49 +234,40 @@ def mandelbrot_escape(c, max_iter=100):
239
234
  return i
240
235
  return max_iter
241
236
 
242
- # Create a grid and evaluate
243
- grid = complex_range(-2-1.5j, 1+1.5j, [0.1, 0.1])
244
- escapes = [mandelbrot_escape(c) for c in grid]
245
- ```
246
-
247
- ## Author
248
-
249
- **Daniele Gregori**
250
-
251
- - Original [Wolfram Language ComplexRange](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) function
252
- - Python implementation
237
+ # Grid parameters
238
+ re_min, re_max = -2, 1
239
+ im_min, im_max = -1.5, 1.5
240
+ step = 0.005
253
241
 
254
- ## Contributing
255
-
256
- Contributions are welcome! Please feel free to submit a Pull Request.
257
-
258
- ```bash
259
- # Clone the repository
260
- git clone https://github.com/Daniele-Gregori/PyPI-packages.git
261
- cd PyPI-packages/packages/complex-range
242
+ # Generate grid and compute escape times
243
+ grid = complex_range(re_min + im_min*1j, re_max + im_max*1j, [step, step])
244
+ escapes = [mandelbrot_escape(c) for c in grid]
262
245
 
263
- # Install development dependencies
264
- pip install -e ".[dev]"
246
+ # Reshape and plot
247
+ n_re = int((re_max - re_min) / step) + 1
248
+ n_im = int((im_max - im_min) / step) + 1
249
+ escape_array = np.array(escapes).reshape(n_re, n_im).T
265
250
 
266
- # Run tests
267
- pytest
251
+ plt.figure(figsize=(10, 8))
252
+ plt.imshow(escape_array, extent=[re_min, re_max, im_min, im_max],
253
+ origin='lower', cmap='hot', aspect='equal')
254
+ plt.colorbar(label='Escape iterations')
255
+ plt.xlabel('Real')
256
+ plt.ylabel('Imaginary')
257
+ plt.title('Mandelbrot Set')
258
+ plt.savefig('mandelbrot.png', dpi=150)
259
+ plt.show()
260
+ ```
268
261
 
269
- # Run type checking
270
- mypy src/complex_range
262
+ ![Mandelbrot Set](mandelbrot.png)
271
263
 
272
- # Format code
273
- black src tests
274
- isort src tests
275
- ```
276
264
 
277
265
  ## License
278
266
 
279
267
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
280
268
 
281
- ## Acknowledgments
269
+ ## See Also
282
270
 
283
- Original [Wolfram Language ComplexRange](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) resource function contributed by Daniele Gregori and reviewed by the Wolfram Review Team.
271
+ Original [Wolfram Language "ComplexRange"](https://resources.wolframcloud.com/FunctionRepository/resources/ComplexRange/) resource function contributed by Daniele Gregori and reviewed by the Wolfram Review Team.
284
272
 
285
- ## Changelog
286
273
 
287
- See [CHANGELOG.md](CHANGELOG.md) for a list of changes.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "complex-range"
7
- version = "1.0.0"
7
+ version = "1.0.0.post1"
8
8
  description = "Generate ranges of complex numbers - rectangular grids and linear sequences in the complex plane"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -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.