Skip to content

Replace kwargs:dict with kwargs:any #697

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions pymoo/core/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
]

import copy
from typing import Any
from typing import Optional
from typing import Tuple
from typing import Union
Expand Down Expand Up @@ -48,7 +49,7 @@ class Individual:
def __init__(
self,
config: Optional[dict] = None,
**kwargs: dict,
**kwargs: Any,
) -> None:
"""
Constructor for the ``Invididual`` class.
Expand All @@ -58,7 +59,7 @@ def __init__(
config : dict, None
A dictionary of configuration metadata.
If ``None``, use a class-dependent default configuration.
kwargs : dict
kwargs : Any
Additional keyword arguments containing data which is to be stored
in the ``Individual``.
"""
Expand Down Expand Up @@ -553,14 +554,14 @@ def feasible(self) -> np.ndarray:

def set_by_dict(
self,
**kwargs: dict
**kwargs: Any
) -> None:
"""
Set an individual's data or metadata using values in a dictionary.

Parameters
----------
kwargs : dict
kwargs : Any
Keyword arguments defining the data to set.
"""
for k, v in kwargs.items():
Expand Down Expand Up @@ -594,15 +595,15 @@ def set(

def get(
self,
*keys: Tuple[str,...],
*keys: str,
) -> Union[tuple,object]:
"""
Get the values for one or more keys for an individual.

Parameters
----------
keys : tuple
A tuple of keys for which to get values.
keys : str
Keys for which to get values.

Returns
-------
Expand Down
18 changes: 9 additions & 9 deletions pymoo/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"get",
]

from typing import Optional, Tuple
from typing import Any, Optional, Tuple
from typing import Union
import numpy as np
from numpy.typing import ArrayLike
Expand Down Expand Up @@ -111,14 +111,14 @@ def set(

def get(
self,
**kwargs: dict
**kwargs: Any
) -> object:
"""
Get the value of a decision variable.

Parameters
----------
kwargs : dict
kwargs : Any
Additional keyword arguments.

Returns
Expand All @@ -139,7 +139,7 @@ def __init__(
value: Optional[object] = None,
bounds: Tuple[Optional[object],Optional[object]] = (None, None),
strict: Optional[Tuple[Optional[object],Optional[object]]] = None,
**kwargs: dict,
**kwargs: Any,
) -> None:
"""
Constructor for the ``BoundedVariable`` class.
Expand All @@ -154,7 +154,7 @@ def __init__(
strict : tuple, None
Strict boundaries for the decision variable.
If ``None``, the value of ``bounds`` is copied to ``strict``.
kwargs : dict
kwargs : Any
Additional keyword arguments for ``active`` and ``flag``.
"""
# call the Variable constructor
Expand Down Expand Up @@ -302,7 +302,7 @@ def __init__(
value: Optional[object] = None,
options: Optional[ArrayLike] = None,
all: Optional[ArrayLike] = None,
**kwargs: dict,
**kwargs: Any,
) -> None:
"""
Constructor for the ``Choice`` class.
Expand All @@ -316,7 +316,7 @@ def __init__(
all : ArrayLike, None
A strict list of decision variable options from which to choose.
If ``None``, the value of ``options`` is copied to ``all``.
kwargs : dict
kwargs : Any
Additional keyword arguments for ``active`` and ``flag``.
"""
# all super constructor
Expand Down Expand Up @@ -357,7 +357,7 @@ def _sample(
def get(
*args: Tuple[Union[Variable,object],...],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the same change can be made here as you made further above for *keys.

size: Optional[Union[tuple,int]] = None,
**kwargs: dict
**kwargs: Any
) -> Union[tuple,object,None]:
"""
Get decision variable values from a tuple of ``Variable`` objects.
Expand All @@ -368,7 +368,7 @@ def get(
A tuple of ``Variable`` or ``object``s.
size : tuple, int, None
Size to reshape decision variables.
kwargs : dict
kwargs : Any
Additional keyword arguments to pass to the ``get`` method of the
``Variable`` class when getting decision variable values.

Expand Down
Loading