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

Fixed a bug caused by a type error #696

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

Xinyi-Cheng
Copy link
Contributor

This commit addresses a specific TypeError encountered in the LibriMix.__getitem__ method when using the random.randint function. The error was triggered by passing a numpy.float64 type argument to random.randint, which expects integer arguments to generate a random integer between two specified integer values. The problematic code snippet was:

start = random.randint(0, row["length"] - self.seg_len)

Here, the operation between row["length"] and self.seg_len could result in a floating-point number, while random.randint requires integer inputs. To resolve this issue, the code has been modified to explicitly convert the result of row["length"] - self.seg_len to an integer using the int() function, as shown below:

start = random.randint(0, int(row["length"] - self.seg_len))

This modification ensures that the input to random.randint is always an integer, irrespective of the original data types involved, thus preventing the TypeError.

@mpariente
Copy link
Collaborator

Thank you very much for your contribution and clear explanation, it's perfect.
Please remove all the .DS_Store file from the PR, and this is ready to be merged.

@Xinyi-Cheng
Copy link
Contributor Author

Hi, sorry for .DS_Store files. I have corrected them in the latest commit.

@mpariente mpariente merged commit 2c7fe19 into asteroid-team:master Apr 10, 2024
3 of 4 checks passed
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.

2 participants