itsdawei / dpvis

A simple and flexible visualization library for dynamic programs
https://dpvis.readthedocs.io/en/latest/
MIT License
4 stars 1 forks source link

Max/Min Function Bug Fix and Updates #42

Open Tianyu659 opened 10 months ago

Tianyu659 commented 10 months ago

Description

specifically:

  1. users can now explicitly compare constants using the constants parameter
  2. users can call max with only indices if they don't really wish to make changes to the elements before comparing
  3. current code using None as index for a constant in elements still work. see the updated tests (below) & all the demos still have the same behavior, i believe

image

so if users prefer the None way to do it it would still work. I mainly wanted to provide an option to call the max function with less confusion when comparing existing elements without transformation. so arguably

dp.max([0,1], constants=[c[0]])
dp.max([i for i in range(50)])

could be more straightforward than

dp.max([0, 1, None], [dp[0], dp[1], c[0]])
dp.max([i for i in range(50)], [dp[i] for i in range50]])

TODO

TESTING

Questions

none atm

Status

Tianyu659 commented 10 months ago

@ramirodcv i was fixing something in min/max (see description) and end up making some updates to the function (backward compatible with current demos). would be great if you can take a look at lmk what you think since this was your feature. @itsdawei too

itsdawei commented 10 months ago

What is the expected behavior when a constant is the best element?

Tianyu659 commented 10 months ago

What is the expected behavior when a constant is the best element?

best constant value returned, nothing highlighted, involved array elements Op.READ

itsdawei commented 10 months ago

What is the expected behavior when a constant is the best element?

best constant value returned, nothing highlighted, involved array elements Op.READ

What does "involved array elements Op.READ" mean?

Tianyu659 commented 10 months ago

What is the expected behavior when a constant is the best element?

best constant value returned, nothing highlighted, involved array elements Op.READ

What does "involved array elements Op.READ" mean?

oh any involved array elements will show up in the READ operation list. they are READ and this is recorded