Skip to content

Commit dfa3264

Browse files
committed
acb_theta: add type stubs
1 parent b8e95bb commit dfa3264

5 files changed

Lines changed: 64 additions & 2 deletions

File tree

src/flint/test/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pyfiles = [
99
'test_acb_mat.py',
1010
'test_acb_poly.py',
1111
'test_acb_series.py',
12+
'test_acb_theta.py',
1213
'test_arb.py',
1314
'test_arb_mat.py',
1415
'test_arb_series.py',

src/flint/test/test_acb_theta.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from __future__ import annotations
2+
3+
from flint import acb, acb_mat
4+
from flint.test.helpers import is_close_acb_mat as is_close, raises
5+
6+
7+
def _acb_theta_importable() -> bool:
8+
try:
9+
from flint.types.acb_theta import acb_theta as _ # noqa: F401
10+
return True
11+
except ImportError:
12+
return False
13+
14+
15+
def test_acb_theta_basic() -> None:
16+
if not _acb_theta_importable():
17+
return
18+
19+
from flint.types.acb_theta import acb_theta
20+
21+
z = acb(1 + 1j)
22+
tau = acb(1.25 + 3j)
23+
zmat = acb_mat([[z]])
24+
taumat = acb_mat([[tau]])
25+
26+
direct = acb_theta(zmat, taumat)
27+
via_method = taumat.theta(zmat)
28+
assert is_close(direct, via_method, tol=1e-12, rel_tol=1e-12, max_width=1e-12)
29+
assert direct.nrows() == 1
30+
assert direct.ncols() == 4
31+
32+
squared = acb_theta(zmat, taumat, square=True)
33+
assert squared.nrows() == 1
34+
assert squared.ncols() == 4
35+
36+
37+
def test_acb_theta_shape_assertions() -> None:
38+
if not _acb_theta_importable():
39+
return
40+
41+
from flint.types.acb_theta import acb_theta
42+
43+
z = acb_mat([[0]])
44+
tau_bad = acb_mat([[1j, 0]])
45+
assert raises(lambda: acb_theta(z, tau_bad), AssertionError)
46+
47+
tau = acb_mat([[1j]])
48+
z_bad_rows = acb_mat([[0], [0]])
49+
assert raises(lambda: acb_theta(z_bad_rows, tau), AssertionError)
50+
51+
z_bad_cols = acb_mat([[0, 0]])
52+
assert raises(lambda: acb_theta(z_bad_cols, tau), AssertionError)
53+
54+
assert raises(lambda: acb_theta(object(), tau), TypeError) # type: ignore[arg-type]
55+
assert raises(lambda: acb_theta(z, object()), TypeError) # type: ignore[arg-type]

src/flint/types/acb_mat.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ class acb_mat(flint_mat[acb]):
9595
nonstop: bool = False,
9696
) -> Any: ...
9797

98-
@staticmethod
99-
def theta(tau: acb_mat, z: object, square: bool = False) -> Any: ...
98+
def theta(self, z: acb_mat, square: bool = False) -> acb_mat: ...
10099

101100
def str(self, n: int = 0, radius: bool = True, more: bool = False, condense: int = 0) -> _str: ...
102101
def repr(self) -> _str: ...

src/flint/types/acb_theta.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from __future__ import annotations
2+
3+
from flint.types.acb_mat import acb_mat
4+
5+
6+
def acb_theta(z: acb_mat, tau: acb_mat, square: bool | int = False) -> acb_mat: ...

src/flint/types/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pyfiles = [
4141
#
4242
'acb_poly.pyi',
4343
'acb_mat.pyi',
44+
'acb_theta.pyi',
4445
'acb_series.pyi',
4546
#
4647
'dirichlet.pyi',

0 commit comments

Comments
 (0)