Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
PasaOpasen committed Apr 13, 2024
1 parent a601fe1 commit ba508b4
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 377 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pip install geneticalgorithm2[full]
- `AlgorithmParams` class for base GA algorithm parameters (instead of dictionary)
- `Generation` class for saving/loading/returning generation (instead of dictionary)

All that classes are collected [in file](geneticalgorithm2/classes.py). To maintain backward compatibility, `AlgorithmParams` and `Generation` classes have dictionary-like interface for getting fields: u can use `object.field` or `object['field']` notations.
All that classes are collected [in file](geneticalgorithm2/data_types/classes.py). To maintain backward compatibility, `AlgorithmParams` and `Generation` classes have dictionary-like interface for getting fields: u can use `object.field` or `object['field']` notations.


# Working process
Expand Down
10 changes: 6 additions & 4 deletions geneticalgorithm2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@

from typing_extensions import TypeAlias

from .classes import Generation, AlgorithmParams
"""
Genetic Algorithm (Elitist version) for Python3.8+
Expand All @@ -12,6 +8,12 @@
code docs path: https://pasaopasen.github.io/geneticalgorithm2/
"""


from typing_extensions import TypeAlias

from .data_types.algorithm_params import AlgorithmParams
from .data_types.generation import Generation

from .geneticalgorithm2 import GeneticAlgorithm2

# to keep backward compatibility like it was since geneticalgorithm package
Expand Down
5 changes: 3 additions & 2 deletions geneticalgorithm2/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
from .utils.files import mkdir
from .utils.funcs import union_to_matrix, fast_max

from .classes import MiddleCallbackData, Generation

from .data_types.generation import Generation
from .data_types.callback import MiddleCallbackData

from .crossovers import CrossoverFunc
from .selections import SelectionFunc
from .mutations import MutationFunc

# TODO refactor

CallbackFunc: TypeAlias = Callable[[int, List[float], array2D, array1D], None]
MiddleCallbackActionFunc: TypeAlias = Callable[[MiddleCallbackData], MiddleCallbackData]
Expand Down
Loading

0 comments on commit ba508b4

Please sign in to comment.