Skip to content

Port changes to the number() routine in the micropython library to _number() #53

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

Merged
merged 9 commits into from
Jan 27, 2020
Merged

Port changes to the number() routine in the micropython library to _number() #53

merged 9 commits into from
Jan 27, 2020

Conversation

hybotix
Copy link

@hybotix hybotix commented Jan 22, 2020

This is a port of the changes I did to the number() routine in the micropython version of this library. I also found several errors in processing floats and negative numbers, which I fixed. This version is much more robust. I also fixed a problem with the "from adafruit_ht16k33 import..." line.

@hybotix
Copy link
Author

hybotix commented Jan 22, 2020

PyLint does not like me.

@hybotix
Copy link
Author

hybotix commented Jan 22, 2020

Done.

@kattni kattni requested a review from a team January 22, 2020 23:08
Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this. I've made some suggested changes that should help with it passing linting. I'm not sure why you changed it to import from matrix which imports from the base class (ht16k33) rather than just importing the ht16k33 class for better memory usage.

print("(2) places = {0}, dot = {1}, decimal = {2}, stnum = '{3}'".format(places, dot, decimal, stnum))

# Set decimal places, if number of decimal places is specified (decimal > 0)
if ((places > 0) and (decimal > 0) and (dot > 0) and (len(stnum[places:]) > decimal)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing pylint because of all the parenthesis and variable > 0 can be shortened to variable. I'd suggest changing this line to:
if places and decimal and dot and len(stnum[places:]) > decimal:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[code]if places and decimal and dot will be true as long as one of them is not zero. This is true for Python 3.7.3. I should be able to remove the parentheses without changing the meaning.

if self.debug:
print("(1) number = {0}, places = {1}, decimal = {2}, dot = {3}, stnum = '{4}'".format(number, places, decimal, dot, stnum))

if ((places <= 0) and (decimal > 0)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is failing pylint because of the parenthesis and variable > 0 can be shortened to variable. I'd suggest changing this line to:
if places <= 0 and decimal:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment on zero checks.

@hybotix
Copy link
Author

hybotix commented Jan 27, 2020 via email

@makermelissa
Copy link
Collaborator

Ok yeah, that makes sense. If pylint fails on that, you can add lines to disable certain checks with #pylint: disable-msg=[pylint-fail-code] and replace [pylint-fail-code] with the actual fail code.

@hybotix
Copy link
Author

hybotix commented Jan 27, 2020

Done! I will get better as I learn what PyLint expects.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more small thing with regards to some commented out duplicate code, but everything else looks good.

@@ -26,6 +26,7 @@
"""

from time import sleep
#from adafruit_ht16k33.ht16k33 import HT16K33
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor nitpick, can we remove this commented out line please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I would have nitpicked that too.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks

@makermelissa makermelissa merged commit e8ad143 into adafruit:master Jan 27, 2020
@hybotix hybotix deleted the port_number_change_from_micropython branch January 27, 2020 17:48
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jan 28, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_BME680 to 3.1.3 from 3.1.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BME680#18 from markpatterson27/upstream-issue-12

Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 4.1.0 from 4.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BNO055#30 from sjirwin/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_HT16K33 to 3.2.0 from 3.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#56 from makermelissa/set_digit_raw
  > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#55 from makermelissa/set_digit_raw
  > Merge pull request adafruit/Adafruit_CircuitPython_HT16K33#53 from hybotics/port_number_change_from_micropython

Updating https://github.com/adafruit/Adafruit_CircuitPython_LIS3MDL to 1.0.1 from 1.0.0:
  > Update README.rst

Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel_SPI to 0.3.3 from 0.3.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel_SPI#10 from caternuson/pypix

Updating https://github.com/adafruit/Adafruit_CircuitPython_PyPortal to 3.1.7 from 3.1.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_PyPortal#34 from colonwq/add_sdcheck

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 5.0.3 from 5.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#65 from dhalbert/update-dis

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Apple_Notification_Center to 0.8.2 from 0.8.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Apple_Notification_Center#4 from tannewt/remove_ble_mock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants