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 expression progression logic and rounding #2

Merged
merged 1 commit into from
Dec 28, 2016

Conversation

rtkrruvinskiy
Copy link
Contributor

The expression progression logic manipulated the variable i in two ways:

  • direct manipulation in the body for the for loop
  • via the enumerate function, which would reset the value i every loop
    iteration, overwriting whatever the body of the loop did to the value of
    i

This caused evaluation bugs where parts of the expression were evaluated twice:

>>> datemath.dm('2016-12-28T10:00:00||-1d/d')
<Arrow [2016-12-26T00:00:00+00:00]>

The for loop is replaced with a while loop, and all changes to our position
in the expression buffer are now done explicitly in the body of the loop.

The expression progression logic manipulated the variable `i` in two ways:
- direct manipulation in the body for the `for` loop
- via the `enumerate` function, which would reset the value `i` every loop
  iteration, overwriting whatever the body of the loop did to the value of
  `i`

This caused evaluation bugs where parts of the expression were evaluated twice:
```python
>>> datemath.dm('2016-12-28T10:00:00||-1d/d')
<Arrow [2016-12-26T00:00:00+00:00]>
```

The `for` loop is replaced with a `while` loop, and all changes to our position
in the expression buffer are now done explicitly in the body of the loop.
@nickmaccarthy nickmaccarthy self-assigned this Dec 28, 2016
@nickmaccarthy
Copy link
Owner

Thank you taking the time to help fix this @rtkrruvinskiy ! Much appreciated!

@nickmaccarthy nickmaccarthy merged commit bdaf549 into nickmaccarthy:master Dec 28, 2016
@nickmaccarthy
Copy link
Owner

@rtkrruvinskiy , version 1.4.4 has been uploaded to pypi for for python 2x and python 3x. Let me know if you have any issues.

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

Successfully merging this pull request may close these issues.

2 participants