Nodes/Comfy_KepListStuff/Range(Num Steps) - Int
ComfyUI Node

Range(Num Steps) - Int

Exactly N integer steps, evenly spaced — no math required

By M1kep·Created 3 years ago·Updated 2 years ago· 56
Range(Num Steps) - Int
    • range
    • range_sizes
    start0
    stop0
    num_steps0
    end_modeInclusive
    allow_uneven_stepsFalse

    Range(Num Steps) - Int is the "give me a specific number of integer values" sibling of Range(Step) - Int. The step-based version asks how far apart values should be; this one asks how many values you want, and spaces them evenly between start and stop. Want six integer steps from 0 to 10? Set start=0, stop=10, num_steps=6 and let the node figure out that the spacing is 2.

    The inputs are start, stop, num_steps (all INT), plus two enums: end_mode (Inclusive default / Exclusive) and allow_uneven_steps (False default / True). Outputs are range (the integer list) and range_sizes (per-run lengths, for when you feed multiple starts/stops as lists).

    Mechanically it uses numpy.linspace rounded to integers. Here's the part that matters in practice: linspace computes an even step of (stop - start) / (num_steps - 1), and if that division doesn't come out to a whole number, you've got a decision to make. With allow_uneven_steps left at False, a non-integer step raises Uneven steps detected for start=... stop=... num_steps=... - the node refuses to silently round. Flip it to True and it rounds each value to the nearest integer instead, accepting that the steps won't be perfectly even. Pick your poison deliberately: False keeps the sweep honest but will error on awkward spans, True lets anything through but the spacing gets approximate.

    Two more traps worth naming. First, the end_mode: Exclusive shrinks stop by one step's direction before generating, so you get the same "is the endpoint included?" question the step-based range asks - and Inclusive is the default, so 0→10 in six steps gives you 0, 2, 4, 6, 8, 10. Second, the default num_steps is 0, and generating a range with zero steps silently returns an empty range - no error, just nothing, which downstream usually means a batch that never runs. Set a real count (2 or more) before you run; the Float version of this node actually crashes on this, this one just disappoints you. Also note allow_uneven_steps can't be fed a list - single value only, or it refuses.

    Like its step-based sibling, it's list-aware: feed lists of starts/stops and it builds multiple concatenated ranges, with range_sizes marking each segment's boundary for grid slicing. That makes it a solid axis generator for the pack's XY workflows - a checkpoint sweep over an exact count of seeds, for example.

    Install is the pack-wide one-liner with zero extra dependencies:

    cd ComfyUI/custom_nodes
    git clone https://github.com/M1kep/Comfy_KepListStuff
    

    Restart ComfyUI or install Comfy_KepListStuff via Manager, and look under List Stuff. Set a real num_steps, pick your end_mode, and decide how you feel about uneven steps before you hit queue.

    CategoryList Stuff

    Inputs (5)

    NameTypeDefaultDescription
    startINT0-4096–4096
    stopINT0-4096–4096
    num_stepsINT0-4096–4096
    end_modeCOMBOInclusive2 options: Inclusive, Exclusive
    allow_uneven_stepsCOMBOFalse2 options: True, False

    Outputs (2)

    NameTypeDescription
    rangeINT
    range_sizesINT