Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add generic typing to grid generator #37

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"""Generators for the grid"""

from typing import Type
from typing import Generic, Type, TypeVar

import numpy as np

Expand All @@ -18,13 +18,15 @@

# pylint: disable=too-few-public-methods,too-many-arguments,too-many-positional-arguments

T = TypeVar("T", bound=Grid)

class RadialGridGenerator:

class RadialGridGenerator(Generic[T]):
"""Generates a random but structurally correct radial grid with the given specifications"""

def __init__(
self,
grid_class: Type[Grid],
grid_class: Type[T],
nr_nodes: int = 100,
nr_sources: int = 2,
nr_nops: int = 10,
Expand All @@ -36,7 +38,7 @@ def __init__(
self.nr_sources = nr_sources
self.nr_nops = nr_nops

def run(self, seed=None, create_10_3_kv_net: bool = False):
def run(self, seed=None, create_10_3_kv_net: bool = False) -> T:
"""Run the generator to create a random radial grid.

if a seed is provided, this will be used to set rng.
Expand Down