Commit Graph
24 Commits
Author SHA1 Message Date
jono 8468e78bcf chore: update project configuration in pyproject.toml
Run Python Tests / test (3.12) (pull_request) Successful in 22s
Run Python Tests / test (3.14) (pull_request) Successful in 2m0s
Run Python Tests / test (3.10) (pull_request) Successful in 2m50s
Publish Python Package to PyPI / deploy (push) Successful in 46s
2026-09-29 21:45:43 -04:00
jono 563fb440a3 refactor!: migrate to modern numpy API, patch root solving, and bump dependencies
Run Python Tests / test (3.10) (pull_request) Successful in 21s
Run Python Tests / test (3.12) (pull_request) Successful in 26s
Run Python Tests / test (3.14) (pull_request) Successful in 20s
- Drop support for Python 3.8.
- Bump minimum dependencies to `numpy>=2.0` and `numba>=0.60`.
- Replace legacy NumPy polynomial functions (polyder, polyadd, etc.) with
  the modern `numpy.polynomial.Polynomial` class for stable calculus and
  arithmetic operations.
- Remove `_strip_leading_zeros` as the modern API handles degree alignment
  and zero-trimming natively.
- Retain highest-to-lowest `self.coefficients` array to maintain compatibility
  with Numba and CUDA GPU kernels evaluating via Horner's method.
- Fix `TypeError` in `quadratic_solve` by evaluating `b.real >= 0` to safely
  support complex coefficients.
- Update `quadratic_solve` return type hint to `np.ndarray`.
2026-09-26 11:41:11 -04:00
jono 313efcebd0 Add Python 3.13 & 3.14 to supported version in toml file 2026-09-26 15:02:03 +00:00
jono 1b94ac6e3f Minor incremental version update
Publish Python Package to PyPI / deploy (push) Successful in 1m0s
No code changes in this update, just added automated testing for Python 3.14
2026-09-26 14:49:39 +00:00
jonoandjono b6b30008a6 v0.7.0 - Complex Number Support (#25)
Publish Python Package to PyPI / deploy (push) Successful in 13s
Reviewed-on: #25
Co-authored-by: Jonathan Rampersad <[email protected]>
Co-committed-by: Jonathan Rampersad <[email protected]>
2026-01-31 15:31:57 +00:00
jono 1aa2e8875a Made the default values of min/max_range 0.0
Run Python Tests / test (3.10) (pull_request) Successful in 14s
Run Python Tests / test (3.12) (pull_request) Successful in 26s
Run Python Tests / test (3.8) (pull_request) Successful in 14s
Publish Python Package to PyPI / deploy (push) Successful in 12s
2025-11-05 18:58:20 -04:00
jono 94723dcb88 feat(Function): Add __eq__ method and improve quadratic_solve stability
Run Python Tests / test (3.10) (pull_request) Successful in 13s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
Run Python Tests / test (3.8) (pull_request) Successful in 14s
Publish Python Package to PyPI / deploy (push) Successful in 13s
Implements two features for the Function class:

1.  Adds the `__eq__` operator (`==`) to allow for logical comparison of two Function objects based on their coefficients.
2.  Replaces the standard quadratic formula with a numerically stable version in `quadratic_solve` to prevent "catastrophic cancellation" errors and improve accuracy.
2025-11-02 12:50:48 -04:00
jono b7ea6c2e23 Added root_precision warning 2025-10-31 11:08:02 -04:00
jono 9d967210fa feat(ga): Overhaul GA for multi-root robustness and CPU performance
Run Python Tests / test (3.12) (pull_request) Successful in 34s
Run Python Tests / test (3.8) (pull_request) Successful in 35s
Run Python Tests / test (3.10) (pull_request) Successful in 3m8s
Publish Python Package to PyPI / deploy (push) Successful in 12s
### 🚀 Performance (CPU)
* Replaces `np.polyval` with a parallel Numba JIT function (`_calculate_ranks_numba`).
* Replaces $O(N \log N)$ `np.argsort` with $O(N)$ `np.argpartition` in the GA loop.
* Adds `numba` as a core dependency.

### 🧠 Robustness (Algorithm)
* Implements Blend Crossover (BLX-$\alpha$) for better, extrapolative exploration.
* Uses a hybrid selection model (top X% for crossover, 100% for mutation) to preserve root niches.
* Adds `selection_percentile` and `blend_alpha` to `GA_Options` for tuning.
2025-10-30 11:31:00 -04:00
jonoandjono 1318006959 v0.5.1-dev (#20)
Publish Python Package to PyPI / deploy (push) Successful in 56s
Reviewed-on: #20
Co-authored-by: Jonathan Rampersad <[email protected]>
Co-committed-by: Jonathan Rampersad <[email protected]>
2025-10-28 15:42:34 +00:00
jonoandjono 4e46c11f83 feat(ga): Implement quality filtering and precision-based clustering (#19)
Publish Python Package to PyPI / deploy (push) Successful in 12s
The previous GA logic was returning the "top N" solutions, which led to test failures when the algorithm correctly converged on only one of all possible roots (e.g., returning 1000 variations of -1.0).

This commit fixes the root-finding logic to correctly identify and return *all* unique, high-quality roots:

1.  **feat(api):** Adds `root_precision` to `GA_Options`. This new parameter (default: 5) allows the user to control the number of decimal places for clustering unique roots.

2.  **fix(ga):** Replaces the flawed "top N" logic in both `_solve_x_numpy` and `_solve_x_cuda`. The new process is:
    * Dynamically sets a `quality_threshold` based on the user's `root_precision` (e.g., `precision=5` requires a rank > `1e6`).
    * Filters the *entire* final population for all solutions that meet this quality threshold.
    * Rounds these high-quality solutions to `root_precision`.
    * Returns only the `np.unique()` results.

This ensures the solver returns all distinct roots that meet the accuracy requirements, rather than just the top N variations of a single root.

Reviewed-on: #19
Co-authored-by: Jonathan Rampersad <[email protected]>
Co-committed-by: Jonathan Rampersad <[email protected]>
2025-10-27 19:26:50 +00:00
jono 962eab5af7 feat(ga): Implement Cauchy's bound for automatic root range detection
Run Python Tests / test (3.12) (pull_request) Successful in 10s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Successful in 12s
The previous benchmark results showed that the GA was failing to find accurate roots (high MAE) for many polynomials. This was because the fixed default search range ([-100, 100]) was often incorrect, and the GA was searching in the wrong place.

This commit introduces a significantly more robust solution:

1.  Adds a `_get_cauchy_bound` helper function to mathematically calculate a search radius that is guaranteed to contain all real roots.

2.  Updates `_solve_x_numpy` and `_solve_x_cuda` with new logic:
    * If the user provides a *custom* `min_range` or `max_range`, we treat them as an expert and use their specified range.
    * If the user is using the *default* range, we silently discard it and use the smarter, automatically-calculated Cauchy bound instead.

This provides the best of both worlds: a powerful, smart default for most users and an "expert override" for those who need to fine-tune the search area.
2025-10-27 14:33:12 -04:00
jono 7c75000637 fix(ga): Suppress divide-by-zero warning in NumPy solver
Publish Python Package to PyPI / deploy (push) Successful in 18s
Run Python Tests / test (3.10) (pull_request) Successful in 17s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Run Python Tests / test (3.12) (pull_request) Successful in 12s
The `_solve_x_numpy` method was correctly using `np.where(error == 0, ...)` to handle perfect roots. However, NumPy eagerly calculates `1.0 / error` for the entire array before applying the `where` condition, which was causing a `RuntimeWarning: divide by zero` when a perfect root was found.

This warning was harmless but created unnecessary console noise during testing and use.

This commit wraps the `ranks = ...` assignments in a `with np.errstate(divide='ignore'):` block to silence this specific, expected warning. The CUDA kernel is unaffected as its ternary operator already prevents this calculation.
2025-10-27 12:25:54 -04:00
jonoandjono c3b3513e79 feat(ga, api): Implement advanced GA strategy and refactor API for v0.4.0 (#16)
Publish Python Package to PyPI / deploy (push) Successful in 18s
This commit introduces a major enhancement to the genetic algorithm's convergence logic and refactors key parts of the API for better clarity and usability.

- **feat(ga):** Re-implements the GA solver (CPU & CUDA) to use a more robust strategy based on Elitism, Crossover, and Mutation. This replaces the previous, less efficient model and is designed to significantly improve accuracy and convergence speed.

- **feat(api):** Updates `GA_Options` to expose the new GA strategy parameters:
    - Renames `mutation_percentage` to `mutation_strength` for clarity.
    - Adds `elite_ratio`, `crossover_ratio`, and `mutation_ratio`.
    - Includes a `__post_init__` validator to ensure ratios are valid.

- **refactor(api):** Moves `quadratic_solve` from a standalone function to a method of the `Function` class (`f1.quadratic_solve()`). This provides a cleaner, more object-oriented API.

- **docs:** Updates the README, `GA_Options` doc page, and `quadratic_solve` doc page to reflect all API changes, new parameters, and updated usage examples.

- **chore:** Bumps version to 0.4.0.

Reviewed-on: #16
Co-authored-by: Jonathan Rampersad <[email protected]>
Co-committed-by: Jonathan Rampersad <[email protected]>
2025-10-27 14:20:56 +00:00
jono 6596c2df99 typo fix
Publish Python Package to PyPI / deploy (push) Successful in 14s
2025-06-19 18:00:29 +00:00
jono 24337cea48 Updated Project urls
Run Python Tests / test (3.12) (pull_request) Successful in 10s
Run Python Tests / test (3.10) (pull_request) Successful in 14s
Run Python Tests / test (3.8) (pull_request) Successful in 10s
Publish Python Package to PyPI / deploy (push) Failing after 14s
Signed-off-by: Jonathan Rampersad <[email protected]>
2025-06-19 17:58:50 +00:00
jono ee18cc9e59 Added Branding (#14)
Publish Python Package to PyPI / deploy (push) Successful in 19s
Reviewed-on: #14
2025-06-19 17:54:07 +00:00
jonoandjono ce464cffd4 FEAT: Added support for float coefficients (#13)
Publish Python Package to PyPI / deploy (push) Successful in 13s
Reviewed-on: #13
Co-authored-by: Jonathan Rampersad <[email protected]>
Co-committed-by: Jonathan Rampersad <[email protected]>
2025-06-18 13:20:18 +00:00
jono c94d08498d Edited README to advise of function * function multiplication being available (#12)
Publish Python Package to PyPI / deploy (push) Successful in 17s
Reviewed-on: #12
2025-06-18 12:55:37 +00:00
jono 32d6cfeeea Update pyproject.toml
Run Python Tests / test (3.12) (pull_request) Successful in 9s
Run Python Tests / test (3.10) (pull_request) Successful in 13s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 18:37:33 +00:00
jono 25f20a4db2 v0.2.0
Run Python Tests / test (3.12) (pull_request) Failing after 11s
Run Python Tests / test (3.10) (pull_request) Failing after 15s
Run Python Tests / test (3.8) (pull_request) Failing after 11s
2025-06-17 14:26:45 -04:00
GitHub Bridge Bot 83f565c08c Apply patch from GitHub PR #4 by jono-rams
Run Python Tests / test (3.10) (pull_request) Successful in 10s
Run Python Tests / test (3.12) (pull_request) Successful in 15s
Run Python Tests / test (3.8) (pull_request) Successful in 9s
2025-06-17 13:05:16 +00:00
jono 593a9de9e0 Removed cuda 11 version for consistency with automated tests
Run Python Tests / test (3.10) (push) Successful in 11s
Run Python Tests / test (3.8) (push) Successful in 10s
Run Python Tests / test (3.12) (push) Successful in 14s
2025-06-16 19:27:24 -04:00
jono 2dc39b6ae3 Initial Commit
Run Python Tests / test (3.8) (push) Failing after 3s
Run Python Tests / test (3.10) (push) Failing after 12s
Run Python Tests / test (3.12) (push) Failing after 2m0s
2025-06-16 18:40:06 -04:00