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

Fixing AttributeError in slice_indicator initialization #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rafe-sh
Copy link

@rafe-sh rafe-sh commented Dec 24, 2023

The issue was related to an AttributeError raised in the code when initializing the slice_indicator variable. The error occurred due to the usage of np.int as the dtype argument in the np.ones() function. In earlier versions of NumPy, np.int was a deprecated alias for the built-in int type. However, starting from NumPy 1.20, these aliases were removed.

To resolve the issue, the code was modified by changing the dtype argument from np.int to np.int64 to specify the desired precision explicitly. The modified code snippet looks as follows:

# turn partitions into an indicator
slice_indicator = np.ones(y.shape[0], dtype=np.int64)

This change ensures compatibility with the latest versions of NumPy and resolves the AttributeError related to the use of np.int in the code. The modified code should now execute without any errors.

By making this fix, the issue has been resolved, and the code functions as intended, initializing the slice_indicator variable with the correct dtype.

The issue was related to an AttributeError raised in the code when initializing the slice_indicator variable. The error occurred due to the usage of np.int as the dtype argument in the np.ones() function. In earlier versions of NumPy, np.int was a deprecated alias for the built-in int type. However, starting from NumPy 1.20, these aliases were removed.

To resolve the issue, the code was modified by changing the dtype argument from np.int to np.int64 to specify the desired precision explicitly. The modified code snippet looks as follows:

```
# turn partitions into an indicator
slice_indicator = np.ones(y.shape[0], dtype=np.int64)
```

Title: Fixing AttributeError in slice_indicator initialization

Description:
The issue was related to an `AttributeError` raised in the code when initializing the `slice_indicator` variable. The error occurred due to the usage of `np.int` as the dtype argument in the `np.ones()` function. In earlier versions of NumPy, `np.int` was a deprecated alias for the built-in `int` type. However, starting from NumPy 1.20, these aliases were removed.

To resolve the issue, the code was modified by changing the dtype argument from `np.int` to `np.int64` to specify the desired precision explicitly. The modified code snippet looks as follows:

```python
# turn partitions into an indicator
slice_indicator = np.ones(y.shape[0], dtype=np.int64)
```

This change ensures compatibility with the latest versions of NumPy and resolves the `AttributeError` related to the use of `np.int` in the code. The modified code should now execute without any errors.

By making this fix, the issue has been resolved, and the code functions as intended, initializing the `slice_indicator` variable with the correct dtype.
@gunsodo
Copy link

gunsodo commented Apr 29, 2024

@rafe-sh I noticed there is another np.int in sliced.datasets as well.

target_dtype = np.int

@joshloyal May I kindly ask if there is any plan for releasing a new version including this fix that @rafe-sh has made? Anyway, I sincerely thank you for making this repository!

@statmlben
Copy link

A quick fix for this error is to add one line before using sliced:

import numpy as np
np.int = np.int64

Of course, this is an ad-hoc solution. Hope the authors can merge this commit soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants