was-node-suite-comfyui icon indicating copy to clipboard operation
was-node-suite-comfyui copied to clipboard

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

Open gobshyte opened this issue 1 year ago • 6 comments

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: https://github.com/WoLpH/numpy-stl/issues/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.

gobshyte avatar Dec 08 '24 00:12 gobshyte

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.

WASasquatch avatar Dec 08 '24 04:12 WASasquatch

Has this been merged? I can confirm it works

mattymatty avatar Jan 20 '25 14:01 mattymatty

It happened in python 3.12.

lldacing avatar Feb 17 '25 11:02 lldacing

Image

Image

Still getting this issue. Am I doing something wrong? Otherwise can the changes suggested above be merged?

ckao10301 avatar May 08 '25 21:05 ckao10301

Still broken, the line number to fix is now 12490

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

:)

gobshyte avatar May 19 '25 21:05 gobshyte

I fixed the line a long time ago. Then recently updated ComfyUI and all the nodes to do new things that are supported and it must have updated the WAS nodes to have the wrong line of code in it AGAIN. It is crazy how this isn't fixed. So I changed the line again at the new position on line 12490 and the node works again. How is this not just fixed and committed into the updated nodes and still happening?

spiritparticle avatar May 28 '25 01:05 spiritparticle