Skip to content

Commit

Permalink
Fix variance specification for GraphFunction (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
donRumata03 authored Apr 4, 2024
1 parent 46a905a commit 457ebd7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions golem/core/optimisers/objective/objective.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import itertools
from dataclasses import dataclass
from numbers import Real
from typing import Any, Optional, Callable, Sequence, TypeVar, Dict, Tuple, Union
from typing import Any, Optional, Callable, Sequence, TypeVar, Dict, Tuple, Union, Protocol

from golem.core.dag.graph import Graph
from golem.core.log import default_log
from golem.core.optimisers.fitness import Fitness, SingleObjFitness, null_fitness, MultiObjFitness

G = TypeVar('G', bound=Graph, covariant=True)
R = TypeVar('R', contravariant=True)
GraphFunction = Callable[[G], R]
G = TypeVar('G', bound=Graph, contravariant=True)
R = TypeVar('R', covariant=True)


class GraphFunction(Protocol[G, R]):
def __call__(self, graph: G) -> R:
...


ObjectiveFunction = GraphFunction[G, Fitness]


Expand Down

0 comments on commit 457ebd7

Please sign in to comment.