Skip to content

Commit

Permalink
align_left -> lean_left
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisvandenbossche committed Jun 26, 2024
1 parent 8640a56 commit 351d979
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cpp/src/arrow/compute/api_scalar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static auto kNullOptionsType = GetFunctionOptionsType<NullOptions>(
DataMember("nan_is_null", &NullOptions::nan_is_null));
static auto kPadOptionsType = GetFunctionOptionsType<PadOptions>(
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<ReplaceSliceOptions>(
DataMember("start", &ReplaceSliceOptions::start),
DataMember("stop", &ReplaceSliceOptions::stop),
Expand Down Expand Up @@ -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[];

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/api_scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_string_ascii.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/kernels/scalar_string_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"])",
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/arrow/compute/kernels/scalar_string_utf8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions python/pyarrow/_compute.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions python/pyarrow/includes/libarrow.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 351d979

Please sign in to comment.