Create a more semantic Size.numpy_shape property

This commit is contained in:
Eryn Wells 2023-02-12 14:28:14 -08:00
parent 84f7bdb947
commit cf31bcc272
2 changed files with 13 additions and 3 deletions

View file

@ -4,7 +4,7 @@
import math
from dataclasses import dataclass
from typing import Any, Iterator, Optional, overload
from typing import Any, Iterator, Optional, overload, Tuple
@dataclass(frozen=True)
@ -114,6 +114,11 @@ class Size:
width: int = 0
height: int = 0
@property
def numpy_shape(self) -> Tuple[int, int]:
'''Return a tuple suitable for passing into numpy array initializers for specifying the shape of the array.'''
return (self.width, self.height)
def __iter__(self):
yield self.width
yield self.height