{"action":"created","issue":{"url":"https://api.github.com/repos/hgrecco/pint/issues/194","labels_url":"https://api.github.com/repos/hgrecco/pint/issues/194/labels{/name}","comments_url":"https://api.github.com/repos/hgrecco/pint/issues/194/comments","events_url":"https://api.github.com/repos/hgrecco/pint/issues/194/events","html_url":"https://github.com/hgrecco/pint/issues/194","id":45480080,"number":194,"title":"Compare quantity to zero should not raise ValueError","user":{"login":"david-zwicker","id":5444873,"avatar_url":"https://avatars.githubusercontent.com/u/5444873?v=3","gravatar_id":"","url":"https://api.github.com/users/david-zwicker","html_url":"https://github.com/david-zwicker","followers_url":"https://api.github.com/users/david-zwicker/followers","following_url":"https://api.github.com/users/david-zwicker/following{/other_user}","gists_url":"https://api.github.com/users/david-zwicker/gists{/gist_id}","starred_url":"https://api.github.com/users/david-zwicker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-zwicker/subscriptions","organizations_url":"https://api.github.com/users/david-zwicker/orgs","repos_url":"https://api.github.com/users/david-zwicker/repos","events_url":"https://api.github.com/users/david-zwicker/events{/privacy}","received_events_url":"https://api.github.com/users/david-zwicker/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2014-10-10T13:26:34Z","updated_at":"2015-12-22T03:42:01Z","closed_at":"2015-12-22T03:42:01Z","body":"Currently, pint raises a ValueError if a quantity with a unit is compared to a plain number. This is of course the correct behavior, but I propose that an exception can be made for the special case of comparing a quantity with zero. In this case, the comparison can be resolved for arbitrary units. An example could read:\r\n\r\n    >>> import pint\r\n    >>> ureg = pint.UnitRegistry()\r\n    >>> a = 1 * ureg.meter\r\n    >>> a > 1\r\n    Traceback (most recent call last):\r\n      File \"<stdin>\", line 1, in <module>\r\n      File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pint/quantity.py\", line 592, in <lambda>\r\n        __gt__ = lambda self, other: self.compare(other, op=operator.gt)\r\n      File \"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pint/quantity.py\", line 579, in compare\r\n        raise ValueError('Cannot compare Quantity and {0}'.format(type(other)))\r\n    ValueError: Cannot compare Quantity and <type 'int'>\r\n    >>> a > 0\r\n    True\r\n\r\nNote the last line, where I changed the result to what I would pint expect to return."},"comment":{"url":"https://api.github.com/repos/hgrecco/pint/issues/comments/166497519","html_url":"https://github.com/hgrecco/pint/issues/194#issuecomment-166497519","issue_url":"https://api.github.com/repos/hgrecco/pint/issues/194","id":166497519,"user":{"login":"hgrecco","id":278566,"avatar_url":"https://avatars.githubusercontent.com/u/278566?v=3","gravatar_id":"","url":"https://api.github.com/users/hgrecco","html_url":"https://github.com/hgrecco","followers_url":"https://api.github.com/users/hgrecco/followers","following_url":"https://api.github.com/users/hgrecco/following{/other_user}","gists_url":"https://api.github.com/users/hgrecco/gists{/gist_id}","starred_url":"https://api.github.com/users/hgrecco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgrecco/subscriptions","organizations_url":"https://api.github.com/users/hgrecco/orgs","repos_url":"https://api.github.com/users/hgrecco/repos","events_url":"https://api.github.com/users/hgrecco/events{/privacy}","received_events_url":"https://api.github.com/users/hgrecco/received_events","type":"User","site_admin":false},"created_at":"2015-12-22T03:42:01Z","updated_at":"2015-12-22T03:42:01Z","body":"I am closing this now. Feel free to reopen."}}