diff --git a/cpp/src/arrow/compute/api_scalar.cc b/cpp/src/arrow/compute/api_scalar.cc index 02b9c0945da39..7c3bc46650e9f 100644 --- a/cpp/src/arrow/compute/api_scalar.cc +++ b/cpp/src/arrow/compute/api_scalar.cc @@ -342,7 +342,7 @@ static auto kNullOptionsType = GetFunctionOptionsType( DataMember("nan_is_null", &NullOptions::nan_is_null)); static auto kPadOptionsType = GetFunctionOptionsType( DataMember("width", &PadOptions::width), DataMember("padding", &PadOptions::padding), - DataMember("align_left_on_odd_padding", &PadOptions::align_left_on_odd_padding)); + DataMember("lean_left_on_odd_padding", &PadOptions::lean_left_on_odd_padding)); static auto kReplaceSliceOptionsType = GetFunctionOptionsType( DataMember("start", &ReplaceSliceOptions::start), DataMember("stop", &ReplaceSliceOptions::stop), @@ -481,11 +481,11 @@ NullOptions::NullOptions(bool nan_is_null) : FunctionOptions(internal::kNullOptionsType), nan_is_null(nan_is_null) {} constexpr char NullOptions::kTypeName[]; -PadOptions::PadOptions(int64_t width, std::string padding, bool align_left_on_odd_padding) +PadOptions::PadOptions(int64_t width, std::string padding, bool lean_left_on_odd_padding) : FunctionOptions(internal::kPadOptionsType), width(width), padding(std::move(padding)), - align_left_on_odd_padding(align_left_on_odd_padding) {} + lean_left_on_odd_padding(lean_left_on_odd_padding) {} PadOptions::PadOptions() : PadOptions(0, " ") {} constexpr char PadOptions::kTypeName[]; diff --git a/cpp/src/arrow/compute/api_scalar.h b/cpp/src/arrow/compute/api_scalar.h index 56184bd26a68f..9a913ddbe18ac 100644 --- a/cpp/src/arrow/compute/api_scalar.h +++ b/cpp/src/arrow/compute/api_scalar.h @@ -359,7 +359,7 @@ class ARROW_EXPORT StrftimeOptions : public FunctionOptions { class ARROW_EXPORT PadOptions : public FunctionOptions { public: explicit PadOptions(int64_t width, std::string padding = " ", - bool align_left_on_odd_padding = true); + bool lean_left_on_odd_padding = true); PadOptions(); static constexpr char const kTypeName[] = "PadOptions"; @@ -370,7 +370,7 @@ class ARROW_EXPORT PadOptions : public FunctionOptions { /// What to do if there is an odd number of padding characters (in case of centered /// padding). Defaults to alignig on the left (i.e. adding the extra padding character /// on the right) - bool align_left_on_odd_padding = true; + bool lean_left_on_odd_padding = true; }; class ARROW_EXPORT TrimOptions : public FunctionOptions { diff --git a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc index 3a5d1a3ba4ca1..fecd57412b436 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc +++ b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc @@ -1142,7 +1142,7 @@ struct AsciiPadTransform : public StringTransformBase { int64_t left = 0; int64_t right = 0; if (PadLeft && PadRight) { - if (options_.align_left_on_odd_padding) { + if (options_.lean_left_on_odd_padding) { left = spaces / 2; right = spaces - left; } else { diff --git a/cpp/src/arrow/compute/kernels/scalar_string_test.cc b/cpp/src/arrow/compute/kernels/scalar_string_test.cc index 87efacf2e88ed..0a2261290846a 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_test.cc +++ b/cpp/src/arrow/compute/kernels/scalar_string_test.cc @@ -2117,7 +2117,7 @@ TYPED_TEST(TestStringKernels, PadUTF8) { R"([null, "a\u2008\u2008\u2008\u2008", "bb\u2008\u2008\u2008", "b\u00E1r\u2008\u2008", "foobar"])", &options); - PadOptions options2{/*width=*/5, "\xe2\x80\x88", /*align_left_on_odd_padding=*/false}; + PadOptions options2{/*width=*/5, "\xe2\x80\x88", /*lean_left_on_odd_padding=*/false}; this->CheckUnary( "utf8_center", R"([null, "a", "bb", "b\u00E1r", "foobar"])", this->type(), R"([null, "\u2008\u2008a\u2008\u2008", "\u2008\u2008bb\u2008", "\u2008b\u00E1r\u2008", "foobar"])", @@ -2465,7 +2465,7 @@ TYPED_TEST(TestStringKernels, PadAscii) { this->CheckUnary("ascii_rpad", R"([null, "a", "bb", "bar", "foobar"])", this->type(), R"([null, "a ", "bb ", "bar ", "foobar"])", &options); - PadOptions options2{/*width=*/5, " ", /*align_left_on_odd_padding=*/false}; + PadOptions options2{/*width=*/5, " ", /*lean_left_on_odd_padding=*/false}; this->CheckUnary("ascii_center", R"([null, "a", "bb", "bar", "foobar"])", this->type(), R"([null, " a ", " bb ", " bar ", "foobar"])", &options2); diff --git a/cpp/src/arrow/compute/kernels/scalar_string_utf8.cc b/cpp/src/arrow/compute/kernels/scalar_string_utf8.cc index 141512e794d85..42762ca8b116f 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_utf8.cc +++ b/cpp/src/arrow/compute/kernels/scalar_string_utf8.cc @@ -930,7 +930,7 @@ struct Utf8PadTransform : public StringTransformBase { int64_t left = 0; int64_t right = 0; if (PadLeft && PadRight) { - if (options_.align_left_on_odd_padding) { + if (options_.lean_left_on_odd_padding) { left = spaces / 2; right = spaces - left; } else { diff --git a/python/pyarrow/_compute.pyx b/python/pyarrow/_compute.pyx index e234a6ad5a5ed..1bb864ac68fbb 100644 --- a/python/pyarrow/_compute.pyx +++ b/python/pyarrow/_compute.pyx @@ -1108,8 +1108,8 @@ class MatchSubstringOptions(_MatchSubstringOptions): cdef class _PadOptions(FunctionOptions): - def _set_options(self, width, padding, align_left_on_odd_padding): - self.wrapped.reset(new CPadOptions(width, tobytes(padding), align_left_on_odd_padding)) + def _set_options(self, width, padding, lean_left_on_odd_padding): + self.wrapped.reset(new CPadOptions(width, tobytes(padding), lean_left_on_odd_padding)) class PadOptions(_PadOptions): @@ -1122,14 +1122,14 @@ class PadOptions(_PadOptions): Desired string length. padding : str, default " " What to pad the string with. Should be one byte or codepoint. - align_left_on_odd_padding : bool, default True + lean_left_on_odd_padding : bool, default True What to do if there is an odd number of padding characters (in case of centered padding). Defaults to alignig on the left (i.e. adding the extra padding character on the right). """ - def __init__(self, width, padding=' ', align_left_on_odd_padding=True): - self._set_options(width, padding, align_left_on_odd_padding) + def __init__(self, width, padding=' ', lean_left_on_odd_padding=True): + self._set_options(width, padding, lean_left_on_odd_padding) cdef class _TrimOptions(FunctionOptions): diff --git a/python/pyarrow/includes/libarrow.pxd b/python/pyarrow/includes/libarrow.pxd index 6a74cc441473d..3dee463118442 100644 --- a/python/pyarrow/includes/libarrow.pxd +++ b/python/pyarrow/includes/libarrow.pxd @@ -2359,10 +2359,10 @@ cdef extern from "arrow/compute/api.h" namespace "arrow::compute" nogil: cdef cppclass CPadOptions \ "arrow::compute::PadOptions"(CFunctionOptions): - CPadOptions(int64_t width, c_string padding, c_bool align_left_on_odd_padding) + CPadOptions(int64_t width, c_string padding, c_bool lean_left_on_odd_padding) int64_t width c_string padding - c_bool align_left_on_odd_padding + c_bool lean_left_on_odd_padding cdef cppclass CSliceOptions \ "arrow::compute::SliceOptions"(CFunctionOptions):