Skip to content

Commit

Permalink
Fix lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Oct 28, 2023
1 parent c71bccf commit 9d644d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
28 changes: 13 additions & 15 deletions lute/book/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def get_status_distribution(book):
Does a full render of the next 20 pages in a book
to calculate the distribution.
"""
start_text_index = 0
txindex = 0

curr_tx_id = book.current_tx_id
if curr_tx_id != 0 and curr_tx_id is not None:
if (book.current_tx_id or 0) != 0:
for t in book.texts:
if t.id == curr_tx_id:
if t.id == book.current_tx_id:
break
start_text_index += 1
txindex += 1

# Get the next 20 pages, a good enough sample.
end_ind = start_text_index + 20
texts = book.texts[start_text_index:end_ind]
paras = [ get_paragraphs(t) for t in texts ]
paras = [
get_paragraphs(t) for t in
# Next 20 pages, a good enough sample.
book.texts[txindex:txindex + 20]
]

def flatten_list(nested_list):
result = []
Expand All @@ -33,11 +33,10 @@ def flatten_list(nested_list):
else:
result.append(item)
return result
sentences = flatten_list(paras)
text_items = []
for s in sentences:
sent_words = [ti for ti in s.textitems if ti.is_word]
text_items.extend(sent_words)
for s in flatten_list(paras):
text_items.extend(s.textitems)
text_items = [ti for ti in text_items if ti.is_word]

statterms = {
0: [],
Expand All @@ -54,8 +53,7 @@ def flatten_list(nested_list):
statterms[ti.wo_status or 0].append(ti.text_lc)

stats = {}
for statusval in statterms.keys():
allterms = statterms[statusval]
for statusval, allterms in statterms.items():
uniques = list(set(allterms))
statterms[statusval] = uniques
stats[statusval] = len(uniques)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/book/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
TokenCoverage tests.
"""

import pytest
from lute.db import db
from lute.term.model import Term, Repository
from lute.book.stats import get_status_distribution
Expand Down

0 comments on commit 9d644d4

Please sign in to comment.