Skip to content

Commit

Permalink
Clean up Module torcharrow has no attribute _torcharrow. (pytor…
Browse files Browse the repository at this point in the history
…ch#262)

Summary: Pull Request resolved: pytorch#262

Reviewed By: vancexu

Differential Revision: D35106132

fbshipit-source-id: 57f162508a60bbef64122f5957dd8f5011d72f26
  • Loading branch information
wenleix authored and facebook-github-bot committed Mar 24, 2022
1 parent 6e0c236 commit 588f9b1
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 223 deletions.
126 changes: 0 additions & 126 deletions torcharrow/test/lib_test/test_column.py

Large diffs are not rendered by default.

55 changes: 0 additions & 55 deletions torcharrow/test/lib_test/test_udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import unittest
from typing import List, Any

# pyre-fixme[21]: Could not find module `torcharrow._torcharrow`.
# @manual=//pytorch/torcharrow/csrc/velox:_torcharrow
import torcharrow._torcharrow as ta


Expand All @@ -29,7 +27,6 @@ def assert_SimpleColumn(self, col: ta.BaseColumn, val: List[Any]) -> None:

@staticmethod
def construct_simple_column(velox_type, data: List[Any]):
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = ta.Column(velox_type)
for item in data:
if item is None:
Expand All @@ -41,94 +38,74 @@ def construct_simple_column(velox_type, data: List[Any]):
def test_basic(self) -> None:
# test some UDFs together
data = ["abc", "ABC", "XYZ123", None, "xYZ", "123", "äöå"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("lower", col)
self.assert_SimpleColumn(
lcol, ["abc", "abc", "xyz123", None, "xyz", "123", "äöå"]
)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ucol = ta.generic_udf_dispatch("upper", col)
self.assert_SimpleColumn(
ucol, ["ABC", "ABC", "XYZ123", None, "XYZ", "123", "ÄÖÅ"]
)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol2 = ta.generic_udf_dispatch("lower", ucol)
self.assert_SimpleColumn(
lcol2, ["abc", "abc", "xyz123", None, "xyz", "123", "äöå"]
)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ucol2 = ta.generic_udf_dispatch("upper", lcol)
self.assert_SimpleColumn(
ucol2, ["ABC", "ABC", "XYZ123", None, "XYZ", "123", "ÄÖÅ"]
)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
alpha = ta.generic_udf_dispatch("torcharrow_isalpha", col)
self.assert_SimpleColumn(alpha, [True, True, False, None, True, False, True])

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
alnum = ta.generic_udf_dispatch("torcharrow_isalnum", col)
self.assert_SimpleColumn(alnum, [True, True, True, None, True, True, True])

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
digit = ta.generic_udf_dispatch("torcharrow_isdecimal", col)
self.assert_SimpleColumn(digit, [False, False, False, None, False, True, False])

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
islower = ta.generic_udf_dispatch("torcharrow_islower", col)
self.assert_SimpleColumn(
islower, [True, False, False, None, False, False, True]
)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
isupper = ta.generic_udf_dispatch("torcharrow_isupper", col)
self.assert_SimpleColumn(
isupper, [False, True, True, None, False, False, False]
)

# substr, 3 parameters
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
substr = ta.generic_udf_dispatch(
"substr",
col,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn(2, 7), # start
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn(2, 7), # length
)
data = ["abc", "ABC", "XYZ123", None, "xYZ", "123", "äöå"]

self.assert_SimpleColumn(substr, ["bc", "BC", "YZ", None, "YZ", "23", "öå"])

data2 = [1, 2, 3, None, 5, None, -7]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col2 = self.construct_simple_column(ta.VeloxType_BIGINT(), data2)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
neg = ta.generic_udf_dispatch("negate", col2)
self.assert_SimpleColumn(neg, [-1, -2, -3, None, -5, None, 7])

data3 = ["\n", "a", "\t", "76", " ", None]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col3 = self.construct_simple_column(ta.VeloxType_VARCHAR(), data3)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
isspace = ta.generic_udf_dispatch("torcharrow_isspace", col3)
self.assert_SimpleColumn(isspace, [True, False, True, False, True, None])

data4 = ["a b c", "d,e,f"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col4 = self.construct_simple_column(ta.VeloxType_VARCHAR(), data4)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
splits = ta.generic_udf_dispatch(
"split",
col4,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn(" ", len(data4)),
)
expected = [["a", "b", "c"], ["d,e,f"]]
Expand All @@ -137,64 +114,48 @@ def test_basic(self) -> None:
self.assert_SimpleColumn(splits[i], expected[i])

def test_coalesce(self) -> None:
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col1 = self.construct_simple_column(ta.VeloxType_BIGINT(), [1, 2, None, 3])
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
result = ta.generic_udf_dispatch(
"coalesce",
col1,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn(42, len(col1)),
)
self.assert_SimpleColumn(result, [1, 2, 42, 3])
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
self.assertTrue(isinstance(result.type(), ta.VeloxType_BIGINT))

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col2 = self.construct_simple_column(ta.VeloxType_INTEGER(), [1, 2, None, 3])
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
result = ta.generic_udf_dispatch(
"coalesce",
col2,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn(42, len(col2), ta.VeloxType_INTEGER()),
)
self.assert_SimpleColumn(result, [1, 2, 42, 3])
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
self.assertTrue(isinstance(result.type(), ta.VeloxType_INTEGER))

def test_regex(self) -> None:
# test some regex UDF
data = ["abc", "a1", "b2", "c3", "___d4___", None]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
match = ta.generic_udf_dispatch(
"match_re",
col,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn("[a-z]\\d", 6),
)
self.assert_SimpleColumn(match, [False, True, True, True, False, None])

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
search = ta.generic_udf_dispatch(
"regexp_like",
col,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn("[a-z]\\d", 6),
)
self.assert_SimpleColumn(search, [False, True, True, True, True, None])

data = ["d4e5", "a1", "b2", "c3", "___d4___f6"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
extract = ta.generic_udf_dispatch(
"regexp_extract_all",
col,
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
ta.ConstantColumn("([a-z])\\d", 5),
)
expected = [["d4", "e5"], ["a1"], ["b2"], ["c3"], ["d4", "f6"]]
Expand All @@ -204,9 +165,7 @@ def test_regex(self) -> None:

def test_lower(self) -> None:
data = ["abc", "ABC", "XYZ123", None, "xYZ", "123", "äöå"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("lower", col)
self.assert_SimpleColumn(
lcol, ["abc", "abc", "xyz123", None, "xyz", "123", "äöå"]
Expand All @@ -225,9 +184,7 @@ def test_istitle(self) -> None:
"AaBbCd",
None,
]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
istitle = ta.generic_udf_dispatch("torcharrow_istitle", col)
self.assert_SimpleColumn(
istitle,
Expand All @@ -254,28 +211,22 @@ def test_istitle(self) -> None:
"A1 B2",
"A1B2",
]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
istitle = ta.generic_udf_dispatch("torcharrow_istitle", col)
self.assert_SimpleColumn(istitle, [True, True, True, True, True, True, True])

def test_isnumeric(self) -> None:
# All False
data = ["-1", "1.5", "+2", "abc", "AA", "VIII", "1/3", None]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("torcharrow_isnumeric", col)
self.assert_SimpleColumn(
lcol, [False, False, False, False, False, False, False, None]
)

# All True
data = ["9876543210123456789", "ⅧⅪ", "ⅷ〩𐍁ᛯ", "᧖७𝟡௫6", "¼⑲⑹⓲➎㉏𐧯"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("torcharrow_isnumeric", col)
self.assert_SimpleColumn(lcol, [True, True, True, True, True])

Expand All @@ -289,24 +240,18 @@ def test_isprintable(self) -> None:
"re\terw",
None,
]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("torcharrow_isprintable", col)
self.assert_SimpleColumn(lcol, [False, False, False, False, False, None])

# # All True
data = ["9876543210123456789", "ⅧⅪ", "ⅷ〩𐍁ᛯ", "᧖७𝟡௫6", "¼⑲⑹⓲➎㉏𐧯"]
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = self.construct_simple_column(ta.VeloxType_VARCHAR(), data)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
lcol = ta.generic_udf_dispatch("torcharrow_isprintable", col)
self.assert_SimpleColumn(lcol, [True, True, True, True, True])

def test_factory(self) -> None:
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = ta.factory_udf_dispatch("rand", 42)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
self.assertEqual(col.type().kind(), ta.TypeKind.DOUBLE)
self.assertEqual(42, len(col))
for i in range(42):
Expand Down
6 changes: 0 additions & 6 deletions torcharrow/velox_rt/dataframe_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import numpy as np
import pyarrow as pa
import torcharrow as ta

# pyre-fixme[21]: Could not find module `torcharrow._torcharrow`.
import torcharrow._torcharrow as velox
import torcharrow.dtypes as dt
import torcharrow.pytorch as pytorch
Expand Down Expand Up @@ -69,7 +67,6 @@ def __init__(self, device: str, dtype: dt.Struct, data: Dict[str, ColumnCpuMixin
assert dt.is_struct(dtype)
DataFrame.__init__(self, device, dtype)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
self._data = velox.Column(get_velox_type(dtype))
assert isinstance(data, Dict)

Expand Down Expand Up @@ -174,7 +171,6 @@ def _from_arrow(device: str, array: pa.StructArray, dtype: dt.Struct):
# pyre-fixme[16]: `Array` has no attribute `_export_to_c`.
array._export_to_c(ptr_array, ptr_schema)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
velox_column = velox._import_from_arrow(
get_velox_type(dtype), ptr_array, ptr_schema
)
Expand Down Expand Up @@ -213,7 +209,6 @@ def _fromdata(
[dt.Field(n, c.dtype) for n, c in field_data.items()],
nullable=self.dtype.nullable,
)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = velox.Column(get_velox_type(dtype))
for n, c in field_data.items():
# pyre-fixme[16]: `Column` has no attribute `_data`.
Expand Down Expand Up @@ -326,7 +321,6 @@ def _set_field_data(self, name: str, col: Column, empty_df: bool):

# pyre-fixme[16]: `DType` has no attribute `get_index`.
column_idx = self._dtype.get_index(name)
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
new_delegate = velox.Column(get_velox_type(self._dtype))
# pyre-fixme[16]: `Column` has no attribute `_data`.
new_delegate.set_length(len(col._data))
Expand Down
3 changes: 0 additions & 3 deletions torcharrow/velox_rt/list_column_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from typing import List, Callable, Optional

import torcharrow as ta

# pyre-fixme[21]: Could not find module `torcharrow._torcharrow`.
import torcharrow._torcharrow as velox
import torcharrow.dtypes as dt
import torcharrow.pytorch as pytorch
Expand Down Expand Up @@ -58,7 +56,6 @@ def _empty(device, dtype: dt.List):
@staticmethod
def _from_pysequence(device: str, data: List[List], dtype: dt.List):
if dt.is_primitive(dtype.item_dtype):
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
velox_column = velox.Column(get_velox_type(dtype), data)
return ColumnCpuMixin._from_velox(
device,
Expand Down
7 changes: 0 additions & 7 deletions torcharrow/velox_rt/numerical_column_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import numpy as np
import torcharrow as ta

# pyre-fixme[21]: Could not find module `torcharrow._torcharrow`.
import torcharrow._torcharrow as velox
import torcharrow.dtypes as dt
import torcharrow.pytorch as pytorch
Expand Down Expand Up @@ -50,7 +48,6 @@ def _empty(device, dtype):
def _from_pysequence(
device: str, data: Sequence[Union[int, float, bool]], dtype: dt.DType
):
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
velox_column = velox.Column(get_velox_type(dtype), data)
return ColumnCpuMixin._from_velox(
device,
Expand All @@ -73,7 +70,6 @@ def _from_arrow(device: str, array, dtype: dt.DType):
# pyre-fixme[16]: `Array` has no attribute `_export_to_c`.
array._export_to_c(ptr_array, ptr_schema)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
velox_column = velox._import_from_arrow(
get_velox_type(dtype), ptr_array, ptr_schema
)
Expand Down Expand Up @@ -184,7 +180,6 @@ def sort(
res.append(self._getdata(i))
res.sort(reverse=not ascending)

# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = velox.Column(get_velox_type(self.dtype))
if na_position == "first":
for i in range(none_count):
Expand Down Expand Up @@ -607,7 +602,6 @@ def fill_null(self, fill_value: Union[dt.ScalarTypes, Dict]):
if not self.is_nullable:
return self
else:
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = velox.Column(get_velox_type(self.dtype))
for i in range(len(self)):
if self._getmask(i):
Expand Down Expand Up @@ -646,7 +640,6 @@ def drop_duplicates(
if subset is not None:
raise TypeError(f"subset parameter for numerical columns not supported")
seen = set()
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
col = velox.Column(get_velox_type(self.dtype))
for i in range(len(self)):
if self._getmask(i):
Expand Down
3 changes: 0 additions & 3 deletions torcharrow/velox_rt/string_column_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from typing import Optional, Sequence

import numpy as np

# pyre-fixme[21]: Could not find module `torcharrow._torcharrow`.
import torcharrow._torcharrow as velox
import torcharrow.dtypes as dt
from tabulate import tabulate
Expand Down Expand Up @@ -76,7 +74,6 @@ def _full(device, data, dtype=None, mask=None):

@staticmethod
def _from_pysequence(device: str, data: Sequence[str], dtype: dt.DType):
# pyre-fixme[16]: Module `torcharrow` has no attribute `_torcharrow`.
velox_column = velox.Column(get_velox_type(dtype), data)
return ColumnCpuMixin._from_velox(
device,
Expand Down
Loading

0 comments on commit 588f9b1

Please sign in to comment.