Update README and tests for new integral function
Publish Python Package to PyPI / deploy (push) Successful in 13s
Run Python Tests / test (3.10) (pull_request) Successful in 20s
Run Python Tests / test (3.12) (pull_request) Successful in 7s
Run Python Tests / test (3.14) (pull_request) Successful in 20s

This commit was merged in pull request #27.
This commit is contained in:
2026-09-26 12:04:32 -04:00
parent 563fb440a3
commit 2fa219f860
2 changed files with 36 additions and 3 deletions
+21
View File
@@ -18,6 +18,13 @@ def quadratic_func() -> Function:
f.set_coeffs([2, -3, -5])
return f
@pytest.fixture
def int_func() -> Function:
"""Provides a function for easy integral calculation."""
f = Function(largest_exponent=2)
f.set_coeffs([3, -4, -5])
return f
@pytest.fixture
def linear_func() -> Function:
"""Provides a standard linear function: x + 10."""
@@ -70,6 +77,20 @@ def test_nth_derivative(quadratic_func):
# The derivative of 2x^2 - 3x - 5 is 4x - 3
assert np.array_equal(derivative.coefficients, [4])
def test_integral(int_func):
"""Tests the calculation of the function's integral."""
integral = int_func.integral()
assert integral.largest_exponent == 3
# The integral of 2x^2 -3x - 5 is x^3 - 2x^2 - 5x
assert np.array_equal(integral.coefficients, [1, -2, -5, 0])
def test_integral_custom_constant(int_func):
"""Tests the calculation of the function's integral with custom constant of integration."""
integral = int_func.integral(constant_of_integration=42)
assert integral.largest_exponent == 3
# The integral of 2x^2 -3x - 5 is x^3 - 2x^2 - 5x
assert np.array_equal(integral.coefficients, [1, -2, -5, 42])
def test_quadratic_solve(quadratic_func):
"""Tests the analytical quadratic solver for exact roots."""
roots = quadratic_func.quadratic_solve()