aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2021-03-15 15:37:05 +0530
committerArun Isaac2021-03-15 15:37:05 +0530
commitd3c68431fb8a1eb444d5635faa13fd4ffb0073f1 (patch)
treeb2f974d41011f581697bf644b5c8ee7e486a5c75
parent2b89e25cc18cd82df1a3720e7e4739b007f14879 (diff)
downloadnsmc-d3c68431fb8a1eb444d5635faa13fd4ffb0073f1.tar.gz
nsmc-d3c68431fb8a1eb444d5635faa13fd4ffb0073f1.tar.lz
nsmc-d3c68431fb8a1eb444d5635faa13fd4ffb0073f1.zip
Put sample code in separate function.
* contrib/cone-vector.py: Call sample_code when run as a script. (sample_code): New function.
-rw-r--r--contrib/cone-vector.py16
1 files 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()