llama90 commented on code in PR #40761: URL: https://github.com/apache/arrow/pull/40761#discussion_r1542381779
########## python/pyarrow/type_traits.pxi: ########## @@ -0,0 +1,394 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from pyarrow.includes.libarrow cimport (is_integer, + is_signed_integer, + is_unsigned_integer, + is_floating, + is_numeric, + is_decimal, + is_run_end_type, + is_primitive, + is_base_binary_like, + is_binary_like, + is_large_binary_like, + is_binary, + is_string, + is_temporal, + is_time, + is_date, + is_interval, + is_dictionary, + is_fixed_size_binary, + is_fixed_width, + is_var_length_list, + is_list, + is_list_like, + is_var_length_list_like, + is_list_view, + is_nested, + is_union, + bit_width, + offset_bit_width) + + +def is_integer_type(data_type): + """ + Check if the data type is an integer type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_integer(data_type.id) + + +def is_signed_integer_type(data_type): + """ + Check if the data type is a signed integer type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_signed_integer(data_type.id) + + +def is_unsigned_integer_type(data_type): + """ + Check if the data type is an unsigned integer type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_unsigned_integer(data_type.id) + + +def is_floating_type(data_type): + """ + Check if the data type is a floating type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_floating(data_type.id) + + +def is_numeric_type(data_type): + """ + Check if the data type is a numeric type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_numeric(data_type.id) + + +def is_decimal_type(data_type): + """ + Check if the data type is a decimal type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_decimal(data_type.id) + + +def is_run_end_type_py(data_type): + """ + Check if the data type is a run end type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_run_end_type(data_type.id) + + +def is_primitive_type(data_type): + """ + Check if the data type is a primitive type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_primitive(data_type.id) + + +def is_base_binary_like_type(data_type): + """ + Check if the data type is a base_binary_like type. + + Parameters + ---------- + data_type : DataType + The data type to check + """ + return is_base_binary_like(data_type.id) + + +def is_binary_like_type(data_type): + """ + Check if the data type is a _binary_like type. Review Comment: I have enhanced the content. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
