增加环绕侦察场景适配

This commit is contained in:
2026-01-08 15:44:38 +08:00
parent 3eba1f962b
commit 10c5bb5a8a
5441 changed files with 40219 additions and 379695 deletions

View File

@@ -1,8 +1,9 @@
"""Test deprecation and future warnings.
"""
import pytest
import numpy as np
from numpy.testing import assert_warns
def test_qr_mode_full_future_warning():
@@ -14,7 +15,7 @@ def test_qr_mode_full_future_warning():
"""
a = np.eye(2)
assert_warns(DeprecationWarning, np.linalg.qr, a, mode='full')
assert_warns(DeprecationWarning, np.linalg.qr, a, mode='f')
assert_warns(DeprecationWarning, np.linalg.qr, a, mode='economic')
assert_warns(DeprecationWarning, np.linalg.qr, a, mode='e')
pytest.warns(DeprecationWarning, np.linalg.qr, a, mode='full')
pytest.warns(DeprecationWarning, np.linalg.qr, a, mode='f')
pytest.warns(DeprecationWarning, np.linalg.qr, a, mode='economic')
pytest.warns(DeprecationWarning, np.linalg.qr, a, mode='e')

View File

@@ -8,6 +8,7 @@ import sys
import textwrap
import threading
import traceback
import warnings
import pytest
@@ -42,7 +43,6 @@ from numpy.testing import (
assert_equal,
assert_raises,
assert_raises_regex,
suppress_warnings,
)
try:
@@ -1331,8 +1331,9 @@ class _TestNormGeneral(_TestNormBase):
self.check_dtype(at, an)
assert_almost_equal(an, 0.0)
with suppress_warnings() as sup:
sup.filter(RuntimeWarning, "divide by zero encountered")
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore', "divide by zero encountered", RuntimeWarning)
an = norm(at, -1)
self.check_dtype(at, an)
assert_almost_equal(an, 0.0)
@@ -1494,8 +1495,9 @@ class _TestNorm2D(_TestNormBase):
self.check_dtype(at, an)
assert_almost_equal(an, 2.0)
with suppress_warnings() as sup:
sup.filter(RuntimeWarning, "divide by zero encountered")
with warnings.catch_warnings():
warnings.filterwarnings(
'ignore', "divide by zero encountered", RuntimeWarning)
an = norm(at, -1)
self.check_dtype(at, an)
assert_almost_equal(an, 1.0)
@@ -2216,8 +2218,7 @@ class TestTensorinv:
((24, 8, 3), 1),
])
def test_tensorinv_shape(self, shape, ind):
a = np.eye(24)
a.shape = shape
a = np.eye(24).reshape(shape)
ainv = linalg.tensorinv(a=a, ind=ind)
expected = a.shape[ind:] + a.shape[:ind]
actual = ainv.shape
@@ -2227,15 +2228,13 @@ class TestTensorinv:
0, -2,
])
def test_tensorinv_ind_limit(self, ind):
a = np.eye(24)
a.shape = (4, 6, 8, 3)
a = np.eye(24).reshape((4, 6, 8, 3))
with assert_raises(ValueError):
linalg.tensorinv(a=a, ind=ind)
def test_tensorinv_result(self):
# mimic a docstring example
a = np.eye(24)
a.shape = (24, 8, 3)
a = np.eye(24).reshape((24, 8, 3))
ainv = linalg.tensorinv(a, ind=1)
b = np.ones(24)
assert_allclose(np.tensordot(ainv, b, 1), np.linalg.tensorsolve(a, b))

View File

@@ -33,7 +33,7 @@ class TestRegression:
1.51971555e-15 + 0.j,
-1.51308713e-15 + 0.j])
a = arange(13 * 13, dtype=float64)
a.shape = (13, 13)
a = a.reshape((13, 13))
a = a % 17
va, ve = linalg.eig(a)
va.sort()
@@ -165,6 +165,7 @@ class TestRegression:
res = np.linalg.matrix_rank(x, rtol=rtol)
assert res.shape == (4,)
@pytest.mark.thread_unsafe(reason="test is already testing threads with openblas")
def test_openblas_threading(self):
# gh-27036
# Test whether matrix multiplication involving a large matrix always