mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
Fix cpp unit test, code review comments
This commit is contained in:
1 parent
285f863028
commit
b3efe9607e
4 files changed
+18
-14
No files matched your search
@@ -46,7 +46,7 @@ TEST(TestDictionary, Basics) {
|
||||
ASSERT_TRUE(int16()->Equals(type2.index_type()));
|
||||
ASSERT_TRUE(type2.dictionary()->Equals(dict));
|
||||
|
||||
ASSERT_EQ("dictionary<int32, int16>", type1->ToString());
|
||||
ASSERT_EQ("dictionary<values=int32, indices=int16>", type1->ToString());
|
||||
}
|
||||
|
||||
TEST(TestDictionary, Equals) {
|
||||
|
||||
@@ -38,7 +38,7 @@ from pyarrow.array import (Array,
|
||||
Int32Array, UInt32Array,
|
||||
Int64Array, UInt64Array,
|
||||
ListArray, StringArray,
|
||||
DictionaryArray, dictionary)
|
||||
DictionaryArray)
|
||||
|
||||
from pyarrow.error import ArrowException
|
||||
|
||||
@@ -57,7 +57,7 @@ from pyarrow.schema import (null, bool_,
|
||||
uint8, uint16, uint32, uint64,
|
||||
timestamp, date,
|
||||
float_, double, binary, string,
|
||||
list_, struct, field,
|
||||
list_, struct, dictionary, field,
|
||||
DataType, Field, Schema, schema)
|
||||
|
||||
from pyarrow.table import Column, RecordBatch, Table, concat_tables
|
||||
@@ -413,14 +413,3 @@ cdef object get_series_values(object obj):
|
||||
|
||||
from_pylist = Array.from_list
|
||||
from_pandas_series = Array.from_pandas
|
||||
|
||||
|
||||
def dictionary(DataType index_type, Array dictionary):
|
||||
"""
|
||||
Dictionary (categorical, or simply encoded) type
|
||||
"""
|
||||
cdef DictionaryType out = schema.DictionaryType()
|
||||
cdef shared_ptr[CDataType] dict_type
|
||||
dict_type.reset(new CDictionaryType(index_type.sp_type, dictionary.sp_array))
|
||||
out.init(dict_type)
|
||||
return out
|
||||
@@ -25,6 +25,7 @@
|
||||
from cython.operator cimport dereference as deref
|
||||
|
||||
from pyarrow.compat import frombytes, tobytes
|
||||
from pyarrow.array cimport Array
|
||||
from pyarrow.includes.libarrow cimport (CDataType, CStructType, CListType,
|
||||
Type_NA, Type_BOOL,
|
||||
Type_UINT8, Type_INT8,
|
||||
@@ -282,6 +283,7 @@ def binary():
|
||||
"""
|
||||
return primitive_type(Type_BINARY)
|
||||
|
||||
|
||||
def list_(DataType value_type):
|
||||
cdef DataType out = DataType()
|
||||
cdef shared_ptr[CDataType] list_type
|
||||
@@ -289,6 +291,19 @@ def list_(DataType value_type):
|
||||
out.init(list_type)
|
||||
return out
|
||||
|
||||
|
||||
def dictionary(DataType index_type, Array dictionary):
|
||||
"""
|
||||
Dictionary (categorical, or simply encoded) type
|
||||
"""
|
||||
cdef DictionaryType out = DictionaryType()
|
||||
cdef shared_ptr[CDataType] dict_type
|
||||
dict_type.reset(new CDictionaryType(index_type.sp_type,
|
||||
dictionary.sp_array))
|
||||
out.init(dict_type)
|
||||
return out
|
||||
|
||||
|
||||
def struct(fields):
|
||||
"""
|
||||
|
||||
|
||||
Reference in new issue
Block a user