Skip to content

Commit

Permalink
Merge pull request #185 from FanwangM/scale_trans_doc
Browse files Browse the repository at this point in the history
Add information about accessing translation and scaling
  • Loading branch information
FanwangM committed Sep 2, 2022
2 parents 6d287bc + 48edbdc commit 6efd8e9
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 8 deletions.
74 changes: 74 additions & 0 deletions doc/notebooks/Quick_Start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,80 @@
"print(\"Matrix B (after translation and scaling) = \")\n",
"print(result.new_b)"
]
},
{
"cell_type": "markdown",
"id": "6163449e",
"metadata": {},
"source": [
"### Accessing Scaling, Translation Related Information"
]
},
{
"cell_type": "markdown",
"id": "171e4d70",
"metadata": {},
"source": [
"In order to access the scaling factor of the initial two input matrices, we can use `_scale_array` function in `utils` module."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "09d4f828",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The scaling factor is 0.8623410931853571.\n"
]
}
],
"source": [
"# accessing the scaling factor when preparing two input matrices\n",
"from procrustes.utils import _scale_array\n",
"\n",
"# array_a is scaled to match array_b's norm and the norm of $a$ will be equal norm of $b$\n",
"scaled_a, scaling_factor = _scale_array(a, b)\n",
"# print(f\"The scaled matrix $a$ is {scaled_a}.\")\n",
"print(f\"The scaling factor is {scaling_factor}.\")"
]
},
{
"cell_type": "markdown",
"id": "fc78f6d5",
"metadata": {},
"source": [
"The user may also want to get the translation matrix or the translated matrix. This can be achieved by using `_translate_array` function in `utils` module."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "0efc68a5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The centroid is [-0.36907112 -1.20438156 -0.25281312 -0.3612893 -1.00236417 -0.150441\n",
" -0.93179808].\n"
]
}
],
"source": [
"# accessing the translation matrix\n",
"from procrustes.utils import _translate_array\n",
"\n",
"# rray_a is translated to centroid of array_b\n",
"# the centroid of translated $a$ will centroid with the centroid $b$\n",
"trans_array_a, centroid = _translate_array(a, b)\n",
"# print(f\"The translated array $a$ is {trans_array_a}.\")\n",
"print(f\"The centroid is {centroid}.\")"
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy>=1.21.5
numpy>=1.19.5
scipy>=1.5.0
pytest>=5.4.3
sphinx>=2.3.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ def get_readme():
'Topic :: Scientific/Engineering :: Chemistry',
'Intended Audience :: Science/Research',
],
install_requires=["numpy>=1.18.5", "scipy>=1.5.0", "pytest>=5.4.3", "sphinx>=2.3.0"],
install_requires=["numpy>=1.19.5", "scipy>=1.5.0", "pytest>=5.4.3", "sphinx>=2.3.0"],
)
8 changes: 2 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ envlist = py36, py37, py38, py39, py310, rst_linux, rst_mac, readme, rst, linter

[testenv]
deps =
pytest
-r{toxinidir}/requirements.txt
pytest-cov
coverage>=4.2
numpy
scipy
sphinx
commands =
# coverage run --rcfile=tox.ini -m pytest tests
python -m pip install --upgrade pip
Expand Down Expand Up @@ -66,8 +63,7 @@ commands = {[testenv:rst_linux]commands}

[testenv:linters]
deps =
numpy
scipy
-r{toxinidir}/requirements.txt
pytest
flake8==4.0.1
flake8-docstrings==1.6.0
Expand Down

0 comments on commit 6efd8e9

Please sign in to comment.