Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
ee4b9f5d
Unverified
Commit
ee4b9f5d
authored
Dec 20, 2022
by
Ethan Steinberg
Committed by
GitHub
Dec 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ODR violations in our Eigen Tensor tests (#4412)
* First * Fix centos 7 again :( * Fix minor nits
parent
a97c4d22
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
26 deletions
+19
-26
tests/CMakeLists.txt
+5
-10
tests/eigen_tensor_avoid_stl_array.cpp
+2
-4
tests/test_eigen_tensor.cpp
+4
-2
tests/test_eigen_tensor.inl
+4
-6
tests/test_eigen_tensor.py
+4
-4
No files found.
tests/CMakeLists.txt
View file @
ee4b9f5d
...
@@ -130,7 +130,6 @@ set(PYBIND11_TEST_FILES
...
@@ -130,7 +130,6 @@ set(PYBIND11_TEST_FILES
test_docstring_options
test_docstring_options
test_eigen_matrix
test_eigen_matrix
test_eigen_tensor
test_eigen_tensor
test_eigen_tensor_avoid_stl_array.cpp
test_enum
test_enum
test_eval
test_eval
test_exceptions
test_exceptions
...
@@ -293,6 +292,11 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
...
@@ -293,6 +292,11 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
set
(
EIGEN3_VERSION
${
EIGEN3_VERSION_STRING
}
)
set
(
EIGEN3_VERSION
${
EIGEN3_VERSION_STRING
}
)
endif
()
endif
()
message
(
STATUS
"Building tests with Eigen v
${
EIGEN3_VERSION
}
"
)
message
(
STATUS
"Building tests with Eigen v
${
EIGEN3_VERSION
}
"
)
if
(
NOT
(
CMAKE_CXX_COMPILER_ID STREQUAL
"GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0
))
tests_extra_targets
(
"test_eigen_tensor.py"
"eigen_tensor_avoid_stl_array"
)
endif
()
else
()
else
()
list
(
FIND PYBIND11_TEST_FILES test_eigen_matrix.cpp PYBIND11_TEST_FILES_EIGEN_I
)
list
(
FIND PYBIND11_TEST_FILES test_eigen_matrix.cpp PYBIND11_TEST_FILES_EIGEN_I
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
...
@@ -303,11 +307,6 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
...
@@ -303,11 +307,6 @@ if(PYBIND11_TEST_FILES_EIGEN_I GREATER -1)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
endif
()
endif
()
list
(
FIND PYBIND11_TEST_FILES test_eigen_tensor_avoid_stl_array.cpp
PYBIND11_TEST_FILES_EIGEN_I
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
endif
()
message
(
message
(
STATUS
"Building tests WITHOUT Eigen, use -DDOWNLOAD_EIGEN=ON on CMake 3.11+ to download"
)
STATUS
"Building tests WITHOUT Eigen, use -DDOWNLOAD_EIGEN=ON on CMake 3.11+ to download"
)
endif
()
endif
()
...
@@ -319,10 +318,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_L
...
@@ -319,10 +318,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_L
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
endif
()
endif
()
list
(
FIND PYBIND11_TEST_FILES test_eigen_tensor_avoid_stl_array.cpp PYBIND11_TEST_FILES_EIGEN_I
)
if
(
PYBIND11_TEST_FILES_EIGEN_I GREATER -1
)
list
(
REMOVE_AT PYBIND11_TEST_FILES
${
PYBIND11_TEST_FILES_EIGEN_I
}
)
endif
()
endif
()
endif
()
# Optional dependency for some tests (boost::variant is only supported with version >= 1.56)
# Optional dependency for some tests (boost::variant is only supported with version >= 1.56)
...
...
tests/
test_
eigen_tensor_avoid_stl_array.cpp
→
tests/eigen_tensor_avoid_stl_array.cpp
View file @
ee4b9f5d
...
@@ -5,12 +5,10 @@
...
@@ -5,12 +5,10 @@
BSD-style license that can be found in the LICENSE file.
BSD-style license that can be found in the LICENSE file.
*/
*/
constexpr
const
char
*
test_eigen_tensor_module_name
=
"eigen_tensor_avoid_stl_array"
;
#ifndef EIGEN_AVOID_STL_ARRAY
#ifndef EIGEN_AVOID_STL_ARRAY
# define EIGEN_AVOID_STL_ARRAY
# define EIGEN_AVOID_STL_ARRAY
#endif
#endif
#define PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE eigen_tensor_avoid_stl_array
#include "test_eigen_tensor.inl"
#include "test_eigen_tensor.inl"
PYBIND11_MODULE
(
eigen_tensor_avoid_stl_array
,
m
)
{
eigen_tensor_test
::
test_module
(
m
);
}
tests/test_eigen_tensor.cpp
View file @
ee4b9f5d
...
@@ -5,8 +5,6 @@
...
@@ -5,8 +5,6 @@
BSD-style license that can be found in the LICENSE file.
BSD-style license that can be found in the LICENSE file.
*/
*/
constexpr
const
char
*
test_eigen_tensor_module_name
=
"eigen_tensor"
;
#define PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE eigen_tensor
#define PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE eigen_tensor
#ifdef EIGEN_AVOID_STL_ARRAY
#ifdef EIGEN_AVOID_STL_ARRAY
...
@@ -14,3 +12,7 @@ constexpr const char *test_eigen_tensor_module_name = "eigen_tensor";
...
@@ -14,3 +12,7 @@ constexpr const char *test_eigen_tensor_module_name = "eigen_tensor";
#endif
#endif
#include "test_eigen_tensor.inl"
#include "test_eigen_tensor.inl"
#include "pybind11_tests.h"
test_initializer
egien_tensor
(
"eigen_tensor"
,
eigen_tensor_test
::
test_module
);
tests/test_eigen_tensor.inl
View file @
ee4b9f5d
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
#include <pybind11/eigen/tensor.h>
#include <pybind11/eigen/tensor.h>
#include "pybind11_tests.h"
PYBIND11_NAMESPACE_BEGIN(eigen_tensor_test)
PYBIND11_NAMESPACE_BEGIN(PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE)
namespace py = pybind11;
PYBIND11_WARNING_DISABLE_MSVC(4127)
PYBIND11_WARNING_DISABLE_MSVC(4127)
...
@@ -108,7 +108,7 @@ void init_tensor_module(pybind11::module &m) {
...
@@ -108,7 +108,7 @@ void init_tensor_module(pybind11::module &m) {
return check_tensor(get_tensor<Options>()) && check_tensor(get_fixed_tensor<Options>());
return check_tensor(get_tensor<Options>()) && check_tensor(get_fixed_tensor<Options>());
});
});
py::class_<CustomExample<Options>>(m, "CustomExample")
py::class_<CustomExample<Options>>(m, "CustomExample"
, py::module_local()
)
.def(py::init<>())
.def(py::init<>())
.def_readonly(
.def_readonly(
"member", &CustomExample<Options>::member, py::return_value_policy::reference_internal)
"member", &CustomExample<Options>::member, py::return_value_policy::reference_internal)
...
@@ -322,8 +322,6 @@ void init_tensor_module(pybind11::module &m) {
...
@@ -322,8 +322,6 @@ void init_tensor_module(pybind11::module &m) {
py::return_value_policy::reference);
py::return_value_policy::reference);
}
}
void test_module(py::module_ &);
test_initializer name(test_eigen_tensor_module_name, test_module);
void test_module(py::module_ &m) {
void test_module(py::module_ &m) {
auto f_style = m.def_submodule("f_style");
auto f_style = m.def_submodule("f_style");
auto c_style = m.def_submodule("c_style");
auto c_style = m.def_submodule("c_style");
...
@@ -332,4 +330,4 @@ void test_module(py::module_ &m) {
...
@@ -332,4 +330,4 @@ void test_module(py::module_ &m) {
init_tensor_module<Eigen::RowMajor>(c_style);
init_tensor_module<Eigen::RowMajor>(c_style);
}
}
PYBIND11_NAMESPACE_END(
PYBIND11_TEST_EIGEN_TENSOR_NAMESPACE
)
PYBIND11_NAMESPACE_END(
eigen_tensor_test
)
tests/test_eigen_tensor.py
View file @
ee4b9f5d
...
@@ -6,17 +6,17 @@ np = pytest.importorskip("numpy")
...
@@ -6,17 +6,17 @@ np = pytest.importorskip("numpy")
eigen_tensor
=
pytest
.
importorskip
(
"pybind11_tests.eigen_tensor"
)
eigen_tensor
=
pytest
.
importorskip
(
"pybind11_tests.eigen_tensor"
)
submodules
=
[
eigen_tensor
.
c_style
,
eigen_tensor
.
f_style
]
submodules
=
[
eigen_tensor
.
c_style
,
eigen_tensor
.
f_style
]
try
:
try
:
from
pybind11_tests
import
eigen_tensor_avoid_stl_array
as
avoid
import
eigen_tensor_avoid_stl_array
as
avoid
submodules
+=
[
avoid
.
c_style
,
avoid
.
f_style
]
submodules
+=
[
avoid
.
c_style
,
avoid
.
f_style
]
except
ImportError
as
e
:
except
ImportError
as
e
:
# Ensure config, build, toolchain, etc. issues are not masked here:
# Ensure config, build, toolchain, etc. issues are not masked here:
raise
RuntimeError
(
raise
RuntimeError
(
"import
pybind11_tests.
eigen_tensor_avoid_stl_array FAILED, while "
"import eigen_tensor_avoid_stl_array FAILED, while "
"import pybind11_tests.eigen_tensor succeeded. "
"import pybind11_tests.eigen_tensor succeeded. "
"Please ensure that "
"Please ensure that "
"test_eigen_tensor.cpp & "
"test_eigen_tensor.cpp & "
"
test_
eigen_tensor_avoid_stl_array.cpp "
"eigen_tensor_avoid_stl_array.cpp "
"are built together (or both are not built if Eigen is not available)."
"are built together (or both are not built if Eigen is not available)."
)
from
e
)
from
e
...
@@ -42,7 +42,7 @@ def cleanup():
...
@@ -42,7 +42,7 @@ def cleanup():
def
test_import_avoid_stl_array
():
def
test_import_avoid_stl_array
():
pytest
.
importorskip
(
"
pybind11_tests.
eigen_tensor_avoid_stl_array"
)
pytest
.
importorskip
(
"eigen_tensor_avoid_stl_array"
)
assert
len
(
submodules
)
==
4
assert
len
(
submodules
)
==
4
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment