Skip to content

Commit

Permalink
Merge pull request #112 from NiklasMelton/consistency-fixes
Browse files Browse the repository at this point in the history
improve consistency across modules
  • Loading branch information
NiklasMelton authored Oct 18, 2024
2 parents d33e056 + fc233b8 commit 8b8a242
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions artlib/common/BaseART.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def set_params(self, **params):
for key, value in params.items():
key, delim, sub_key = key.partition("__")
if key not in valid_params:
local_valid_params = List(valid_params.keys())
local_valid_params = list(valid_params.keys())
raise ValueError(
f"Invalid parameter {key!r} for estimator {self}. "
f"Valid parameters are: {local_valid_params!r}."
Expand Down Expand Up @@ -219,7 +219,7 @@ def match_criterion(
w: np.ndarray,
params: Dict,
cache: Optional[Dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions artlib/elementary/ART1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Processing, 37, 54 – 115. doi:10. 1016/S0734-189X(87)80014-2.

import numpy as np
from typing import Optional, List, Tuple, Union, Dict
from typing import Optional, List, Tuple, Dict
from artlib.common.BaseART import BaseART
from artlib.common.utils import l1norm

Expand Down Expand Up @@ -108,7 +108,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion artlib/elementary/BayesianART.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions artlib/elementary/EllipsoidART.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# International Society for Optics and Photonics. doi:10.1117/12.421180.

import numpy as np
from typing import Optional, List, Tuple, Union, Dict
from typing import Optional, List, Tuple, Dict
from matplotlib.axes import Axes
from artlib.common.BaseART import BaseART
from artlib.common.utils import l2norm2, IndexableOrKeyable
Expand Down Expand Up @@ -166,7 +166,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions artlib/elementary/FuzzyART.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Neural Networks, 4, 759 – 771. doi:10.1016/0893-6080(91)90056-B.

import numpy as np
from typing import Optional, Iterable, List, Tuple, Union, Dict
from typing import Optional, Iterable, List, Tuple, Dict
from matplotlib.axes import Axes
from artlib.common.BaseART import BaseART
from artlib.common.utils import (
Expand Down Expand Up @@ -206,7 +206,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions artlib/elementary/GaussianART.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Neural Networks, 9, 881 – 897. doi:10.1016/0893-6080(95)00115-8.

import numpy as np
from typing import Optional, Iterable, List, Tuple, Union, Dict
from typing import Optional, Iterable, List, Tuple, Dict
from matplotlib.axes import Axes
from artlib.common.BaseART import BaseART
from artlib.common.visualization import plot_gaussian_contours_fading
Expand Down Expand Up @@ -109,7 +109,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions artlib/elementary/QuadraticNeuronART.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Pattern Recognition, 38, 1887 – 1901. doi:10.1016/j.patcog.2005.04.010.

import numpy as np
from typing import Optional, Iterable, List, Tuple, Union, Dict
from typing import Optional, Iterable, List, Tuple, Dict
from matplotlib.axes import Axes
from artlib.common.BaseART import BaseART
from artlib.common.utils import l2norm2
Expand Down Expand Up @@ -133,7 +133,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion artlib/experimental/ConvexHullART.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def match_criterion(
w: HullTypes,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""
Get the match criterion of the cluster.
Expand Down
2 changes: 1 addition & 1 deletion artlib/experimental/SeqART.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def category_choice(

def match_criterion(
self, i: str, w: str, params: dict, cache: Optional[dict] = None
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""
Get the match criterion of the cluster.
Expand Down
8 changes: 4 additions & 4 deletions artlib/fusion/FusionART.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def match_criterion(
params: Dict,
cache: Optional[Dict] = None,
skip_channels: List[int] = [],
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion for the cluster.
Parameters
Expand All @@ -308,7 +308,7 @@ def match_criterion(
Returns
-------
tuple
List of match criteria for each channel and the updated cache.
max match_criterion across channels and the updated cache.
"""
if cache is None:
Expand All @@ -322,12 +322,12 @@ def match_criterion(
cache[k],
)
if k not in skip_channels
else (np.inf, {"match_criterion": np.inf})
else (np.nan, {"match_criterion": np.inf})
for k in range(self.n)
]
)
cache = {k: cache_k for k, cache_k in enumerate(caches)}
return M, cache
return np.nanmax(M), cache

def match_criterion_bin(
self,
Expand Down
2 changes: 1 addition & 1 deletion artlib/topological/TopoART.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def match_criterion(
w: np.ndarray,
params: dict,
cache: Optional[dict] = None,
) -> Tuple[Union[float, List[float]], Optional[Dict]]:
) -> Tuple[float, Optional[Dict]]:
"""Get the match criterion of the cluster.
Parameters
Expand Down

0 comments on commit 8b8a242

Please sign in to comment.