Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty datacube calculation #530

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/dataframe/old/datatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ SeriesIndex::SeriesIndex(std::string const &str,

DataCube::iterator_t DataCube::begin() const
{
if (df->get_record_count() == 0) return {};
if (!has_element) return {};
iterator_t res{this,
{},
{{}, std::vector<std::size_t>(dim_reindex.size())}};
Expand Down Expand Up @@ -201,13 +201,14 @@ DataCube::DataCube(const DataTable &table,
}

df->finalize();
has_element = true;
for (std::size_t ix{}; const auto &dim : dimensions) {
auto &&dimName = dim.getColIndex();
auto &&cats = table.getDf().get_categories(dimName);
dim_reindex.push_back(DimensionInfo{dimName,
cats,
cats.size() + df->has_na(dimName),
ix++});
auto &&size = cats.size() + df->has_na(dimName);
dim_reindex.push_back(
DimensionInfo{dimName, cats, size, ix++});
has_element &= size > 0;
}

auto stackInhibitingShape =
Expand Down
1 change: 1 addition & 0 deletions src/dataframe/old/datatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class DataCube
}
};
Type::UniqueList<DimensionInfo> dim_reindex;
bool has_element{};

std::map<Gen::ChannelId,
std::shared_ptr<dataframe::dataframe_interface>>
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/tests/fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"450": {
"refs": ["761380e"]
},
"530": {
"refs": ["1ad4684"]
},
"32303048": {
"refs": ["b5d95ea"]
},
Expand Down
44 changes: 44 additions & 0 deletions test/e2e/tests/fixes/530.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const testSteps = [
(chart) =>
chart.animate({
data: {
series: [
{
name: 'Year',
type: 'dimension',
values: ['2005', 'Total']
},
{
name: 'Result',
type: 'dimension',
values: ['Won', 'Lost']
}
]
}
}),
(chart) =>
chart.animate({
data: {
filter: (record) => {
return record.Year !== 'Total'
}
},
config: {
x: 'Year'
}
}),

(chart) =>
chart.animate({
data: {
filter: (record) => {
return record.Year === 'Total'
}
},
config: {
y: 'Result'
}
})
]

export default testSteps