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

Update gini.py #9

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

Conversation

BoogalooLi
Copy link

import numpy as np test_list = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000] np_array_test_list = np.array(test_list)

i use this as a test array, add it throw out an error,

`UFuncTypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_10648\1272286076.py in
----> 1 g4 = gini4(np_array_test_list)
2 print("g4: ", g4)

~\AppData\Local\Temp\ipykernel_10648\4044443746.py in gini4(array)
6 if np.amin(array) < 0:
7 array -= np.amin(array) #values cannot be negative
----> 8 array += 0.0000001 #values cannot be 0
9 array = np.sort(array) #values must be sorted
10 index = np.arange(1,array.shape[0]+1) #index per array element

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int32') with casting rule 'same_kind'`

but if i add array = array.astype(float), the error disappered.

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.

1 participant