From d3c68431fb8a1eb444d5635faa13fd4ffb0073f1 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Mon, 15 Mar 2021 15:37:05 +0530 Subject: Put sample code in separate function. * contrib/cone-vector.py: Call sample_code when run as a script. (sample_code): New function. --- contrib/cone-vector.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/cone-vector.py b/contrib/cone-vector.py index c099879..8d1877e 100644 --- a/contrib/cone-vector.py +++ b/contrib/cone-vector.py @@ -67,9 +67,13 @@ def random_vector_on_spherical_cap(axis, maximum_planar_angle): x[-1] = cos(planar_angle) return rotate_from_nth_canonical(x, axis) -# Sample code exercising the above functions -dim = 100 -maximum_planar_angle = pi/3 -axis = ones(dim) -axis = axis/norm(axis) -print(random_vector_on_spherical_cap(axis, maximum_planar_angle)) +def sample_code(): + """Run some sample code testing the defined functions.""" + dim = 100 + maximum_planar_angle = pi/3 + axis = ones(dim) + axis = axis/norm(axis) + print(random_vector_on_spherical_cap(axis, maximum_planar_angle)) + +if __name__ == '__main__': + sample_code() -- cgit v1.2.3