mkaz / termgraph

a python command-line tool which draws basic graphs in the terminal
MIT License
3.15k stars 165 forks source link

ValueError: math domain error if value == 0 #90

Open sgelb opened 3 years ago

sgelb commented 3 years ago

If termgraph is used as a module and a value is 0, a ValueError: math domain error is thrown by math.log in utils.py::cvt_to_readable(num) here: https://github.com/mkaz/termgraph/blob/09e17cc3510b62969fc12075dd698817357a5a93/termgraph/utils.py#L16

Problem is that there is there is no zero check for num. This is done correctly in termgraph.py::cvt_to_readable(num): https://github.com/mkaz/termgraph/blob/4aa3b6711136fb0232bf149a64afa4b49c2b28f3/termgraph/termgraph.py#L197

frankbryce commented 3 years ago

I made a pull request to fix this.