Skip to content

CLN: rename get_block_values, simplify #32521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/_libs/src/ujson/python/objToJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ static PyObject *get_values(PyObject *obj) {
}
}

if ((values == NULL) && PyObject_HasAttrString(obj, "get_block_values")) {
if ((values == NULL) && PyObject_HasAttrString(obj, "get_block_values_for_json")) {
PRINTMARK();
values = PyObject_CallMethod(obj, "get_block_values", NULL);
values = PyObject_CallMethod(obj, "get_block_values_for_json", NULL);

if (values == NULL) {
// Clear so we can subsequently try another method
Expand Down
7 changes: 4 additions & 3 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ def get_values(self, dtype=None):
return self.values.astype(object)
return self.values

def get_block_values(self, dtype=None):
def get_block_values_for_json(self) -> np.ndarray:
"""
This is used in the JSON C code
This is used in the JSON C code.
"""
return self.get_values(dtype=dtype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep it as get_values() (but remove the dtype, since that is not used) ? The get_values already handles the reshape, avoiding the need to keep track of it here as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because get_values is next up on the chopping block

# TODO(2DEA): reshape will be unnecessary with 2D EAs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting such comments in several places won't make this happen ... (if you want this, you will need to lead a discussion about it)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

experience shows that discussion turns on amounts of complexity; marking these will allow us to pseudo-quantify that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with both of you! these do have good placeholders, but am skeptical of 2D EA.

return np.asarray(self.values).reshape(self.shape)

def to_dense(self):
return self.values.view()
Expand Down