mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #23705 from asmorkalov:as/cxx-named-arguments
Re-implement named parameters bindings for Python #23705 Reverted named argument handling from #19156. Ported new solution from #23224 The port is required to harmonize 4.x -> 5.x merges. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
67a3d35b4e
commit
d24ffe9a65
@@ -738,6 +738,29 @@ class Arguments(NewOpenCVTests):
|
||||
)
|
||||
)
|
||||
|
||||
def test_named_arguments_without_parameters(self):
|
||||
src = np.ones((5, 5, 3), dtype=np.uint8)
|
||||
arguments_dump, src_copy = cv.utils.copyMatAndDumpNamedArguments(src)
|
||||
np.testing.assert_equal(src, src_copy)
|
||||
self.assertEqual(arguments_dump, 'lambda=-1, sigma=0.0')
|
||||
|
||||
def test_named_arguments_without_output_argument(self):
|
||||
src = np.zeros((2, 2, 3), dtype=np.uint8)
|
||||
arguments_dump, src_copy = cv.utils.copyMatAndDumpNamedArguments(
|
||||
src, lambda_=15, sigma=3.5
|
||||
)
|
||||
np.testing.assert_equal(src, src_copy)
|
||||
self.assertEqual(arguments_dump, 'lambda=15, sigma=3.5')
|
||||
|
||||
def test_named_arguments_with_output_argument(self):
|
||||
src = np.zeros((3, 3, 3), dtype=np.uint8)
|
||||
dst = np.ones_like(src)
|
||||
arguments_dump, src_copy = cv.utils.copyMatAndDumpNamedArguments(
|
||||
src, dst, lambda_=25, sigma=5.5
|
||||
)
|
||||
np.testing.assert_equal(src, src_copy)
|
||||
np.testing.assert_equal(dst, src_copy)
|
||||
self.assertEqual(arguments_dump, 'lambda=25, sigma=5.5')
|
||||
|
||||
|
||||
class CanUsePurePythonModuleFunction(NewOpenCVTests):
|
||||
|
||||
Reference in New Issue
Block a user