Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for exact specification of plot height. #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

neighthan
Copy link
Contributor

@neighthan neighthan commented Jul 1, 2019

Fixes #26, fixes #25.

This changes a bit of the logic for making the plot, some of which wasn't really necessary but made it easier / less confusing for me to work on it. ratio is the reciprocal of what it was before (it's now the change in y when you move up one row in the plot). The plot is stored in reverse order compared to before when in list form (e.g. result[0] is now the bottom row of the plot instead of the top one; I reverse the rows before joining them into the final plot string to make up for this). The actual change is a rework to how we convert from the data space to the row space of the plot which makes it (IMHO) less complex (removes max2 and min2) and easy to guarantee exactly what the height is.

Caveats

  • I didn't understand why max2 and min2 were needed before instead of working with maximum and minimum directly, as I do in this version. Is there some drawback to the method I use here that I'm missing?
  • I also wasn't quite clear on when you wanted to use '┼' vs '┤'; I think that part might not be the same now. I should be able to update that quickly if you can explain to me when you want '┼' used (it seems you use it for the y-value of the first data point, which I kept, but I wasn't clear on the second condition for it).

(#28 should be merged before this one, which starts from the cleaned up Python code; I was working on a few different things in parallel, but it got to be a pain to have all the PRs completely independent. Just look at the second commit to see the changes that this PR introduces).

This removes a handful of unnecessary uses of `abs`, `float`, and `int` and also puts in a check to ensure that the maximum value for the plot is greater than the minimum value. No functionality is changed here.
This changes a bit of the logic for making the plot, some of which wasn't really necessary but made it easier / less confusing for me to work on it. `ratio` is the reciprocal of what it was before (it's now the change in y when you move up one row in the plot). The plot is stored in reverse order compared to before when in list form (e.g. `result[0]` is now the bottom row of the plot instead of the top one; I reverse the rows before joining them into the final plot string to make up for this). The actual change is a rework to how we convert from the data space to the row space of the plot which makes it (IMHO) less complex (removes `max2` and `min2`) and easy to guarantee exactly what the height is. Admittedly, I'm not sure what the thought process was behind the old method, so there may be some drawback that I haven't considered.
@neighthan
Copy link
Contributor Author

This wasn't exactly intended to fix #25, but I believe it does (certainly in my tests).

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 3069095 on neighthan:height_fix into 714e057 on kroitor:master.

@neighthan
Copy link
Contributor Author

This should give a merge conflict if #27 is merged first; doing plot_string = '\n'.join([''.join(row) for row in result[::-1]]) is the only part of that which could be easy to miss (reversing result when creating the string before adding the title).

@kroitor kroitor self-assigned this Jul 13, 2019
@kroitor
Copy link
Owner

kroitor commented Jul 13, 2019

@neighthan hey ) Pardon for a long wait, didn't really have the time to dive into it thoughtfully (was mostly occupied with ccxt), but hope to get to it asap! Thx again for your involvement! Appreciate it very much!

@gamesguru
Copy link

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Height cannot be exactly configured Max/min values not reached
4 participants