ellphi.ellcloud
The EllipseCloud class is the central data structure of EllPHi. It holds an array of ellipsoid coefficient vectors together with the original means and covariances, and provides convenience methods for computing tangency distances and visualisation.
The ellipse_cloud factory function (an alias for EllipseCloud.from_point_cloud) is the recommended entry point:
When centres and covariance matrices are already available, prefer the direct constructor:
ellphi.ellcloud
ellphi.ellcloud – ellipse cloud interfaces
- ellipse_cloud(X, method="local_cov", rescaling="none", k=5)
- class EllipseCloud
- class LocalCov
EllipseCloud
dataclass
A container for an ellipse cloud with convenience methods.
This class provides a convenient way to store and manipulate a collection of ellipses. It includes methods for plotting, computing pairwise tangency distances, and creating an ellipse cloud from a point cloud.
Attributes:
| Name | Type | Description |
|---|---|---|
coef |
FloatArray
|
A NumPy array of shape |
mean |
FloatArray
|
A NumPy array of shape |
cov |
FloatArray
|
A NumPy array of shape |
k |
int
|
The number of nearest neighbors used to create the ellipse cloud. |
nbd |
NDArray[int_]
|
A NumPy array of shape |
n |
int
|
The number of ellipses in the cloud. |
n_dim |
int
|
The number of dimensions of the ellipses. |
Source code in src/ellphi/ellcloud.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | |
__getitem__(idx)
Returns the conic coefficient array for a single ellipsoid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx |
Any
|
The index of the ellipsoid to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
FloatArray
|
A NumPy array representing the conic coefficients of the specified |
FloatArray
|
ellipsoid. |
Source code in src/ellphi/ellcloud.py
distance_matrix(*, parallel=True, n_jobs=-1, backend='auto')
Computes the square pairwise tangency distance matrix.
This is a convenience wrapper around pdist_tangency that returns the
full square matrix using the same layout as
scipy.spatial.distance.squareform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parallel |
bool
|
If |
True
|
n_jobs |
int | None
|
The number of jobs to run in parallel. See
|
-1
|
backend |
str
|
The backend to use for the computation. Can be one of "auto", "python", or "cpp". |
'auto'
|
Returns:
| Type | Description |
|---|---|
FloatArray
|
A square matrix of tangency distances with shape |
Source code in src/ellphi/ellcloud.py
from_cov(X, cov, *, rescaling='none')
classmethod
Creates an EllipseCloud from centers and covariance matrices.
This class method is the recommended entry point when ellipsoid covariances are already known and no k-nearest-neighbour structure is involved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
FloatArray
|
An array of centers with shape |
required |
cov |
FloatArray
|
An array of covariance matrices with shape |
required |
rescaling |
str
|
The method to use for rescaling the ellipses. Can be one of "none", "median", or "average". |
'none'
|
Returns:
| Type | Description |
|---|---|
EllipseCloud
|
An |
EllipseCloud
|
covariances. |
Source code in src/ellphi/ellcloud.py
from_local_cov(X, *, k=5)
classmethod
Creates an EllipseCloud from a point cloud using local covariance.
This class method creates an EllipseCloud from a point cloud by
computing the local covariance of the k-nearest neighbors for each
point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
FloatArray
|
A NumPy array of shape |
required |
k |
int
|
The number of nearest neighbors to use for computing the local covariance. |
5
|
Returns:
| Type | Description |
|---|---|
EllipseCloud
|
An |
Source code in src/ellphi/ellcloud.py
from_point_cloud(X, *, method='local_cov', rescaling='none', **kwgs)
classmethod
Creates an EllipseCloud from a point cloud.
This class method provides a way to create an EllipseCloud from a
given point cloud. It supports different methods for creating the
ellipses and for rescaling them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
FloatArray
|
A NumPy array of shape |
required |
method |
str
|
The method to use for creating the ellipses. Currently, only "local_cov" is supported. |
'local_cov'
|
rescaling |
str
|
The method to use for rescaling the ellipses. Can be one of "none", "median", or "average". |
'none'
|
**kwgs |
Any
|
Additional keyword arguments to pass to the specified
|
{}
|
Returns:
| Type | Description |
|---|---|
EllipseCloud
|
An |
Source code in src/ellphi/ellcloud.py
pdist_tangency(*, parallel=True, n_jobs=-1, backend='auto')
Computes pairwise tangency distances for the ellipse cloud.
This is a convenience method that calls ellphi.solver.pdist_tangency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parallel |
bool
|
If |
True
|
n_jobs |
int | None
|
The number of jobs to run in parallel. See
|
-1
|
backend |
str
|
The backend to use for the computation. Can be one of "auto", "python", or "cpp". |
'auto'
|
Returns:
| Type | Description |
|---|---|
FloatArray
|
A condensed distance matrix of tangency distances. |
Source code in src/ellphi/ellcloud.py
plot(ids=None, ax=None, scale=1.0, **kwgs)
A quick matplotlib visualization of the ellipse cloud.
This method provides a simple way to visualize the ellipse cloud using
matplotlib. It can plot all ellipses or a subset of them, and it can
be used with an existing Axes object or create a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ids |
Sequence[int] | None
|
A sequence of indices of the ellipses to plot. If |
None
|
ax |
Axes | None
|
An existing |
None
|
scale |
float
|
A scaling factor for the ellipses. |
1.0
|
**kwgs |
Any
|
Additional keyword arguments to pass to the
|
{}
|
Returns:
| Type | Description |
|---|---|
Axes
|
The |
Source code in src/ellphi/ellcloud.py
rescale(*, method='median')
Applies rescaling to all the ellipses in the cloud.
This method rescales all the ellipses in the cloud based on the specified method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method |
str
|
The rescaling method to use. Can be "median" or "average". |
'median'
|
Returns:
| Type | Description |
|---|---|
float
|
The scaling factor used to rescale the ellipses. |
Source code in src/ellphi/ellcloud.py
LocalCov
dataclass
An algorithm for creating an EllipseCloud from k-nearest neighbors.
This class implements an algorithm for creating an EllipseCloud from a
point cloud by computing the local covariance of the k-nearest neighbors
for each point.
Attributes:
| Name | Type | Description |
|---|---|---|
k |
int
|
The number of nearest neighbors to use for computing the local covariance. |
Source code in src/ellphi/ellcloud.py
__call__(X)
Creates an EllipseCloud from a point cloud.
This method takes a point cloud and creates an EllipseCloud by
computing the local covariance of the k-nearest neighbors for each
point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
FloatArray
|
A NumPy array of shape |
required |
Returns:
| Type | Description |
|---|---|
EllipseCloud
|
An |
EllipseCloud
|
the number of ellipses can be less than the number of input points |
EllipseCloud
|
|
EllipseCloud
|
single ellipse. |