NDArray -> ArrayLike typing
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
|
|
||||||
# the following functions are taken from Ben Southgate:
|
# the following functions are taken from Ben Southgate:
|
||||||
# https://bsouthga.dev/posts/colour-gradients-with-python
|
# https://bsouthga.dev/posts/colour-gradients-with-python
|
||||||
|
|
||||||
@@ -131,6 +133,7 @@ class LinearGradientColourMap(ColourMap):
|
|||||||
colours: list[str] | None = ["#ff0000", "#ffffff", "#0000ff"],
|
colours: list[str] | None = ["#ff0000", "#ffffff", "#0000ff"],
|
||||||
min_value: float = 0,
|
min_value: float = 0,
|
||||||
max_value: float = 1,
|
max_value: float = 1,
|
||||||
|
matrix: ArrayLike | None = None,
|
||||||
bins: int = 100,
|
bins: int = 100,
|
||||||
):
|
):
|
||||||
self.colours = polylinear_gradient(colours, bins)
|
self.colours = polylinear_gradient(colours, bins)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
import svg
|
import svg
|
||||||
from .colours import ColourMap
|
from .colours import ColourMap
|
||||||
|
|
||||||
@@ -6,8 +7,8 @@ from .colours import ColourMap
|
|||||||
class MatrixVisualisation:
|
class MatrixVisualisation:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
matrix: np.typing.NDArray,
|
|
||||||
cmap: ColourMap,
|
cmap: ColourMap,
|
||||||
|
matrix: ArrayLike,
|
||||||
text: bool = False,
|
text: bool = False,
|
||||||
labels: int | list[str] | bool = False,
|
labels: int | list[str] | bool = False,
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import logging
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from numpy.typing import ArrayLike
|
||||||
|
|
||||||
|
|
||||||
class NeuralNet:
|
class NeuralNet:
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
matrix: np.typing.NDArray | list[np.typing.NDArray] | None = None,
|
matrix: ArrayLike | list[ArrayLike] | None = None,
|
||||||
shape: tuple[int] | None = None,
|
shape: tuple[int] | None = None,
|
||||||
node_colour: str = "blue",
|
node_colour: str = "blue",
|
||||||
node_border: str = "black",
|
node_border: str = "black",
|
||||||
@@ -18,7 +19,7 @@ class NeuralNet:
|
|||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
matrix : np.typing.NDArray | None
|
matrix : ArrayLike | None
|
||||||
matrix or list of matrices
|
matrix or list of matrices
|
||||||
shape : tuple[int] | None
|
shape : tuple[int] | None
|
||||||
shape
|
shape
|
||||||
|
|||||||
Reference in New Issue
Block a user