Skip to content

Commit

Permalink
use FExpr_FuncUnary for isna
Browse files Browse the repository at this point in the history
  • Loading branch information
samukweku committed Mar 29, 2023
1 parent 9b92676 commit db169c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 67 deletions.
47 changes: 21 additions & 26 deletions src/core/expr/funary/fexpr_isna.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//------------------------------------------------------------------------------
// Copyright 2023 H2O.ai
// Copyright 2022-2023 H2O.ai
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
Expand All @@ -19,42 +19,37 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//------------------------------------------------------------------------------
#include "expr/funary/fexpr_isna.h"
#include "column/const.h"
#include "column/isna.h"
#include "expr/fexpr_column.h"
#include "documentation.h"
#include "expr/fexpr_func_unary.h"
#include "expr/eval_context.h"
#include "expr/fexpr_column.h"
#include "expr/workframe.h"
#include "python/xargs.h"
#include "stype.h"
namespace dt {
namespace expr {

FExpr_ISNA::FExpr_ISNA(ptrExpr &&arg)
: arg_(std::move(arg))
{}

std::string FExpr_ISNA::repr() const {
std::string out = "isna";
out += '(';
out += arg_->repr();
out += ')';
return out;
}
class FExpr_ISNA : public FExpr_FuncUnary {
public:
using FExpr_FuncUnary::FExpr_FuncUnary;

Workframe FExpr_ISNA::evaluate_n(EvalContext &ctx) const {
Workframe wf = arg_->evaluate_n(ctx);

for (size_t i = 0; i < wf.ncols(); ++i) {
Column coli = wf.retrieve_column(i);
bool is_void_column = coli.stype() == SType::VOID;
coli = is_void_column? Const_ColumnImpl::make_bool_column(coli.nrows(), true)
: Column(new Isna_ColumnImpl(std::move(coli)));
wf.replace_column(i, std::move(coli));
}
std::string name() const override {
return "isna";
}


Column evaluate1(Column&& col) const override{
bool is_void_column = col.stype() == SType::VOID;
col = is_void_column? Const_ColumnImpl::make_bool_column(col.nrows(), true)
: Column(new Isna_ColumnImpl(std::move(col)));
return std::move(col);
}
};

return wf;
}

static py::oobj pyfn_isna(const py::XArgs &args) {
auto isna = args[0].to_oobj();
Expand All @@ -68,5 +63,5 @@ DECLARE_PYFN(&pyfn_isna)
->n_positional_args(1)
->n_required_args(1);

} // namespace expr
} // namespace dt

}} // dt::expr
41 changes: 0 additions & 41 deletions src/core/expr/funary/fexpr_isna.h

This file was deleted.

0 comments on commit db169c2

Please sign in to comment.