Conversation
|
|
|
|
|
|
6a30cb8 to
0e83a1b
Compare
llama90
left a comment
There was a problem hiding this comment.
As you can see, not all functions can be replaced by the functionalities present in type_traits.h.
- There are cases where
type_traits.hdoes not provide functions that check for a specific type only (e.g.,int8,int16,int32,int64, etc.). - Even when check functions are available, they may cover different types from one another (e.g.,
temporaltypes, etc.).
Assuming a draft that makes the functions in type_traits.h accessible from Python has been created in this PR, it would be beneficial to address the mentioned types. Organizing these and handling them through new issues and PRs would be ideal.
I'd appreciate your thoughts on this matter. cc @AlenkaF @jorisvandenbossche @pitrou
|
|
There was a problem hiding this comment.
These docstrings are not useful if they merely repeat what the function name says. You should explain what a "_binary_like" type is, because the reader probably doesn't know.
There was a problem hiding this comment.
In other words, please use your own judgement when writing docstrings. Don't just write them mechanically.
There was a problem hiding this comment.
I have enhanced the content.
There was a problem hiding this comment.
It is looking much better, thanks! I think you could remove the first sentence, and maybe the last ("Useful for ..."). The middle portions of the docstrings are quite clear already.
There was a problem hiding this comment.
Even I don't know what a "offset_bit_width type" is supposed to be...
There was a problem hiding this comment.
Hmm... why are we defining two sets of functions exactly? We should have either is_integer or is_integer_type, not both.
There was a problem hiding this comment.
I wrote the wrapper for the C++ function to use the is_integer function, thinking someone might use it while working with pyarrow for compatibility. Should we not consider this aspect?
There was a problem hiding this comment.
hello. I would appreciate it if you could review it when you have time. thank you! cc @pitrou
|
I've updated the docstrings based on the review and made adjustments to ensure that existing functions work using the functions in I understand that pyarrow has a wide user base, and to avoid breaking compatibility, I've made sure that functions in the form of Additionally, I plan to create a new issue to address types such as
This requires further consideration, and I intend to proceed with a new issue for it. |
AlenkaF
left a comment
There was a problem hiding this comment.
Thank you for the updates! Just few more suggestions from me.
Additionally, I plan to create a new issue to address types such as NA, BINARY_VIEW, STRING_VIEW, FIXED_SIZE_LIST, STRUCT, and RUN_END_ENCODED, ...
Sounds great!
There was a problem hiding this comment.
It is looking much better, thanks! I think you could remove the first sentence, and maybe the last ("Useful for ..."). The middle portions of the docstrings are quite clear already.
AlenkaF
left a comment
There was a problem hiding this comment.
Looking great! (Only added one small suggestion).
Thank you for working on this!
|
@pitrou mind giving one more look before I merge? |
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Parameters {'ty', 'allow_none'} not documented
|
@pitrou Hello. I think the changes match what we wanted. Could you review them when you have time? Thank you. |
|
Hi @llama90 , I filed the original issue. Your PR is reimplementing too many things. This issue was originally filed due to this comment: https://github.com/apache/arrow/pull/40265/files#r1505826814 To help clarify, we don't want to reimplement all of the type checks. Instead, we want to investigate if we can replace these python-defined vars Lines 29 to 46 in e1de9c5 Line 177 in e1de9c5 Let me know if that helps. |
|
Thank you for the clarification @danepitkin! I have also misunderstood the issue and guided @llama90 in wrong directions, very sorry about that! I hope you are still willing to finish this and that the clarification from Dane helps? |
|
I haven’t reviewed it in detail yet, but I will consider feedback and proceed accordingly. Thank you!! |
|
From your description and the mention by @pitrou, I understood the following:
From a straightforward view, the cases that can be replaced with C++ functions are as follows:
In this case, do you intend to only replace the functions marked with ✅? Or are you considering modifying the C++ functions to align with the Python implementation as well?
is_interval, is_temporal, and is_nested/// \brief Check for an interval type
///
/// \param[in] type_id the type-id to check
/// \return whether type-id is an interval type one
constexpr bool is_interval(Type::type type_id) {
switch (type_id) {
case Type::INTERVAL_MONTHS:
case Type::INTERVAL_DAY_TIME:
case Type::INTERVAL_MONTH_DAY_NANO:
return true;
default:
break;
}
return false;
}
/// \brief Check for a temporal type
///
/// \param[in] type_id the type-id to check
/// \return whether type-id is a temporal type one
constexpr bool is_temporal(Type::type type_id) {
switch (type_id) {
case Type::DATE32:
case Type::DATE64:
case Type::TIME32:
case Type::TIME64:
case Type::TIMESTAMP:
return true;
default:
break;
}
return false;
}
/// \brief Check for a nested type
///
/// \param[in] type_id the type-id to check
/// \return whether type-id is a nested type one
constexpr bool is_nested(Type::type type_id) {
switch (type_id) {
case Type::LIST:
case Type::LARGE_LIST:
case Type::LIST_VIEW:
case Type::LARGE_LIST_VIEW:
case Type::FIXED_SIZE_LIST:
case Type::MAP:
case Type::STRUCT:
case Type::SPARSE_UNION:
case Type::DENSE_UNION:
case Type::RUN_END_ENCODED:
return true;
default:
break;
}
return false;
}
Moreover, while it is certainly easier to simply apply what you have mentioned, from a long-term perspective, exporting C++ functions to replace equivalent Python code raises questions about the rationale for maintaining them separately. I would like to seek further opinions on this. |
|
The predicates around lists and list-views are quite confusing (for backwards compatibility reasons) with some are deprecated. Is it possible to not repeat these on the Python side or we have to keep exactly the same structure that we have in C++? https://gist.github.com/felipecrv/3c02f3784221d946dec1b031c6d400db |
|
Aha... I see that maintaining both C++ and Python code identically may complicate maintenance. |
|
I have come too far in this PR to make changes, so I have closed it and opened a new one. |

Rationale for this change
Use C++ type traits to avoid redefining in Python
What changes are included in this PR?
Changed all functions that check types in
type_traits.hso that they can be used in Python.Are these changes tested?
Yes
Are there any user-facing changes?
Yes