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

Added some unittests for parent selection, population creation, and crossover/mutation #8

Merged
merged 5 commits into from
Jan 28, 2025

Conversation

danyoungday
Copy link
Contributor

Also some miscellaneous linting and formatting fixes in the process.

@danyoungday danyoungday self-assigned this Jan 27, 2025
@@ -85,7 +85,7 @@ def selection(self, sorted_population: list[Prescriptor]) -> list[Prescriptor]:
"""
idx1 = min(random.choices(range(len(sorted_population)), k=2))
idx2 = min(random.choices(range(len(sorted_population)), k=2))
return sorted_population[idx1], sorted_population[idx2]
return [sorted_population[idx1], sorted_population[idx2]]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returns what we actually expect (a list)

@@ -84,7 +87,7 @@ def mutate_(self, candidate: NNPrescriptor, mutation_rate: float, mutation_facto
param[mutate_mask].shape,
device=param.device,
dtype=param.dtype)
param[mutate_mask] += noise * param[mutate_mask]
param[mutate_mask] *= (1 + noise)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mathematically the same I'm not sure how the compiler handles it but it may be faster.

@danyoungday danyoungday merged commit e761964 into main Jan 28, 2025
1 check passed
@danyoungday danyoungday deleted the testing branch January 28, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant