From 7b9b22aedf0b924e77c892ae68baf208974c6007 Mon Sep 17 00:00:00 2001 From: "S.M Hosseinirad" Date: Tue, 16 Aug 2022 07:30:12 +0430 Subject: [PATCH 1/5] Convert to package --- requirements.txt | 7 +++++++ README.md => rotations/README.md | 0 __init__.py => rotations/__init__.py | 0 mcrotations.py => rotations/mcrotations.py | 16 ++++++++-------- .../rotate_vector_collection.py | 2 +- rotations2d.py => rotations/rotations2d.py | 6 +++--- rotations3d.py => rotations/rotations3d.py | 4 ++-- {tests => rotations/tests}/__init__.py | 0 {tests => rotations/tests}/test_2d.py | 0 {tests => rotations/tests}/test_3d.py | 0 {tests => rotations/tests}/test_mcrotations.py | 0 .../tests}/test_rotate_vector_collection.py | 0 {tests => rotations/tests}/test_utilities.py | 0 .../vector_utilities.py | 4 ++-- setup.py | 9 +++++++++ 15 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 requirements.txt rename README.md => rotations/README.md (100%) rename __init__.py => rotations/__init__.py (100%) rename mcrotations.py => rotations/mcrotations.py (87%) rename rotate_vector_collection.py => rotations/rotate_vector_collection.py (98%) rename rotations2d.py => rotations/rotations2d.py (96%) rename rotations3d.py => rotations/rotations3d.py (97%) rename {tests => rotations/tests}/__init__.py (100%) rename {tests => rotations/tests}/test_2d.py (100%) rename {tests => rotations/tests}/test_3d.py (100%) rename {tests => rotations/tests}/test_mcrotations.py (100%) rename {tests => rotations/tests}/test_rotate_vector_collection.py (100%) rename {tests => rotations/tests}/test_utilities.py (100%) rename vector_utilities.py => rotations/vector_utilities.py (97%) create mode 100644 setup.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f3ad2dd --- /dev/null +++ b/requirements.txt @@ -0,0 +1,7 @@ +# Packages required for basic usage of `rotations` package +numpy +astropy + +# Packages required for unit tests +nose +coverage \ No newline at end of file diff --git a/README.md b/rotations/README.md similarity index 100% rename from README.md rename to rotations/README.md diff --git a/__init__.py b/rotations/__init__.py similarity index 100% rename from __init__.py rename to rotations/__init__.py diff --git a/mcrotations.py b/rotations/mcrotations.py similarity index 87% rename from mcrotations.py rename to rotations/mcrotations.py index 89ac195..d75d4b2 100644 --- a/mcrotations.py +++ b/rotations/mcrotations.py @@ -8,16 +8,16 @@ unicode_literals) import numpy as np from astropy.utils.misc import NumpyRNGContext -from vector_utilities import * -from rotate_vector_collection import rotate_vector_collection -from rotations2d import rotation_matrices_from_angles as rotation_matrices_from_angles_2d -from rotations3d import rotation_matrices_from_angles as rotation_matrices_from_angles_3d +from .vector_utilities import * +from .rotate_vector_collection import rotate_vector_collection +from .rotations2d import rotation_matrices_from_angles as rotation_matrices_from_angles_2d +from .rotations3d import rotation_matrices_from_angles as rotation_matrices_from_angles_3d -__all__=['random_rotation_3d', - 'random_rotation_2d', - 'random_perpendicular_directions', - 'random_unit_vectors_3d'] +#__all__=['random_rotation_3d', +# 'random_rotation_2d', +# 'random_perpendicular_directions', +# 'random_unit_vectors_3d'] __author__ = ['Duncan Campbell'] diff --git a/rotate_vector_collection.py b/rotations/rotate_vector_collection.py similarity index 98% rename from rotate_vector_collection.py rename to rotations/rotate_vector_collection.py index f581bde..d79f638 100644 --- a/rotate_vector_collection.py +++ b/rotations/rotate_vector_collection.py @@ -9,7 +9,7 @@ normalized_vectors, angles_between_list_of_vectors) -__all__=['rotate_vector_collection',] +#__all__=['rotate_vector_collection',] __author__ = ['Duncan Campbell', 'Andrew Hearin'] def rotate_vector_collection(rotation_matrices, vectors, optimize=False): diff --git a/rotations2d.py b/rotations/rotations2d.py similarity index 96% rename from rotations2d.py rename to rotations/rotations2d.py index 5f99456..57a969d 100644 --- a/rotations2d.py +++ b/rotations/rotations2d.py @@ -9,9 +9,9 @@ normalized_vectors, angles_between_list_of_vectors) -__all__=['rotation_matrices_from_angles', - 'rotation_matrices_from_vectors', - 'rotation_matrices_from_basis'] +#__all__=['rotation_matrices_from_angles', +# 'rotation_matrices_from_vectors', +# 'rotation_matrices_from_basis'] __author__ = ['Duncan Campbell', 'Andrew Hearin'] diff --git a/rotations3d.py b/rotations/rotations3d.py similarity index 97% rename from rotations3d.py rename to rotations/rotations3d.py index f8924f4..8b73dc8 100644 --- a/rotations3d.py +++ b/rotations/rotations3d.py @@ -9,8 +9,8 @@ normalized_vectors, angles_between_list_of_vectors) -__all__=['rotation_matrices_from_angles', 'rotation_matrices_from_vectors', 'rotation_matrices_from_basis', - 'vectors_between_list_of_vectors', 'vectors_normal_to_planes', 'project_onto_plane'] +#__all__=['rotation_matrices_from_angles', 'rotation_matrices_from_vectors', 'rotation_matrices_from_basis', +# 'vectors_between_list_of_vectors', 'vectors_normal_to_planes', 'project_onto_plane'] __author__ = ['Duncan Campbell', 'Andrew Hearin'] diff --git a/tests/__init__.py b/rotations/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to rotations/tests/__init__.py diff --git a/tests/test_2d.py b/rotations/tests/test_2d.py similarity index 100% rename from tests/test_2d.py rename to rotations/tests/test_2d.py diff --git a/tests/test_3d.py b/rotations/tests/test_3d.py similarity index 100% rename from tests/test_3d.py rename to rotations/tests/test_3d.py diff --git a/tests/test_mcrotations.py b/rotations/tests/test_mcrotations.py similarity index 100% rename from tests/test_mcrotations.py rename to rotations/tests/test_mcrotations.py diff --git a/tests/test_rotate_vector_collection.py b/rotations/tests/test_rotate_vector_collection.py similarity index 100% rename from tests/test_rotate_vector_collection.py rename to rotations/tests/test_rotate_vector_collection.py diff --git a/tests/test_utilities.py b/rotations/tests/test_utilities.py similarity index 100% rename from tests/test_utilities.py rename to rotations/tests/test_utilities.py diff --git a/vector_utilities.py b/rotations/vector_utilities.py similarity index 97% rename from vector_utilities.py rename to rotations/vector_utilities.py index 66a7a9e..f862527 100644 --- a/vector_utilities.py +++ b/rotations/vector_utilities.py @@ -6,8 +6,8 @@ unicode_literals) import numpy as np -__all__=['elementwise_dot', 'elementwise_norm', 'normalized_vectors', - 'angles_between_list_of_vectors'] +#__all__=['elementwise_dot', 'elementwise_norm', 'normalized_vectors', +# 'angles_between_list_of_vectors'] __author__ = ['Duncan Campbell', 'Andrew Hearin'] diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..dd41ea9 --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +from setuptools import setup + +setup( + name='rotations', + version='1.0.0', + packages=["rotations"], + install_requires=["numpy", "astropy"], + tests_require=["nose","coverage"], +) \ No newline at end of file From 1d0678a0dfd5e65bd6205a340857379e14391ead Mon Sep 17 00:00:00 2001 From: "S.M Hosseinirad" Date: Tue, 16 Aug 2022 07:33:47 +0430 Subject: [PATCH 2/5] Modify README --- README | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 0000000..35d6edc --- /dev/null +++ b/README @@ -0,0 +1,52 @@ +# Rotations + +This package contains functions to rotate collections of 2D and 3D vectors. + +Some of the functionality of this package is taken from the [Halotools](https://halotools.readthedocs.io/en/latest/) utilities sudmodule, reproduced here for convenience. + + +## Description + +This package contains tools to perform: + +* rotations of 3D vectors, +* rotations of 2D vectors, +* and monte carlo rotations of 2D and 3D vectors. + + +## Requirements + +In order to use the functions in this package, you will need the following python packages installed: + +* numpy +* astropy + + +## Installation + +It could be installable as: + +``` +pip install --user . +``` +Place this directory in your PYTHONPATH. The various functions can then be imported as, e.g.: + +``` +from rotations import rotate_vector_collection +``` + +or for 2- and 3-D specific functions, + +``` +from rotations.rotations3d import rotation_matrices_from_vectors +``` + +You can run the testing suite for this package using the [pytest](https://docs.pytest.org/en/latest/) framework by executing the following command in the package directory: + +``` +pytest +``` + + +contact: +duncanc@andrew.cmu.edu From d54a030a6a33444e78a6a355707f273e8e090841 Mon Sep 17 00:00:00 2001 From: "S.M Hosseinirad" Date: Tue, 16 Aug 2022 07:34:43 +0430 Subject: [PATCH 3/5] Modify README --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From eef9d38169470bbdc0726558c479f4c507c1d1dc Mon Sep 17 00:00:00 2001 From: smhr Date: Thu, 8 Sep 2022 22:57:38 +0430 Subject: [PATCH 4/5] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 35d6edc..8f09f12 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ It could be installable as: ``` pip install --user . ``` -Place this directory in your PYTHONPATH. The various functions can then be imported as, e.g.: +The various functions can then be imported as, e.g.: ``` from rotations import rotate_vector_collection From 24dbf989af99fa5f0980d0c9bddbb96c03871e47 Mon Sep 17 00:00:00 2001 From: "S.Mohammad Hosseinirad" Date: Thu, 8 Sep 2022 23:13:21 +0430 Subject: [PATCH 5/5] Convert to package --- rotations/mcrotations.py | 8 ++++---- rotations/rotate_vector_collection.py | 2 +- rotations/rotations2d.py | 6 +++--- rotations/rotations3d.py | 4 ++-- rotations/vector_utilities.py | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/rotations/mcrotations.py b/rotations/mcrotations.py index d75d4b2..fb54b01 100644 --- a/rotations/mcrotations.py +++ b/rotations/mcrotations.py @@ -14,10 +14,10 @@ from .rotations3d import rotation_matrices_from_angles as rotation_matrices_from_angles_3d -#__all__=['random_rotation_3d', -# 'random_rotation_2d', -# 'random_perpendicular_directions', -# 'random_unit_vectors_3d'] +__all__=['random_rotation_3d', + 'random_rotation_2d', + 'random_perpendicular_directions', + 'random_unit_vectors_3d'] __author__ = ['Duncan Campbell'] diff --git a/rotations/rotate_vector_collection.py b/rotations/rotate_vector_collection.py index d79f638..f581bde 100644 --- a/rotations/rotate_vector_collection.py +++ b/rotations/rotate_vector_collection.py @@ -9,7 +9,7 @@ normalized_vectors, angles_between_list_of_vectors) -#__all__=['rotate_vector_collection',] +__all__=['rotate_vector_collection',] __author__ = ['Duncan Campbell', 'Andrew Hearin'] def rotate_vector_collection(rotation_matrices, vectors, optimize=False): diff --git a/rotations/rotations2d.py b/rotations/rotations2d.py index 57a969d..5f99456 100644 --- a/rotations/rotations2d.py +++ b/rotations/rotations2d.py @@ -9,9 +9,9 @@ normalized_vectors, angles_between_list_of_vectors) -#__all__=['rotation_matrices_from_angles', -# 'rotation_matrices_from_vectors', -# 'rotation_matrices_from_basis'] +__all__=['rotation_matrices_from_angles', + 'rotation_matrices_from_vectors', + 'rotation_matrices_from_basis'] __author__ = ['Duncan Campbell', 'Andrew Hearin'] diff --git a/rotations/rotations3d.py b/rotations/rotations3d.py index 8b73dc8..f8924f4 100644 --- a/rotations/rotations3d.py +++ b/rotations/rotations3d.py @@ -9,8 +9,8 @@ normalized_vectors, angles_between_list_of_vectors) -#__all__=['rotation_matrices_from_angles', 'rotation_matrices_from_vectors', 'rotation_matrices_from_basis', -# 'vectors_between_list_of_vectors', 'vectors_normal_to_planes', 'project_onto_plane'] +__all__=['rotation_matrices_from_angles', 'rotation_matrices_from_vectors', 'rotation_matrices_from_basis', + 'vectors_between_list_of_vectors', 'vectors_normal_to_planes', 'project_onto_plane'] __author__ = ['Duncan Campbell', 'Andrew Hearin'] diff --git a/rotations/vector_utilities.py b/rotations/vector_utilities.py index f862527..66a7a9e 100644 --- a/rotations/vector_utilities.py +++ b/rotations/vector_utilities.py @@ -6,8 +6,8 @@ unicode_literals) import numpy as np -#__all__=['elementwise_dot', 'elementwise_norm', 'normalized_vectors', -# 'angles_between_list_of_vectors'] +__all__=['elementwise_dot', 'elementwise_norm', 'normalized_vectors', + 'angles_between_list_of_vectors'] __author__ = ['Duncan Campbell', 'Andrew Hearin']