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

Iterating over column raises IndexOutOfBoundsError #47

Closed
lars-reimann opened this issue Mar 15, 2023 · 1 comment · Fixed by #55
Closed

Iterating over column raises IndexOutOfBoundsError #47

lars-reimann opened this issue Mar 15, 2023 · 1 comment · Fixed by #55
Assignees
Labels
bug 🪲 Something isn't working released Included in a release

Comments

@lars-reimann
Copy link
Member

lars-reimann commented Mar 15, 2023

Describe the bug

Running code like this

for value in column:
    print(value)

raises an IndexOutOfBoundsError because index >= self._data.size.

If one instead writes

for value in column._data:
    print(value)

everything works as expected. But we don't want users to access the internal _data, so this is not a feasible workaround.

Additional context (optional)

Rows are probably affected, too.

@lars-reimann lars-reimann added the bug 🪲 Something isn't working label Mar 15, 2023
@github-project-automation github-project-automation bot moved this to Backlog in Library Mar 15, 2023
@lars-reimann lars-reimann self-assigned this Mar 15, 2023
@lars-reimann lars-reimann moved this from Backlog to Todo in Library Mar 15, 2023
@lars-reimann lars-reimann linked a pull request Mar 21, 2023 that will close this issue
lars-reimann added a commit that referenced this issue Mar 21, 2023
Closes #47.

### Summary of Changes

* Add `__iter__` method to `Column` and `Row` to iterate over the
values:
  * Iterating over a `Column` returns the values.
* Iterating over a `Row` returns the column names, as specified in the
[documenetation of
`__iter__`](https://docs.python.org/3/reference/datamodel.html#object.__iter__).
* Add `__len__` method to `Column` and `Row` to compute their length.
* Change superclasses of exceptions as needed for
[`__getitem__`](https://docs.python.org/3/reference/datamodel.html#object.__getitem__):
  * Change superclass of `IndexOutOfBoundsError` to `IndexError`.
  * Change superclass of `UnknownColumnNameError` to `KeyError`.

---------

Co-authored-by: lars-reimann <[email protected]>
@github-project-automation github-project-automation bot moved this from Todo to ✔️ Done in Library Mar 21, 2023
lars-reimann pushed a commit that referenced this issue Mar 24, 2023
## [0.3.0](v0.2.0...v0.3.0) (2023-03-24)

### Features

* make `Column` and `Row` iterable ([#55](#55)) ([74eea1f](74eea1f)), closes [#47](#47)

### Bug Fixes

* "UserWarning: X has feature names" when predicting ([#53](#53)) ([74b0753](74b0753)), closes [#51](#51)
@lars-reimann
Copy link
Member Author

🎉 This issue has been resolved in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@lars-reimann lars-reimann added the released Included in a release label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working released Included in a release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant