Skip to content

Deprecate DT(rows=, select=, ...) #1579

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

Merged
merged 15 commits into from
Jan 22, 2019
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
deprecated, they will be removed in 0.9.0. Please use `.to_list()`,
`.to_pandas()` and `.to_numpy()` instead.

- Calling a frame object `DT(rows=i, select=j, groupby=g, join=z, sort=s)` is
now deprecated. Use the expression `DT[i, j, by(g), join(z), sort(s)]`
instead, where symbols `by()`, `join()` and `sort()` can all be imported
from the `datatable` namespace (#1579).


### Removed

Expand Down
8 changes: 0 additions & 8 deletions c/datatablemodule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ extern void init_jay();

namespace py {
PyObject* fread_fn = nullptr;
PyObject* fallback_makedatatable = nullptr;
}


Expand Down Expand Up @@ -106,7 +105,6 @@ PyObject* register_function(PyObject*, PyObject *args) {
else if (n == 6) replace_dtWarning(fnref);
else if (n == 7) py::Frame_Type = fnref;
else if (n == 8) py::fread_fn = fnref;
else if (n == 9) py::fallback_makedatatable = fnref;
else {
throw ValueError() << "Incorrect function index: " << n;
}
Expand Down Expand Up @@ -194,12 +192,6 @@ void DatatableModule::init_methods() {
add(METHODv(register_function));
add(METHOD0(get_internal_function_ptrs));
add(METHOD0(get_integer_sizes));
add(METHODv(expr_binaryop));
add(METHODv(expr_cast));
add(METHODv(expr_column));
add(METHODv(expr_reduceop));
add(METHODv(expr_count));
add(METHODv(expr_unaryop));
add(METHOD0(is_debug_mode));
add(METHOD0(has_omp_support));

Expand Down
2 changes: 1 addition & 1 deletion c/expr/base_expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void py::base_expr::Type::init_methods_and_getsets(


bool is_PyBaseExpr(const py::_obj& obj) {
static auto BaseExprType = py::oobj::import("datatable.graph", "BaseExpr");
static auto BaseExprType = py::oobj::import("datatable.expr", "BaseExpr");
return PyObject_IsInstance(obj.to_borrowed_ref(),
BaseExprType.to_borrowed_ref());
}
2 changes: 2 additions & 0 deletions c/expr/by_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//------------------------------------------------------------------------------
#include "expr/base_expr.h"
#include "expr/by_node.h"
#include "expr/collist.h"
#include "expr/py_expr.h"
#include "expr/workframe.h"
#include "python/arg.h"
#include "python/tuple.h"
#include "utils/exceptions.h"
Expand Down
5 changes: 4 additions & 1 deletion c/expr/collist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//------------------------------------------------------------------------------
#include "expr/base_expr.h"
#include "expr/collist.h"
#include "expr/workframe.h"
#include "utils/exceptions.h"
#include "datatable.h"

Expand Down Expand Up @@ -112,7 +114,7 @@ class collist_maker
_process_element(elem);
}
}
else {
else if (!src.is_none()) {
throw TypeError()
<< "Unsupported " << srcname << " of type " << src.typeobj();
}
Expand Down Expand Up @@ -170,6 +172,7 @@ class collist_maker
else if (elem.is_type()) _process_element_type(elem);
else if (elem.is_ltype()) _process_element_ltype(elem);
else if (elem.is_stype()) _process_element_stype(elem);
else if (elem.is_none()) return;
else {
throw TypeError()
<< "Element " << k << " in " << srcname << " list has type `"
Expand Down
8 changes: 5 additions & 3 deletions c/expr/collist.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@
//------------------------------------------------------------------------------
#ifndef dt_EXPR_COLLIST_h
#define dt_EXPR_COLLIST_h
#include <memory>
#include <string>
#include <vector>
#include "expr/base_expr.h"
#include "expr/workframe.h"
#include "python/obj.h"

namespace dt {
class collist;
class base_expr;
class workframe;


using strvec = std::vector<std::string>;
using exprvec = std::vector<std::unique_ptr<dt::base_expr>>;
using intvec = std::vector<size_t>;
using collist_ptr = std::unique_ptr<collist>;
Expand Down
136 changes: 0 additions & 136 deletions c/expr/py_expr.cc

This file was deleted.

41 changes: 0 additions & 41 deletions c/expr/py_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@
#include "groupby.h"


DECLARE_FUNCTION(
expr_binaryop,
"expr_binaryop(op, lhs, rhs)\n\n"
"\n",
dt_EXPR_PY_EXPR_CC)

DECLARE_FUNCTION(
expr_cast,
"expr_cast(col, stype)\n\n"
"Convert column into new stype.\n",
dt_EXPR_PY_EXPR_CC)

DECLARE_FUNCTION(
expr_column,
"expr_column(dt, i, rowindex)\n\n"
"Retrieve column `i` from the DataTable `dt`, replacing its rowindex with\n"
"the provided one and then materializing.\n",
dt_EXPR_PY_EXPR_CC)

DECLARE_FUNCTION(
expr_reduceop,
"expr_reduceop(op, col, groupby)\n\n"
"Compute a reduction over the provided column, using the provided Groupby\n"
"object.\n",
dt_EXPR_PY_EXPR_CC)

DECLARE_FUNCTION(
expr_unaryop,
"expr_unaryop(op, col)\n\n"
"Apply unary operator `op` to the column `col` and return the resulting \n"
"column.\n",
dt_EXPR_PY_EXPR_CC)

DECLARE_FUNCTION(
expr_count,
"expr_count(dt, groupby)\n\n"
"Compute number of rows in each group if the Groupby object is provided, otherwise simply\n"
"return number of rows in dataframe.\n",
dt_EXPR_PY_EXPR_CC)


namespace expr {

typedef void (*mapperfn)(int64_t row0, int64_t row1, void** params);
Expand Down
3 changes: 3 additions & 0 deletions c/expr/repl_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
// IN THE SOFTWARE.
//------------------------------------------------------------------------------
#include <unordered_map>
#include "datatable.h"
#include "expr/base_expr.h"
#include "expr/collist.h"
#include "expr/repl_node.h"
#include "expr/workframe.h"
#include "utils/exceptions.h"

namespace dt {
Expand Down
1 change: 1 addition & 0 deletions c/expr/workframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//------------------------------------------------------------------------------
#include "expr/base_expr.h"
#include "expr/collist.h"
#include "expr/workframe.h"
#include "frame/py_frame.h"
Expand Down
1 change: 0 additions & 1 deletion c/frame/py_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class Frame : public PyObject {

extern PyObject* Frame_Type;
extern PyObject* fread_fn;
extern PyObject* fallback_makedatatable;

} // namespace py

Expand Down
31 changes: 23 additions & 8 deletions datatable/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
#!/usr/bin/env python3
# © H2O.ai 2018; -*- encoding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/env python
#-------------------------------------------------------------------------------
# Copyright 2018 H2O.ai
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#-------------------------------------------------------------------------------
from .__version__ import version as __version__
from .dt_append import rbind, cbind
from .frame import Frame
from .expr import (mean, min, max, sd, isna, sum, count, first, abs, exp,
log, log10)
log, log10, f, g)
from .fread import fread, GenericReader, FreadWarning
from .graph import f, g, join, by
from .lib._datatable import (
unique, union, intersect, setdiff, symdiff,
repeat, sort
repeat, by, join, sort
)
from .nff import save, open
from .options import options
Expand Down
2 changes: 1 addition & 1 deletion datatable/expr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#-------------------------------------------------------------------------------

from datatable.graph.dtproxy import f
from .abs_expr import abs
from .base_expr import BaseExpr
from .binary_expr import BinaryOpExpr
from .cast_expr import CastExpr
from .column_expr import ColSelectorExpr, NewColumnExpr
from .dtproxy import f, g
from .exp_expr import exp, log, log10
from .isna_expr import isna
from .literal_expr import LiteralExpr
Expand Down
2 changes: 1 addition & 1 deletion datatable/expr/abs_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# limitations under the License.
#-------------------------------------------------------------------------------
from .base_expr import BaseExpr
from .dtproxy import f
from .unary_expr import UnaryOpExpr
from datatable.graph.dtproxy import f
from datatable.lib import core

__all__ = ("abs", )
Expand Down
2 changes: 1 addition & 1 deletion datatable/graph/dtproxy.py → datatable/expr/dtproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#-------------------------------------------------------------------------------

from datatable.expr.column_expr import ColSelectorExpr
from .column_expr import ColSelectorExpr

__all__ = ("f", "g")

Expand Down
Loading