Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
texodus committed Apr 13, 2019
1 parent 24b0c24 commit d1aed40
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cpp/perspective/src/cpp/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,8 @@ View<t_ctx2>::get_data(
row_path.set("__ROW_PATH__");
cols.insert(cols.begin(), std::vector<t_tscalar>{row_path});
auto slice_ptr = std::make_shared<std::vector<t_tscalar>>(slice);
auto data_slice_ptr
= std::make_shared<t_data_slice<t_ctx2>>(m_ctx, start_row, end_row, start_col, end_col,
m_row_offset, m_col_offset, slice_ptr, cols, column_indices);
auto data_slice_ptr = std::make_shared<t_data_slice<t_ctx2>>(m_ctx, start_row, end_row,
start_col, end_col, m_row_offset, m_col_offset, slice_ptr, cols, column_indices);
return data_slice_ptr;
}

Expand Down
24 changes: 24 additions & 0 deletions packages/perspective/test/js/pivots.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ var data_7 = {
z: [true, false, true, false]
};

var data_8 = {
w: [1.5, 2.5, 3.5, 4.5],
x: [1, 2, 3, 4],
y: ["a", "b", "c", "d"],
z: [new Date(1555126035065), new Date(1555126035065), new Date(1555026035065), new Date(1555026035065)]
};

module.exports = perspective => {
describe("Aggregate", function() {
it("['z'], sum", async function() {
Expand Down Expand Up @@ -516,6 +523,23 @@ module.exports = perspective => {
table.delete();
});

it("['z'] only, datetime column", async function() {
var table = perspective.table(data_8);
var view = table.view({
column_pivots: ["z"],
columns: ["x", "y"]
});
let result2 = await view.to_columns();
expect(result2).toEqual({
"2019-4-11 23:40:35|x": [null, null, 3, 4],
"2019-4-11 23:40:35|y": [null, null, "c", "d"],
"2019-4-13 03:27:15|x": [1, 2, null, null],
"2019-4-13 03:27:15|y": ["a", "b", null, null]
});
view.delete();
table.delete();
});

it("['x'] only, column-oriented input", async function() {
var table = perspective.table(data_7);
var view = table.view({
Expand Down

0 comments on commit d1aed40

Please sign in to comment.