Skip to content

Commit 82c8ba6

Browse files
authored
Circle shape updates (#290)
1 parent fc93eaa commit 82c8ba6

File tree

10 files changed

+411
-236
lines changed

10 files changed

+411
-236
lines changed

src/data_morph/bounds/bounding_box.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,25 @@ def clone(self) -> BoundingBox:
170170
)
171171

172172
@property
173-
def range(self) -> Iterable[Number]:
173+
def range(self) -> tuple[Number, Number]:
174174
"""
175175
Calculate the range (width) of the bounding box in each direction.
176176
177177
Returns
178178
-------
179-
Iterable[numbers.Number]
179+
tuple[Number, Number]
180180
The range covered by the x and y bounds, respectively.
181181
"""
182182
return self.x_bounds.range, self.y_bounds.range
183183

184184
@property
185-
def center(self) -> Iterable[Number]:
185+
def center(self) -> tuple[Number, Number]:
186186
"""
187187
Calculate the center of the bounding box.
188188
189189
Returns
190190
-------
191-
Iterable[numbers.Number]
191+
tuple[Number, Number]
192192
The center of the x and y bounds, respectively.
193193
"""
194194
return self.x_bounds.center, self.y_bounds.center

src/data_morph/shapes/circles.py

Lines changed: 0 additions & 213 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Shapes made up of circles."""
2+
3+
from .bullseye import Bullseye
4+
from .circle import Circle
5+
from .rings import Rings
6+
7+
__all__ = [
8+
'Bullseye',
9+
'Circle',
10+
'Rings',
11+
]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""Bullseye shape."""
2+
3+
from __future__ import annotations
4+
5+
from typing import TYPE_CHECKING
6+
7+
import numpy as np
8+
9+
from .rings import Rings
10+
11+
if TYPE_CHECKING:
12+
from ..data.dataset import Dataset
13+
14+
15+
class Bullseye(Rings):
16+
"""
17+
Class representing a bullseye shape comprising two concentric circles.
18+
19+
.. plot::
20+
:scale: 75
21+
:caption:
22+
This shape is generated using the panda dataset.
23+
24+
from data_morph.data.loader import DataLoader
25+
from data_morph.shapes.circles import Bullseye
26+
27+
_ = Bullseye(DataLoader.load_dataset('panda')).plot()
28+
29+
See Also
30+
--------
31+
Circle : The individual rings are represented as circles.
32+
"""
33+
34+
@staticmethod
35+
def _derive_radii(dataset: Dataset) -> np.ndarray:
36+
"""
37+
Derive the radii for the circles in the bullseye.
38+
39+
Parameters
40+
----------
41+
dataset : Dataset
42+
The starting dataset to morph into.
43+
44+
Returns
45+
-------
46+
np.ndarray
47+
The radii for the circles in the bullseye.
48+
"""
49+
stdev = dataset.data[['x', 'y']].std().mean() * 1.5
50+
return np.linspace(stdev, 0, 2, endpoint=False)

0 commit comments

Comments
 (0)