Nodes/ComfyUI-LoadAnim-Adv/Aggregate Number List
ComfyUI Node

Aggregate Number List

Turn a list of numbers into the one number you actually wanted

By SineSwiper·Created 7 months ago·Updated 7 months ago· 0
Aggregate Number List
  • numbers
  • float
  • int
  • count
functionaverage

Your directory loader just handed you a list of FPS values - one per file - and the node you're feeding wants a single number. Somewhere in the middle of "list of numbers" and "one number" sits a gap that most workflows paper over with a calculator and a hardcoded value. Aggregate Number List is that gap, filled in. It's a tiny reduce function from SineSwiper's LoadAnim-Adv pack: take a list of numbers, apply a function, get one number (plus an int version and a count).

What it does

Input numbers (a list of NUMBER/FLOAT/INT - which in ComfyUI means it has to come from a node that emits lists, usually marked with a multi-box icon, or continued along a list-processing chain), plus a function dropdown with eight options:

  • average, median, sum, prod, min, max, first, last

The README's canonical example is averaging FPS values from multiple files - exactly the case the directory loader produces: a list of per-file FPS where the flattened output is already averaged for you but the un-flattened list is not. This node is the manual version, and it's more honest than the automatic one.

Three outputs: float (the result as a float), int (rounded), and count (how many numbers went in). Handy because count is genuinely useful downstream - it's how you'd know "I processed 14 files" without counting list entries by hand.

How it works

Under the hood it's numpy: the list becomes a float array, the function applies via numpy's average/median/sum/prod/min/max, and the result comes back as both float and rounded int. first and last skip the math entirely and just grab the edge of the list. Empty input returns (0.00, 0, 0) rather than erroring, which is a sensible bit of defensiveness.

When you'd reach for it

  • Averaging FPS from a multi-file load before wiring into a scheduler.
  • Summing frame counts to budget total frames against VRAM.
  • Getting max/min of a list of batch sizes or seeds for validation.
  • Reducing any list output that a non-list node can't accept - this is the classic "list-to-single" adapter.

Inputs and outputs

Inputs: numbers (required, list), function (enum, default average). Outputs: float (FLOAT), int (INT), count (INT). Short and to the point.

Installing

Part of ComfyUI-LoadAnim-Adv by SineSwiper. ComfyUI Manager → search "LoadAnim", or:

cd ComfyUI/custom_nodes
git clone https://github.com/SineSwiper/ComfyUI-LoadAnim-Adv.git

Restart ComfyUI. No models; dependencies are just torch, numpy, Pillow.

Gotchas

  • The input must actually be a list. A single scalar won't aggregate - you'll get a 1-element list and a somewhat pointless average. That's on your upstream wiring, not the node.
  • int is a straight round(). If you average 10.5 fps you get int = 10 (banker's rounding aside, it rounds to nearest). Use float if precision matters.
  • first/last ignore everything but the edge - useful, but easy to confuse with min/max at a glance. Read the dropdown.

It's not going to win any awards, but the day you're staring at a list of 40 FPS values and a node that wants one number, this is the difference between a clean graph and a calculator.

CategoryLoadAnimAdv/FlattenUtils

Inputs (2)

NameTypeDefaultDescription
numbersNUMBER,FLOAT,INTNumber set to reduce. Must have come from a node that supports list processing (usually marked with a multi-box icon), or was continued from a similar node in a chain.
functionCOMBOaverageFunction to apply to the numbers.

Outputs (3)

NameTypeDescription
floatFLOATThe aggregated number, as a float.
intINTThe aggregated number, as an integer.
countINTThe count of numbers from the initial input.