FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xtensor-python/test/test_sfinae.cpp at master · NKI-AI/xtensor-python · GitHub
NKI-AI
xtensor-python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
xtensor-python
/
test
/
test_sfinae.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (45 loc) · 1.87 KB
Breadcrumbs
xtensor-python
/
test
/
test_sfinae.cpp
Copy path
File metadata and controls
53 lines (45 loc) · 1.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
**************************************************************************
* Copyright (c) Wolf Vollprecht, Johan Mabille and Sylvain Corlay *
* Copyright (c) QuantStack *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
***************************************************************************
*/
#
include
<
limits
>
#
include
"
gtest/gtest.h
"
#
include
"
xtensor-python/pytensor.hpp
"
#
include
"
xtensor-python/pyarray.hpp
"
#
include
"
xtensor/xarray.hpp
"
#
include
"
xtensor/xtensor.hpp
"
namespace
xt
{
template
<
class
E
, std::
enable_if_t
<!xt::
has_fixed_rank_t
<E>::value,
int
> =
0
>
inline
bool
sfinae_has_fixed_rank
(E&&)
{
return
false
;
}
template
<
class
E
, std::
enable_if_t
<xt::
has_fixed_rank_t
<E>::value,
int
> =
0
>
inline
bool
sfinae_has_fixed_rank
(E&&)
{
return
true
;
}
TEST
(sfinae, fixed_rank)
{
xt::pyarray<
size_t
> a = {{
9
,
9
,
9
}, {
9
,
9
,
9
}};
xt::pytensor<
size_t
,
1
> b = {
9
,
9
};
xt::pytensor<
size_t
,
2
> c = {{
9
,
9
}, {
9
,
9
}};
EXPECT_TRUE
(
sfinae_has_fixed_rank
(a) ==
false
);
EXPECT_TRUE
(
sfinae_has_fixed_rank
(b) ==
true
);
EXPECT_TRUE
(
sfinae_has_fixed_rank
(c) ==
true
);
}
TEST
(sfinae, get_rank)
{
xt::pytensor<
double
,
1
> A = xt::zeros<
double
>({
2
});
xt::pytensor<
double
,
2
> B = xt::zeros<
double
>({
2
,
2
});
xt::pyarray<
double
> C = xt::zeros<
double
>({
2
,
2
});
EXPECT_TRUE
(xt::get_rank<
decltype
(A)>::value ==
1ul
);
EXPECT_TRUE
(xt::get_rank<
decltype
(B)>::value ==
2ul
);
EXPECT_TRUE
(xt::get_rank<
decltype
(C)>::value ==
SIZE_MAX
);
}
}
Back
|
FazBrowse Home
|
New Git URL