Files
ltdrdata-ComfyUI-Impact-Pack/modules
kamnxtandDr.Lt.Data 36fbaab563 Improve wildcards and fix a bug (#319)
* Improve wildcards and fix a bug

This commit fixes two issues with wildcards:

- Using a single count value no longer worked due to .strip() being
  called on a None value from matching the upper range,
  when using a wildcard like {2$$a|b|c},
  while {2-2$$a|b|c} worked fine. Added a check to fix that.

- Choosing options was implemented in an odd way. The code would choose
  up to `count` values, then put them in a `set` to prevent duplicates.
  Then retry up to 10 times to get values in case the correct count
  wasn't reached. This had a few issues: {2$$a|a|b} would always choose
  "b a", always in this order! However, {2$$1::a|a|b}, which should be
  identical, gives either "a a" or "b a"!

- When the number of items to choose was more than the count of items to
  choose, the items would be returned in the original order, meaning for
  example {3-6$$a|b|c|d} returns "a b c d" way more often than it
  should. This is changed to shuffle the order when choosing all the
  items.

- As NumPy already had a way to choose N items without replacement and
  with weights, the code has been changed to use a NumPy Generator. This
  means previous seeds are no longer compatible, but also means we don't
  re-seed the built-in Python `random` generator.

- I have also added a "ImpactWildcardUnprocessed" node, in order to have
  a multiline text input node that doesn't do ComfyUI's built in
  wildcard replacement, so it's possible to put a prompt in a separate
  node from the WildcardProcessor (or have a few ones to connect
  manually). Due to the way things are processed both on the JS side and
  the backend side, sadly concatenating text for use in wildcards
  doesn't work yet.

* fix: random_gen.shuffle is side-effect function

* version marker

---------

Co-authored-by: Dr.Lt.Data <dr.lt.data@gmail.com>
2023-12-29 23:41:04 +09:00
..