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

Latex: ZeroDivisionError #7

Open
dahoo opened this issue Jun 11, 2015 · 3 comments
Open

Latex: ZeroDivisionError #7

dahoo opened this issue Jun 11, 2015 · 3 comments

Comments

@dahoo
Copy link
Collaborator

dahoo commented Jun 11, 2015

Latex compilation writes several times to the PDF file, which causes an watchdog update each time. The result is a ZeroDivisionError with an empty document:

2015-06-11 12:17:06 -   Calculating average word length ...
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/local/lib/python2.7/dist-packages/watchdog/observers/api.py", line 199, in run
    self.dispatch_events(self.event_queue, self.timeout)
  File "/usr/local/lib/python2.7/dist-packages/watchdog/observers/api.py", line 368, in dispatch_events
    handler.dispatch(event)
  File "/usr/local/lib/python2.7/dist-packages/watchdog/events.py", line 330, in dispatch
    _method_map[event_type](event)
  File "tracker.py", line 58, in on_modified
    self.analyze_file_event(event)
  File "tracker.py", line 67, in analyze_file_event
    self.analyze_paper()
  File "tracker.py", line 71, in analyze_paper
    self.calculate_statistics()
  File "tracker.py", line 220, in calculate_statistics
    avg_len = float(self.total_word_len) / float(self.num_words)
ZeroDivisionError: float division by zero

I see 3 possible solutions:

  • Delay parsing of file for some seconds
  • Group changes, i.e. changes in a certain window, say 30 seconds, are considered as one change
  • Abort parsing of file if the number of words is 0 but was more before
@Kadrian
Copy link
Owner

Kadrian commented Jun 11, 2015

I think number 3 will be the best solution if we can catch this by checking number of words != 0. Go ahead and create a pull-request if you can test this and eliminate this error. I won't be able to test it with my Latex compiler (Texpax).

@dahoo
Copy link
Collaborator Author

dahoo commented Jun 11, 2015

Well, I found out that one compilation results in ~20 changes... I solved it waiting for 10 seconds after the first change and omitting all changes in the following 20 seconds. I'll file a pull request later.

@Kadrian
Copy link
Owner

Kadrian commented Jun 11, 2015

I don't think that limiting us to one possible save every 20 seconds is a good choice. What about option 3?

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

No branches or pull requests

2 participants