Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.