Skip to content
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

[BUG] Strange code logic in ColumnBase._fill #8566

Closed
isVoid opened this issue Jun 19, 2021 · 1 comment · Fixed by #9078
Closed

[BUG] Strange code logic in ColumnBase._fill #8566

isVoid opened this issue Jun 19, 2021 · 1 comment · Fixed by #9078
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@isVoid
Copy link
Contributor

isVoid commented Jun 19, 2021

I came across this during the categorical column refactor:

def _fill(
self,
fill_value: ScalarLike,
begin: int,
end: int,
inplace: bool = False,
) -> Optional[ColumnBase]:
if end <= begin or begin >= self.size:
return self if inplace else self.copy()
fill_scalar = as_device_scalar(fill_value, self.dtype)
if not inplace:
return libcudf.filling.fill(self, begin, end, fill_scalar)
if is_string_dtype(self.dtype):
return self._mimic_inplace(
libcudf.filling.fill(self, begin, end, fill_scalar),
inplace=True,
)
if fill_value is None and not self.nullable:
mask = create_null_mask(self.size, state=MaskState.ALL_VALID)
self.set_base_mask(mask)
libcudf.filling.fill_in_place(self, begin, end, fill_scalar)
return self
fill_code = self._encode(fill_value)
fill_scalar = as_device_scalar(fill_code, self.codes.dtype)
result = self if inplace else self.copy()
libcudf.filling.fill_in_place(result.codes, begin, end, fill_scalar)
return result

Seems strange that self is returned in the middle.

@isVoid isVoid added bug Something isn't working Needs Triage Need team to review and classify labels Jun 19, 2021
@isVoid isVoid changed the title [BUG] Strange code logic in _fill [BUG] Strange code logic in ColumnBase._fill Jun 19, 2021
@beckernick
Copy link
Member

Nice find. Perhaps this could have been caused by a merge conflict resolution that removed an older implementation?

@beckernick beckernick added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels Jun 21, 2021
rapids-bot bot pushed a commit that referenced this issue Aug 20, 2021
This PR removes unreachable code in `ColumnBase._fill`.
closes #8566

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #9078
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants