With the impressive test results from the previous recipe, this recipe will focus on rewriting some of the smaller functions in asa.py
using NumPy. We will start with the smaller, more manageable find_neighbor_indices
function as a prototype for changes to the main
function.
The following steps will walk you through this recipe:
First, add the
@profile
decorator to thefind_neighbor_indices
function inasa.py
:@profile def find_neighbor_indices(points, radii, probe, k):
We will use
line_profile
to benchmark the originalfind_neighbor_indices
function:python kernprof.py -l asa_np_v1.py "1R0R.pdb"
The results are shown in the following command-line output, and the computed result matches the reference value:
12114.7 angstrom squared. Wrote profile results to asa_np_v1.py.lprof
We use
line_profiler
again to visualize the results:python -m line_profiler...