-
Notifications
You must be signed in to change notification settings - Fork 127
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
Invalid layer weight: '10.0'. Expected type: <class 'int'> #56
Comments
This should be covered by the above PR, i'll take a look and make a release. |
nice one, I'll check that out cheers |
just tried adding that line |
I believe the ZeroDivisionError is happening because with some trait folders in my collection there are for example 150 traits (I can probably solve this by further separating my layers), so the weight is a floating point less than 1, and any float less than 1 is converted to 0 by Python's int method. We could use the math library and specifically the math.ceil method, although since weights need to add up to 100 that could pose a different problem, and would break with trait folders with more than 100 items. Perhaps the simplest fix here is just to specify that trait folders cannot hold more than 100 items, and keep the new int conversion, although, thinking about it, if the weights must add up to 100 and the int method rounds down, then this will fail on quite a lot of folder sizes, unless I'm missing something. |
Here's updated code that will handle trait folders of more than 100, while also ensuring that the weight folder will always equal 100. This ensures that no matter what the trait folder size is, the outputted weights will always be an array of integers. It does this by calculating the floating points first (before rounding), keeping track of the sum of the rounded weights (and the difference from 100), and then distributing back the difference, so the final weight adds up to 100. This will still of course cause any trait folder that contains more than 100 items to leave some weights as equal to zero (but avoids the ZeroDivisionError). If this or something like this works for you, I'd also add a caveat in the README / docs that trait folders shouldn't contain more than 100 items.
|
If this is more than 100 traits, |
@faea726 yeah I mean I initially just wanted to use an open-source NFT generator rather than write one |
Hi,
I've just started playing around with nft-generator-py, great work! I'm currently running into an error when trying to validate my config file, which is as the title of the issue suggests: "Invalid layer weight: '10.0'. Expected type: <class 'int'>"
All of the weights are being generated as floating point, even if there are only 5 traits in a particular folder (e.g. weights are then:
[20.0, 20.0, 20.0, 20.0, 20.0], instead of [20, 20, 20, 20, 20], and the validation stage seems to consider this an error:
Is there any known way to avoid this issue?
The text was updated successfully, but these errors were encountered: