<s> import json <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> from bubbly . extractors import RGBExtractor <EOL> from bubbly . dr1 import bubble_params <EOL> def hide_axes ( ) : <EOL> plt . gca ( ) . get_xaxis ( ) . set_visible ( False ) <EOL> plt . gca ( ) . get_yaxis ( ) . set_visible ( False ) <EOL> def ex ( params ) : <EOL> rgb = RGBExtractor ( ) <EOL> rgb . shp = ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> p = list ( params ) <EOL> p [ - <NUM_LIT:1> ] *= <NUM_LIT> <EOL> return rgb . extract ( * p ) <EOL> def closest_bubble ( p ) : <EOL> bubbles = np . array ( bubble_params ( ) ) <EOL> l0 , b0 = bubbles [ : , <NUM_LIT:1> ] , bubbles [ : , <NUM_LIT:2> ] <EOL> d = np . hypot ( l0 - p [ <NUM_LIT:1> ] , b0 - p [ <NUM_LIT:2> ] ) <EOL> ind = np . argmin ( d ) <EOL> return bubbles [ ind ] , d [ ind ] <EOL> def main ( ) : <EOL> labels = json . load ( open ( '<STR_LIT>' ) ) <EOL> ind = np . argsort ( labels [ '<STR_LIT>' ] ) [ : : - <NUM_LIT:1> ] <EOL> scores = [ labels [ '<STR_LIT>' ] [ i ] for i in ind [ : <NUM_LIT:9> ] ] <EOL> images = [ ex ( labels [ '<STR_LIT>' ] [ i ] ) for i in ind [ : <NUM_LIT:9> ] ] <EOL> for i in range ( <NUM_LIT:9> ) : <EOL> p = labels [ '<STR_LIT>' ] [ ind [ i ] ] <EOL> b , d = closest_bubble ( p ) <EOL> print "<STR_LIT>" % ( d , p [ - <NUM_LIT:1> ] , b [ - <NUM_LIT:1> ] ) <EOL> ims = np . vstack ( np . hstack ( images [ i : i + <NUM_LIT:3> ] ) for i in [ <NUM_LIT:0> , <NUM_LIT:3> , <NUM_LIT:6> ] ) <EOL> plt . imshow ( ims , origin = '<STR_LIT>' ) <EOL> dx = images [ <NUM_LIT:0> ] . shape [ <NUM_LIT:0> ] <EOL> kw = { '<STR_LIT>' : '<STR_LIT>' } <EOL> plt . axhline ( dx , ** kw ) <EOL> plt . axhline ( dx * <NUM_LIT:2> , ** kw ) <EOL> plt . axvline ( dx , ** kw ) <EOL> plt . axvline ( dx * <NUM_LIT:2> , ** kw ) <EOL> for i in range ( <NUM_LIT:9> ) : <EOL> x = dx * ( i % <NUM_LIT:3> ) + dx / <NUM_LIT:10> <EOL> y = dx * ( i / <NUM_LIT:3> ) + <NUM_LIT> * dx / <NUM_LIT:10> <EOL> plt . annotate ( "<STR_LIT>" % scores [ i ] , xy = ( x , y ) , color = '<STR_LIT>' ) <EOL> hide_axes ( ) <EOL> plt . savefig ( '<STR_LIT>' ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
