LCOV - code coverage report
Current view: top level - src/pairinteraction/green_tensor - bessel_function.py (source / functions) Hit Total Coverage
Test: coverage.info Lines: 12 12 100.0 %
Date: 2026-04-30 10:43:26 Functions: 3 4 75.0 %

          Line data    Source code
       1             : # SPDX-FileCopyrightText: 2025 PairInteraction Developers
       2             : # SPDX-License-Identifier: LGPL-3.0-or-later
       3             : 
       4           1 : from functools import lru_cache
       5           1 : from typing import TYPE_CHECKING
       6             : 
       7             : if TYPE_CHECKING:
       8             : 
       9             :     def scipy_bessel_function(v: int, z: complex) -> complex: ...
      10             : else:
      11           1 :     from scipy.special import jv as scipy_bessel_function
      12             : 
      13             : 
      14           1 : @lru_cache(maxsize=100_000)
      15           1 : def cached_bessel_function_0(z: complex) -> complex:
      16           1 :     return scipy_bessel_function(0, z)
      17             : 
      18             : 
      19           1 : @lru_cache(maxsize=100_000)
      20           1 : def cached_bessel_function_1(z: complex) -> complex:
      21           1 :     return scipy_bessel_function(1, z)
      22             : 
      23             : 
      24           1 : @lru_cache(maxsize=100_000)
      25           1 : def cached_bessel_function_2(z: complex) -> complex:
      26           1 :     return scipy_bessel_function(2, z)
      27             :     # for even a bit more speedup:
      28             :     # return (2.0 / z) * cached_bessel_function_1(z) - cached_bessel_function_0(z)  # noqa: ERA001

Generated by: LCOV version 1.16