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

WAS_Random_Number - 'float' object cannot be interpreted as an integer #520

Open
gobshyte opened this issue Dec 8, 2024 · 1 comment
Open

Comments

@gobshyte
Copy link

gobshyte commented Dec 8, 2024

Hi
I've just been trying some stuff with Python 3.11 installed, and a workflow where I use the integer output in the Random Number node breaks with this error:

2024-12-07T22:50:47.090732 - !!! Exception during processing !!! 'float' object cannot be interpreted as an integer
2024-12-07T22:50:47.094414 - Traceback (most recent call last):
  File "C:\SDAI\ComfyUI\ComfyUI\execution.py", line 324, in execute
    output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\SDAI\ComfyUI\ComfyUI\execution.py", line 199, in get_output_data
    return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\SDAI\ComfyUI\ComfyUI\execution.py", line 170, in _map_node_over_list
    process_inputs(input_dict, i)
  File "C:\SDAI\ComfyUI\ComfyUI\execution.py", line 159, in process_inputs
    results.append(getattr(obj, func)(**inputs))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\SDAI\ComfyUI\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 12342, in return_randm_number
    number = random.randint(minimum, maximum)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "random.py", line 336, in randint
  File "random.py", line 301, in randrange
TypeError: 'float' object cannot be interpreted as an integer

I think this is similar to this issue: wolph/numpy-stl#188
eg. randint no longer allows you to pass floats?

Confirmed (I think...) by changing this line 12342:

number = random.randint(minimum, maximum)

To this:

number = random.randint(int(minimum), int(maximum))

And the error goes away.

@WASasquatch
Copy link
Owner

I believe there was a PR that changed some of the functionality to make it more random with seed, and may not have been tested well. I apologize for that, been rather busy. But yes because of float input definitely would need to be converted to int first.

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

No branches or pull requests

2 participants