Domains¶
A domain is the region of the plane that gets sampled. See the guide for how they compose.
complexplorer.Domain ¶
Bases: ABC
Abstract base class for complex domains.
A domain represents a region in the complex plane defined by a membership function. The domain can generate meshes for visualization and supports set operations (union, intersection).
Attributes:
| Name | Type | Description |
|---|---|---|
window_real |
tuple[float, float]
|
Left and right bounds of the viewing window. |
window_imag |
tuple[float, float]
|
Bottom and top bounds of the viewing window. |
square |
bool
|
Whether to constrain the viewing window to be square. |
Initialize domain with viewing window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
real
|
tuple[float, float]
|
Left and right edges of the viewing window. |
required |
imag
|
tuple[float, float]
|
Bottom and top edges of the viewing window. |
required |
square
|
bool
|
If True, constrain viewing window to be square. |
True
|
contains
abstractmethod
¶
Check if points belong to the domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
z
|
ndarray
|
Complex values to test. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean array indicating membership. |
spacing ¶
Calculate mesh point spacing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Distance between adjacent mesh points. |
mesh ¶
Generate complex mesh for the viewing window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
500
|
Returns:
| Type | Description |
|---|---|
ndarray
|
2D array of complex values. |
inmask ¶
Generate boolean mask for points inside the domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
500
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean mask (True for points inside). |
outmask ¶
Generate boolean mask for points outside the domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
500
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Boolean mask (True for points outside). |
domain ¶
Generate mesh with NaN outside the domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
500
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Complex mesh with NaN for points outside. |
union ¶
Create union with another domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Domain
|
Domain to union with. |
required |
Returns:
| Type | Description |
|---|---|
CompositeDomain
|
Union of the two domains. |
intersection ¶
Create intersection with another domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Domain
|
Domain to intersect with. |
required |
Returns:
| Type | Description |
|---|---|
CompositeDomain
|
Intersection of the two domains. |
difference ¶
Create set difference with another domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Domain
|
Domain to subtract. |
required |
Returns:
| Type | Description |
|---|---|
CompositeDomain
|
Points in this domain but not in other. |
complexplorer.Rectangle ¶
Bases: Domain
Rectangular domain in the complex plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
re_length
|
float
|
Length along the real axis. |
required |
im_length
|
float
|
Length along the imaginary axis. |
required |
center
|
complex
|
Center of the rectangle. |
0 + 0j
|
square
|
bool
|
Whether to use square viewing window. |
True
|
Initialize rectangular domain.
contains ¶
Check if points are inside the rectangle.
Membership is defined by the rectangle's own re_length/im_length about its
center — independent of any square-padding applied to the viewing window for
display (so a non-square rectangle does not report the padded strips as inside).
complexplorer.Disk ¶
complexplorer.Annulus ¶
Bases: Domain
Annular (ring-shaped) domain in the complex plane.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner_radius
|
float
|
Inner radius of the annulus. |
required |
outer_radius
|
float
|
Outer radius of the annulus. |
required |
center
|
complex
|
Center of the annulus. |
0 + 0j
|
Initialize annulus domain.
complexplorer.CompositeDomain ¶
Bases: Domain
Domain formed by set operations on other domains.
This class represents domains created by union, intersection, or difference of two existing domains.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain1
|
Domain
|
First domain. |
required |
domain2
|
Domain
|
Second domain. |
required |
operation
|
(union, intersection, difference)
|
Set operation to apply. |
'union'
|
Initialize composite domain.
calculate_tight_bounds ¶
calculate_tight_bounds(sample_density: int = 100) -> tuple[tuple[float, float], tuple[float, float]]
Calculate tight bounds by sampling the actual domain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_density
|
int
|
Number of sample points along each axis. |
100
|
Returns:
| Type | Description |
|---|---|
real_bounds, imag_bounds : tuple of tuple
|
Tight bounds for the composite domain. |
mesh ¶
Generate mesh grid of complex numbers.
For composite domains, can use tight bounds for better fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of points along the longer axis. |
500
|
use_tight_bounds
|
bool
|
If True, use tight bounds for composite domains. |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
2D array of complex values. |