Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Change Log

.. currentmodule:: idesolver

v1.2.0
------

* :math:`k(x, s)` can now be a matrix.
* `UnexpectedlyComplexValuedIDE` is no longer raised if any `TypeError` occurs during integration.
This may lead to less-explicit errors, but this is preferable to incorrect error reporting.

v1.1.0
------
* Add support for multidimensional IDEs (PR :pr:`35` resolves :issue:`28`, thanks `nbrucy <https://github.com/nbrucy>`_!)
Expand Down
12 changes: 9 additions & 3 deletions idesolver/idesolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __init__(
Defaults to :math:`k(x, s) = 1`.
f :
The function :math:`F(y)`.
Defaults to :math:`f(y) = 0`.
Defaults to :math:`F(y) = 0`.
lower_bound :
The lower bound function :math:`\\alpha(x)`.
Defaults to the first element of ``x``.
Expand Down Expand Up @@ -320,7 +320,7 @@ def solve(self, callback: Optional[Callable] = None) -> np.ndarray:
)
)
break
except (np.ComplexWarning, TypeError) as e:
except np.ComplexWarning as e:
raise exceptions.UnexpectedlyComplexValuedIDE(
"Detected complex-valued IDE. Make sure to pass y_0 as a complex number."
) from e
Expand Down Expand Up @@ -368,7 +368,13 @@ def _solve_rhs_with_known_y(self, y: np.ndarray) -> np.ndarray:

def integral(x):
def integrand(s):
return self.k(x, s) * self.f(interpolated_y(s))
k = self.k(x, s)
f = self.f(interpolated_y(s))

if k.size == 1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to replace k.size by k.ndim

return k * f
else:
return k @ f

result = []
for i in range(self.y_0.size):
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = idesolver
version = 1.1.0
version = 1.2.0
description = A general purpose iterative numeric integro-differential equation (IDE) solver
long_description = file: README.rst
long_description_content_type = text/x-rst
Expand Down
15 changes: 14 additions & 1 deletion tests/test_solver_against_analytic_solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,20 @@
upper_bound=lambda x: x,
),
lambda x: [np.sin(x), np.cos(x)],
)
),
( # equivalent to previous case, but with k(x, s) as a matrix instead of a scalar
IDESolver(
x=np.linspace(0, 7, 100),
y_0=[0, 1],
c=lambda x, y: [0.5 * (y[1] + 1), -0.5 * y[0]],
d=lambda x: -0.5,
k=lambda x, s: np.array([[1, 0], [0, 1]]),
f=lambda y: y,
lower_bound=lambda x: 0,
upper_bound=lambda x: x,
),
lambda x: [np.sin(x), np.cos(x)],
),
]


Expand Down