FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
xtensor/test/test_xcsv.cpp at stable · xtensor-stack/xtensor · GitHub
xtensor-stack
xtensor
Repository navigation
Code
Issues
381
(381)
Pull requests
44
(44)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
xtensor
/
test
/
test_xcsv.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
69 lines (53 loc) · 1.94 KB
Breadcrumbs
xtensor
/
test
/
test_xcsv.cpp
Copy path
File metadata and controls
69 lines (53 loc) · 1.94 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
**************************************************************************
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
* 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
"
gtest/gtest.h
"
#
include
<
sstream
>
#
include
<
iostream
>
#
include
"
xtensor/xcsv.hpp
"
#
include
"
xtensor/xmath.hpp
"
#
include
"
xtensor/xio.hpp
"
namespace
xt
{
TEST
(xcsv, load_double)
{
std::string source =
"
1.0, 2.0, 3.0, 4.0
\n
"
"
10.0, 12.0, 15.0, 18.0
"
;
std::stringstream
source_stream
(source);
xtensor<
double
,
2
> res = load_csv<
double
>(source_stream);
xtensor<
double
,
2
> exp
{{
1.0
,
2.0
,
3.0
,
4.0
},
{
10.0
,
12.0
,
15.0
,
18.0
}};
ASSERT_TRUE
(
all
(
equal
(res, exp)));
}
TEST
(xcsv, load_double_with_options)
{
std::string source =
"
A B C D
\n
"
"
#0.0 1.0 1.1 1.2
\n
"
"
1.0 2.0 3.0 4.0
\n
"
"
10.0 12.0 15.0 18.0
\n
"
"
9.0, 8.0, 7.0, 6.
"
;
std::stringstream
source_stream
(source);
auto
res = load_csv<
double
>(source_stream,
'
'
,
1
,
2
,
"
#
"
);
xtensor<
double
,
2
> exp
{{
1.0
,
2.0
,
3.0
,
4.0
},
{
10.0
,
12.0
,
15.0
,
18.0
}};
ASSERT_TRUE
(
all
(
equal
(res, exp)));
}
TEST
(xcsv, dump_double)
{
xtensor<
double
,
2
> data
{{
1.0
,
2.0
,
3.0
,
4.0
},
{
10.0
,
12.0
,
15.0
,
18.0
}};
std::stringstream res;
dump_csv
(res, data);
ASSERT_EQ
(
"
1,2,3,4
\n
10,12,15,18
\n
"
, res.
str
());
}
}
Back
|
FazBrowse Home
|
New Git URL