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

Computed Columns should write to only filtered rows #5709

Merged
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
16 changes: 15 additions & 1 deletion CommonData/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,21 @@ bool Column::overwriteDataAndType(stringvec data, columnType colType)
JASPTIMER_SCOPE(Column::overwriteDataAndType);

if(data.size() != _data->rowCount())
data.resize(_data->rowCount());
{
if(data.size() == _data->filter()->filteredRowCount())
{
const boolvec & filtered = _data->filter()->filtered();
stringvec newData;
newData . reserve(filtered.size());

for(size_t iFilter=0, iData=0; iFilter < filtered.size() && iData < data.size(); iFilter++)
newData.push_back(filtered[iFilter] ? data[iData++] : "");

data = newData;
}
else
data.resize(_data->rowCount());
}

bool changes = _type != colType;
setValues(data, data, 0, &changes);
Expand Down
2 changes: 1 addition & 1 deletion Desktop/engine/enginerepresentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void EngineRepresentation::runScriptOnProcess(RFilterStore * filterStore)

_lastRequestId = filterStore->requestId;

QString dataFilter = filterStore->script == "" ? "*" : filterStore->script;
QString dataFilter = filterStore->script == "" ? "generatedFilter" : filterStore->script;
json["filter"] = dataFilter.toStdString();

Log::log() << "sending filter with requestID " << filterStore->requestId << " to engine" << std::endl;
Expand Down
3 changes: 1 addition & 2 deletions R-Interface/jasprcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,7 @@ bool _jaspRCPP_setColumnDataAndType(const std::string & columnName, Rcpp::RObjec
for(size_t i=0; i<convertedStrings.size(); i++)
{
bool isNA = convertedStrings[i] == "NA",
isLgl = convertedStrings[i] == "TRUE" || convertedStrings[i] == "FALSE",
isNan = std::isnan(dblData[i]);
isLgl = convertedStrings[i] == "TRUE" || convertedStrings[i] == "FALSE";

nominals[i] = std::isnan(dblData[i]) // If the string could not be converted to a number its not TRUE or FALSE, but it might be NA. We do not want that as a result!
? (!isNA ? convertedStrings[i].c_str() : "")
Expand Down
Loading