Skip to content

Commit

Permalink
Removing remaining uses of old_div, since the occurrences should be t…
Browse files Browse the repository at this point in the history
  • Loading branch information
apacha committed Oct 4, 2018
1 parent b5484af commit 0ae34e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
5 changes: 2 additions & 3 deletions scripts/add_staffline_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from __future__ import division
from builtins import zip
from builtins import range
from past.utils import old_div
import argparse
import logging
import os
Expand Down Expand Up @@ -420,7 +419,7 @@ def main(args):
uss_width = tss.width
# We use 1.5, so that large noteheads
# do not "hang out" of the staffspace.
uss_height = int(old_div(tss.height, 1.2))
uss_height = int(tss.height / 1.2)
# Shift because of height downscaling:
uss_top += tss.height - uss_height
uss_mask = tss.mask[:uss_height, :] * 1
Expand All @@ -446,7 +445,7 @@ def main(args):
lss_top = bss.bottom # + max(bsl_heights)
lss_left = bss.left
lss_width = bss.width
lss_height = int(old_div(bss.height, 1.2))
lss_height = int(bss.height / 1.2)
lss_mask = bss.mask[:lss_height, :] * 1

uid = CropObject.build_uid(dataset_namespace, docname, next_objid)
Expand Down
23 changes: 9 additions & 14 deletions scripts/analyze_agreement.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"""
from __future__ import print_function, unicode_literals
from __future__ import division
from past.utils import old_div
import argparse
import collections
import logging
Expand Down Expand Up @@ -121,7 +120,6 @@ def pixel_metrics(truth, prediction):
' p={1}'.format(truth.bounding_box,
prediction.bounding_box))


tt, tl, tb, tr = intersection_truth
pt, pl, pb, pr = intersection_pred
crop_truth = truth.mask[tt:tb, tl:tr]
Expand All @@ -141,8 +139,8 @@ def pixel_metrics(truth, prediction):
recall = 0.0
precision = 0.0
else:
recall = old_div(n_common, n_truth)
precision = old_div(n_common, n_pred)
recall = n_common / n_truth
precision = n_common / n_pred

if (recall == 0) or (precision == 0):
fscore = 0
Expand Down Expand Up @@ -202,7 +200,7 @@ def align_cropobjects(truth, prediction, fscore=None):
# it only acts as a tie-breaker in case one prediction overlaps
# to the same degree multiple truth objects (e.g. a single sharp
# in a key signature).
closest_truth_distance = [fscore[ct,j]
closest_truth_distance = [fscore[ct, j]
for j, ct in enumerate(closest_truths)]
equidistant_closest_truths = [[i for i, x in enumerate(fscore[:, j])
if x == ct]
Expand All @@ -228,7 +226,7 @@ def align_cropobjects(truth, prediction, fscore=None):


def rpf_given_alignment(alignment, r, p,
n_not_aligned = 0,
n_not_aligned=0,
strict_clsnames=True,
truths=None, predictions=None):
if strict_clsnames:
Expand Down Expand Up @@ -398,10 +396,9 @@ def main(args):
])))
print('Truth, not aligned:\n{0}'.format('\n'.join(['({0}: {1})'.format(truth[t].objid, truth[t].clsname)
for t in truth_not_aligned])))
print('Preds, not aligned:\n{0}'.format('\n'.join(['({0}: {1})'.format(prediction[p].objid, prediction[p].clsname)
for p in preds_not_aligned])))


print(
'Preds, not aligned:\n{0}'.format('\n'.join(['({0}: {1})'.format(prediction[p].objid, prediction[p].clsname)
for p in preds_not_aligned])))

##########################################################################
# Check if the alignment is a pairing -- find truth objects
Expand All @@ -420,8 +417,8 @@ def main(args):
print('Truth multi-aligned CropObject classes:\n{0}'
''.format(pprint.pformat(
{(truth[t].objid, truth[t].clsname): [(p.objid, p.clsname)
for p in t_aln_dict[t]]
for t in multiple_truths_aln_dict})))
for p in t_aln_dict[t]]
for t in multiple_truths_aln_dict})))

##########################################################################
# Check if the aligned objects have the same classes
Expand All @@ -435,8 +432,6 @@ def main(args):
''.format(t.objid, t.clsname, p.objid, p.clsname)
for t, p in different_clsnames_pairs])))



_end_time = time.clock()
logging.info('analyze_agreement.py done in {0:.3f} s'.format(_end_time - _start_time))

Expand Down
3 changes: 1 addition & 2 deletions scripts/analyze_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"""
from __future__ import print_function, unicode_literals
from __future__ import division
from past.utils import old_div
import argparse
import collections
import json
Expand Down Expand Up @@ -134,7 +133,7 @@ def main(args):
_n_parsed_cropobjects += len(cs)
if i % 10 == 0 and i > 0:
_time_parsing = time.clock() - _start_time
_cropobjects_per_second = old_div(_n_parsed_cropobjects, _time_parsing)
_cropobjects_per_second = _n_parsed_cropobjects / _time_parsing
logging.info('Parsed {0} cropobjects in {1:.2f} s ({2:.2f} objs/s)'
''.format(_n_parsed_cropobjects,
_time_parsing, _cropobjects_per_second))
Expand Down

0 comments on commit 0ae34e3

Please sign in to comment.