Skip to content

Commit fe65998

Browse files
committed
restrict inverse to bool and int columns
1 parent 653ae11 commit fe65998

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

src/core/expr/funary/uinvert.cc

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -56,44 +56,32 @@ class FExpr_UInvert : public FExpr_FuncUnary {
5656
Column col_out;
5757

5858
switch (stype) {
59-
case SType::VOID: return Column(new ConstNa_ColumnImpl(
60-
col.nrows(), SType::VOID
61-
));
59+
case SType::VOID:
60+
return Column(new ConstNa_ColumnImpl(col.nrows(), SType::VOID));
6261
case SType::BOOL:
63-
col_out = Column(new FuncUnary1_ColumnImpl<int8_t, int8_t>(
64-
std::move(col), op_invert_bool, col.nrows(), SType::BOOL
65-
));
66-
break;
62+
return Column(new FuncUnary1_ColumnImpl<int8_t, int8_t>(
63+
std::move(col), op_invert_bool, col.nrows(), SType::BOOL
64+
));
6765
case SType::INT8:
68-
col_out = Column(new FuncUnary1_ColumnImpl<int8_t, int8_t>(
69-
std::move(col), op_invert<int8_t>, col.nrows(), SType::INT8
70-
));
71-
break;
66+
return Column(new FuncUnary1_ColumnImpl<int8_t, int8_t>(
67+
std::move(col), op_invert<int8_t>, col.nrows(), SType::INT8
68+
));
7269
case SType::INT16:
73-
col_out = Column(new FuncUnary1_ColumnImpl<int16_t, int16_t>(
74-
std::move(col), op_invert<int16_t>, col.nrows(), SType::INT16
75-
));
76-
break;
70+
return Column(new FuncUnary1_ColumnImpl<int16_t, int16_t>(
71+
std::move(col), op_invert<int16_t>, col.nrows(), SType::INT16
72+
));
7773
case SType::INT32:
78-
case SType::DATE32:
79-
col_out = Column(new FuncUnary1_ColumnImpl<int32_t, int32_t>(
80-
std::move(col), op_invert<int32_t>, col.nrows(), SType::INT32
81-
));
82-
break;
74+
return Column(new FuncUnary1_ColumnImpl<int32_t, int32_t>(
75+
std::move(col), op_invert<int32_t>, col.nrows(), SType::INT32
76+
));
8377
case SType::INT64:
84-
case SType::TIME64:
85-
col_out = Column(new FuncUnary1_ColumnImpl<int64_t, int64_t>(
86-
std::move(col), op_invert<int64_t>, col.nrows(), SType::INT64
87-
));
88-
break;;
78+
return Column(new FuncUnary1_ColumnImpl<int64_t, int64_t>(
79+
std::move(col), op_invert<int64_t>, col.nrows(), SType::INT64
80+
));
8981
default:
9082
throw TypeError() << "Cannot apply unary `operator ~` to a column with "
9183
"stype `" << stype << "`";
9284
}
93-
if (stype == SType::DATE32 || stype == SType::TIME64) {
94-
col_out.cast_inplace(stype);
95-
}
96-
return col_out;
9785
}
9886
};
9987

0 commit comments

Comments
 (0)