Add loan-advisor-agent (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +29 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-bool-data.txt +100 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-double-data.txt +100 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-int-data.txt +100 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-uint-data.txt +100 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test__plotutils.py +91 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test__procrustes.py +116 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_distance.py +2287 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_hausdorff.py +199 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_kdtree.py +1536 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_qhull.py +1311 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_slerp.py +465 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_spherical_voronoi.py +358 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__init__.py +31 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/__init__.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rigid_transform.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rigid_transform_xp.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation.cpython-312.pyc +3 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_groups.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_spline.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_xp.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/rotation.cpython-312.pyc +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform.py +1947 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_cy.cp312-win_amd64.dll.a +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_cy.cp312-win_amd64.pyd +3 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_xp.py +448 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation.py +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_cy.cp312-win_amd64.dll.a +0 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_cy.cp312-win_amd64.pyd +3 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_groups.py +140 -0
- loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_spline.py +465 -0
.gitattributes
CHANGED
|
@@ -633,3 +633,32 @@ loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_ckdtree.cp312-win_amd6
|
|
| 633 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_distance_pybind.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 634 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_distance_wrap.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 635 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_qhull.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 633 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_distance_pybind.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 634 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_distance_wrap.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 635 |
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/_qhull.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 636 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 637 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_cy.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 638 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_cy.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 639 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/__pycache__/_basic.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 640 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_ellip_harm_2.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 641 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_gufuncs.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 642 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_specfun.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 643 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_special_ufuncs.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 644 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_ufuncs.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 645 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/_ufuncs_cxx.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 646 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/special/cython_special.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 647 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_continuous_distns.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 648 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_distn_infrastructure.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 649 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_distribution_infrastructure.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 650 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_morestats.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 651 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_mstats_basic.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 652 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_multivariate.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 653 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_qmc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 654 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_resampling.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 655 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/__pycache__/_stats_py.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 656 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_ansari_swilk_statistics.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 657 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_biasedurn.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 658 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_qmc_cy.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 659 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_qmvnt_cy.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 660 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_rcont/rcont.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 661 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_sobol.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 662 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_stats.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 663 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_stats_pythran.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 664 |
+
loan-advisor-agent/.venv/Lib/site-packages/scipy/stats/_unuran/unuran_wrapper.cp312-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cityblock-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.2420590e+01 3.3246607e+01 3.0526910e+01 3.5166573e+01 3.1868301e+01 3.6025002e+01 3.2513623e+01 3.6557796e+01 3.3752212e+01 3.4422130e+01 3.2526018e+01 3.2581161e+01 3.3743555e+01 3.6960777e+01 3.4225270e+01 3.2965308e+01 3.4591031e+01 3.4204203e+01 3.4678123e+01 3.5728720e+01 3.0830047e+01 3.1550681e+01 3.3304790e+01 3.2676753e+01 3.2742330e+01 3.1684556e+01 3.2830915e+01 3.2956614e+01 2.7365639e+01 3.3207307e+01 3.3420925e+01 3.4357941e+01 2.8280126e+01 3.4523458e+01 3.2705274e+01 3.2455891e+01 3.1636060e+01 3.1594957e+01 3.1805202e+01 3.3886574e+01 3.3438829e+01 3.3330030e+01 3.4168514e+01 3.0637353e+01 4.2149167e+01 3.6340559e+01 2.9315308e+01 3.5778314e+01 3.7693050e+01 3.2598714e+01 3.2990836e+01 3.4967659e+01 3.9748920e+01 3.6745043e+01 2.7117550e+01 3.6014760e+01 2.9367558e+01 3.3845350e+01 3.5477339e+01 3.1513372e+01 3.2517953e+01 2.4755097e+01 3.0229897e+01 3.4799343e+01 3.3371710e+01 2.9600910e+01 3.3275088e+01 3.3567110e+01 3.4527016e+01 3.4942320e+01 3.2359383e+01 3.2607100e+01 3.1467914e+01 2.9032039e+01 3.3122878e+01 2.8496709e+01 2.9908448e+01 2.9962886e+01 3.0345299e+01 3.1737613e+01 2.8551485e+01 3.2610551e+01 3.3082660e+01 3.3719298e+01 3.6434018e+01 3.6589278e+01 3.3889586e+01 3.8036774e+01 3.1483497e+01 3.4196794e+01 3.5154035e+01 3.5488608e+01 3.6143183e+01 3.3473491e+01 3.4686446e+01 2.8687495e+01 3.5725742e+01 3.0188298e+01 3.3084534e+01 3.3538519e+01 3.6226849e+01 2.9052099e+01 3.6032733e+01 3.0811503e+01 3.2616190e+01 3.3888566e+01 3.3074570e+01 2.9683515e+01 3.0600771e+01 3.4345247e+01 3.6983843e+01 3.3692824e+01 3.3762461e+01 3.4024582e+01 3.3698854e+01 3.1238613e+01 3.4978833e+01 3.4991078e+01 3.4577741e+01 3.3749227e+01 3.4982272e+01 3.0487868e+01 3.2317632e+01 3.1125588e+01 3.4413791e+01 3.1881871e+01 3.1373821e+01 3.0416864e+01 3.2066187e+01 3.1128313e+01 3.0240249e+01 3.0125198e+01 3.1343454e+01 3.5479092e+01 3.4450767e+01 3.2953507e+01 3.4456795e+01 3.0136375e+01 3.3462150e+01 2.9894274e+01 3.1367432e+01 3.2839320e+01 3.1440398e+01 2.9400374e+01 3.1106338e+01 3.1242624e+01 3.5537892e+01 3.3056459e+01 2.8610281e+01 3.4296217e+01 3.5819772e+01 3.2503922e+01 3.0963029e+01 3.4762112e+01 3.4796284e+01 2.9645345e+01 3.4468088e+01 2.6975590e+01 3.3738555e+01 2.8825009e+01 3.2663999e+01 3.2547878e+01 3.2308091e+01 3.2489966e+01 3.0868597e+01 3.2974220e+01 3.0866111e+01 3.8197342e+01 3.0609568e+01 3.5478978e+01 2.9249184e+01 3.6185622e+01 3.1948258e+01 3.2649719e+01 3.3305650e+01 3.4643955e+01 3.6566241e+01 3.4968484e+01 3.2632218e+01 3.6741383e+01 3.5700008e+01 3.1962468e+01 3.1410623e+01 3.0412061e+01 3.3749077e+01 3.5649661e+01 3.7649263e+01 3.2832574e+01 3.1783914e+01 2.8264292e+01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-correlation-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-correlation-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
9.2507465e-01 9.6528566e-01 8.7255441e-01 1.1287379e+00 8.7318727e-01 1.0767102e+00 9.1419676e-01 1.1503304e+00 9.8074509e-01 1.0135025e+00 1.0495025e+00 9.4794536e-01 9.6829273e-01 1.1345767e+00 1.1048008e+00 9.2407796e-01 1.0228634e+00 9.3853195e-01 9.9377619e-01 1.0407662e+00 9.5048989e-01 9.0465688e-01 9.8056930e-01 8.9777156e-01 9.6357127e-01 9.3864452e-01 9.9754613e-01 9.7271356e-01 8.4383151e-01 9.6981983e-01 9.7510267e-01 1.0112663e+00 7.8730400e-01 1.0299498e+00 9.9307979e-01 9.0239520e-01 8.5428231e-01 8.8972742e-01 8.5933162e-01 9.6625934e-01 9.4175449e-01 9.9120729e-01 1.0503963e+00 8.8223053e-01 1.3261434e+00 1.1063209e+00 8.4058398e-01 1.0844267e+00 1.1153093e+00 1.0092643e+00 8.9585237e-01 1.0599818e+00 1.2321707e+00 1.1359624e+00 8.3503556e-01 1.1792243e+00 7.9159781e-01 1.0830419e+00 1.2181870e+00 9.9888500e-01 1.0227144e+00 6.8557277e-01 9.6836193e-01 1.1061227e+00 1.0883453e+00 9.5681974e-01 9.9436299e-01 1.0304323e+00 1.1273949e+00 1.0735563e+00 1.0582583e+00 9.6040272e-01 1.0032137e+00 8.4900547e-01 1.1035351e+00 8.7867480e-01 9.6433176e-01 9.1850122e-01 8.9337435e-01 1.0449390e+00 8.9639384e-01 9.6704971e-01 1.0084258e+00 1.0528587e+00 1.1764481e+00 1.0913280e+00 1.0136672e+00 1.2737156e+00 9.5130359e-01 1.0367909e+00 1.1983402e+00 1.1319901e+00 1.1117462e+00 1.0343695e+00 1.0838628e+00 7.5266057e-01 1.0763316e+00 8.8067924e-01 9.6734383e-01 9.8800551e-01 1.2265742e+00 7.8833055e-01 1.0338670e+00 8.6666625e-01 9.9039950e-01 9.7142684e-01 9.3138616e-01 8.5849977e-01 8.5486301e-01 1.0516028e+00 1.1105313e+00 9.5943505e-01 9.8845171e-01 1.0566288e+00 9.9712198e-01 9.5545756e-01 1.1817974e+00 9.9128482e-01 1.0117892e+00 1.0979115e+00 1.0493943e+00 9.1318848e-01 9.3157311e-01 8.7073304e-01 1.2459441e+00 9.3412689e-01 1.0482297e+00 9.4224032e-01 9.5134153e-01 9.0857493e-01 9.7264161e-01 8.2900820e-01 9.3140549e-01 1.1330242e+00 1.0333002e+00 1.0117861e+00 1.2053255e+00 8.5291396e-01 1.0148928e+00 8.6641379e-01 9.7080819e-01 9.5457159e-01 9.5207457e-01 9.3539674e-01 9.0769069e-01 9.5322590e-01 1.1181803e+00 9.9765614e-01 7.5370610e-01 1.0807114e+00 1.0804601e+00 9.0214124e-01 8.7101998e-01 1.0167435e+00 1.2045936e+00 8.7300539e-01 1.1054300e+00 7.9145574e-01 1.0279340e+00 8.7623462e-01 1.0034756e+00 1.0386933e+00 9.3910970e-01 1.0028455e+00 9.9868824e-01 9.8752945e-01 9.8319327e-01 1.3110209e+00 8.6180633e-01 1.0993856e+00 8.5912563e-01 1.1303979e+00 9.8690459e-01 9.6910090e-01 9.1456819e-01 1.1525339e+00 1.1064552e+00 1.1062255e+00 9.7226683e-01 1.1091447e+00 1.1072238e+00 9.6544444e-01 9.6681036e-01 9.3247685e-01 9.6854634e-01 1.1035119e+00 1.1317148e+00 9.5557793e-01 9.8908485e-01 7.4873648e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cosine-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-cosine-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
2.5695885e-01 2.6882042e-01 2.3470353e-01 2.9299329e-01 2.2742702e-01 3.1253572e-01 2.4986352e-01 3.0770122e-01 2.5191977e-01 2.7931567e-01 2.8133743e-01 2.6316239e-01 2.6067201e-01 3.2982339e-01 2.8993002e-01 2.5506356e-01 2.8728051e-01 2.4952121e-01 2.8613379e-01 2.6894157e-01 2.3606353e-01 2.1670935e-01 2.3470242e-01 2.4294172e-01 2.4376454e-01 2.3228195e-01 2.3554918e-01 2.4851241e-01 2.0917546e-01 2.4971488e-01 2.4264224e-01 2.7405461e-01 1.9086415e-01 2.6346574e-01 2.5908801e-01 2.2138495e-01 2.2910721e-01 2.2169919e-01 2.0660065e-01 2.3207102e-01 2.5554688e-01 2.5153751e-01 2.6073682e-01 2.0919640e-01 3.3984433e-01 2.7503792e-01 2.1709889e-01 2.7068095e-01 3.0307041e-01 2.4529612e-01 2.2987015e-01 2.7736967e-01 3.0310708e-01 3.0544316e-01 1.9205388e-01 2.7098021e-01 2.0722466e-01 2.6387343e-01 2.8998308e-01 2.2633010e-01 2.5177075e-01 1.6347011e-01 2.4036389e-01 2.6485871e-01 2.8491965e-01 2.2273619e-01 2.4511873e-01 2.5930533e-01 2.6589995e-01 2.7797191e-01 2.3357373e-01 2.4279909e-01 2.3544532e-01 1.9447286e-01 2.3993534e-01 2.0856243e-01 2.2125251e-01 2.1988206e-01 2.0590152e-01 2.6441952e-01 2.0052739e-01 2.2978496e-01 2.4483670e-01 2.3879510e-01 2.9398425e-01 2.7541852e-01 2.3777469e-01 2.9151131e-01 2.0672752e-01 2.4584031e-01 2.7475025e-01 2.7064343e-01 2.5603684e-01 2.6165327e-01 2.4233155e-01 1.7892657e-01 2.6111203e-01 1.9965682e-01 2.4201634e-01 2.6281353e-01 3.1928221e-01 1.9731963e-01 2.7752862e-01 2.2633080e-01 2.6783167e-01 2.5447186e-01 2.6424243e-01 2.1960672e-01 2.2984242e-01 2.8788736e-01 2.8681630e-01 2.6949787e-01 2.3993685e-01 2.4440073e-01 2.5010397e-01 2.3230769e-01 2.9879682e-01 2.4200592e-01 2.6957748e-01 2.6073240e-01 2.6355347e-01 2.3403674e-01 2.2411413e-01 2.2956729e-01 2.8105976e-01 2.2913304e-01 2.4898608e-01 2.3304000e-01 2.2692988e-01 2.3728251e-01 2.2552243e-01 2.0364084e-01 2.3359511e-01 2.6619167e-01 2.6666588e-01 2.3666880e-01 2.7239113e-01 2.0146697e-01 2.3045559e-01 2.1695523e-01 2.1387991e-01 2.2366404e-01 2.2809635e-01 2.0901297e-01 2.2441100e-01 2.3418882e-01 2.8552218e-01 2.4609015e-01 2.0282492e-01 2.5940295e-01 2.7407006e-01 2.3344890e-01 2.1179142e-01 2.7047821e-01 2.9832768e-01 2.0859082e-01 2.8881331e-01 1.8384598e-01 2.5286491e-01 2.2012615e-01 2.3615775e-01 2.6845565e-01 2.3356355e-01 2.7164193e-01 2.4179380e-01 2.5247973e-01 2.5637548e-01 3.2126483e-01 2.3100774e-01 2.8832546e-01 2.0043257e-01 2.7918333e-01 2.4884522e-01 2.2904723e-01 2.3738940e-01 2.9461278e-01 2.9782005e-01 3.0332073e-01 2.5175971e-01 3.1203784e-01 2.6611535e-01 2.3713507e-01 2.2203585e-01 2.3602325e-01 2.5093670e-01 2.6860434e-01 3.0137874e-01 2.3759606e-01 2.6840346e-01 1.9200556e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-double-inp.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
8.278938049410748956e-01 9.035293984476246987e-01 1.862188994679486731e-01 8.921151312310462433e-01 2.061859119379583216e-02 3.440636727385729676e-01 1.533779912830328662e-01 5.701372300009802663e-01 5.510020730211558915e-01 1.792362258426003496e-01 8.086175120876580857e-01 6.115487184317183189e-01 1.233471787164852618e-02 1.441643531871039663e-03 4.044309209045688913e-01 3.561398959499905148e-01 1.281985712929750720e-01 8.663300833847481508e-01 8.696027786291581352e-01 3.611727370363766454e-01 5.283537658772616830e-01 1.440241088090119526e-01 3.112457227138950566e-01 6.031280796897889873e-01 9.230324792742518047e-01 2.332121881136874908e-01 3.192652267403439659e-02 3.466206294995559656e-01 2.988687728046366399e-01 5.116749542048093513e-02 2.584975830914494344e-01 4.302023478042227289e-01 8.003972751713522849e-01 9.364931911368097328e-01 9.737098649964673891e-01 4.718038453972229762e-01 4.526591686607864817e-01 1.056485678520797666e-01 5.883019714285405710e-01 3.846092237676981274e-01 6.461500053435473845e-01 1.013239729848824933e-01 1.216151561651189761e-01 5.159668929484659827e-01 8.452074473510227115e-01 9.885170962247968873e-01 7.623883073490128615e-01 2.291163243615434997e-02 5.775530980802381364e-01 7.820699896828091635e-01 8.239186345842965942e-01 3.391800105260227571e-01 9.546318451614538292e-01 3.789677917867695367e-01 4.526533399649290690e-02 8.366786473238587707e-01 3.082636811049858094e-01 1.173936820793450853e-01 7.631994969169442200e-02 2.997416650722183329e-01 5.795208655160232203e-01 3.942350892542011431e-01 1.175126383297261379e-01 4.928232513950027149e-01 9.421293996225950096e-01 8.365391053841342295e-02 6.868059693571844093e-01 3.589527962429440722e-01 7.592939427166059962e-01 5.623849466131448649e-01 2.110746828032050715e-01 9.824683704668600859e-01 2.661230142246236996e-01 6.162272315007123469e-01 5.023254536607497656e-01 5.202854476669782624e-02 5.835090668842095596e-01 7.864642118889143552e-01 2.504012386867506823e-01 6.728308641135989365e-01 4.610793534576096420e-01 4.820508770515909980e-01 9.720403251022265989e-01 3.100069285263498120e-01 7.681017126461753275e-01 7.956539306007082146e-02 2.593389637887737464e-01 1.137852590403054531e-01 3.885303073284454012e-01 8.599094660075957686e-01 5.215167875918280682e-02 1.620908248572288102e-01 1.859236090457663249e-01 6.247716512610480555e-01 3.415128495520775020e-01 7.034903368378029320e-01 6.037564640019568163e-01 2.338969434423310290e-01 1.002104885609900187e-02 7.866058403969036217e-01
|
| 2 |
+
8.033694116033356369e-01 8.653264545544031572e-01 7.468340410754038539e-01 6.362430919910603278e-01 5.120006306625468628e-02 9.503348372633585450e-01 4.697732609626817935e-01 4.221305288459429317e-01 3.153452119838391354e-01 2.991014843442657556e-01 1.190667967280257811e-01 3.486567714509342109e-01 8.289493649885054660e-01 8.454811050800014049e-01 9.149673018211901265e-01 7.708707837193897738e-01 2.640157732122547785e-01 2.107897022189605396e-01 4.207633055054439408e-01 6.719500284654699174e-01 1.458031684893063007e-01 1.800412735886125493e-02 8.402733435220011149e-02 4.206760156883160295e-02 1.376933515041314227e-01 1.716717341022133692e-01 1.788220727652158892e-01 8.224310433402118869e-01 7.729093666867475898e-01 2.064223621025984556e-01 9.592092036227207741e-01 8.312490243754996344e-01 6.673289360369902834e-01 4.632847903690773261e-02 7.643954098358983762e-01 9.359341525615098023e-01 1.914966319163026176e-01 4.536590469402868031e-01 8.640836016538007147e-01 3.941529178175462444e-02 5.602101995205478469e-01 9.263806161941660067e-01 1.555995325944817820e-01 6.172208102950116348e-01 6.335576752812099866e-01 9.766975460368043649e-02 4.475795689539874278e-02 3.248842796104995934e-01 5.700377122149502540e-01 9.066962967256807504e-01 5.458460621505676347e-01 6.833401285581487405e-01 2.887244409544044155e-01 1.316338647016834784e-01 2.325673305245992140e-01 4.150121963188406760e-01 3.834845466366055833e-01 8.149365773968725302e-01 1.867003849450201702e-01 3.170322173543018707e-01 6.832093662682684476e-01 1.729728518929105618e-01 9.236557359702636250e-01 9.152941252150086360e-01 7.224879983096620384e-01 8.557920626598064517e-01 5.344883059251644974e-01 4.876873274449112783e-01 8.308277804506420949e-01 3.916624489322212410e-01 3.459695122273966916e-01 4.033512499027409604e-01 6.555726444913008155e-01 7.138452409380238173e-01 1.683937314599968094e-01 1.769382143486440961e-01 7.588683655178136700e-01 3.750589892880819010e-01 7.525176245126207197e-01 6.083961152538303052e-01 1.145972309907993258e-01 6.239614485809552580e-01 1.307655482065895880e-01 8.530458750670916190e-01 4.801602070124768584e-01 8.168122189863546989e-02 3.793139622744635675e-01 1.496986997776840189e-01 7.129023878302899186e-01 6.830979237438047358e-01 7.635375943876505644e-01 1.824004963251233402e-01 5.764695848992339444e-01 8.865113248731604223e-01 5.784337085544002388e-01 9.700026628755119562e-01 7.318207347905059112e-01 3.851401393936705331e-01 1.774291851193399161e-01 9.763423229242296220e-01
|
| 3 |
+
9.287178470949695175e-01 1.748282433617460718e-01 9.238531711586964734e-01 8.291274445125006443e-01 9.513259272578692416e-01 7.486316801165745494e-01 6.257378457524477300e-01 2.062711693536473101e-01 3.970721244184766130e-01 2.738325225026445597e-01 8.735038948299954642e-01 5.415282140033768066e-01 5.176317904298315398e-01 5.347036264518250093e-01 7.482056965410627258e-01 4.140672582824351800e-01 8.709067272363142376e-01 9.499605569181273079e-01 5.380266748336398619e-01 4.369252161707162241e-01 8.235722216228258397e-03 4.308187193646527691e-01 6.030581482859224129e-01 7.316831195156517920e-01 5.540499846834291420e-01 2.044203040111662872e-01 8.645251782981867583e-01 1.816095717570278545e-01 9.639119168018674966e-01 3.572031072322333634e-01 5.580226816834680248e-01 5.586629875016585478e-01 7.213854320902782780e-01 8.513998260042524580e-01 6.308764347277173723e-02 4.299855362100638567e-01 8.789303907444128150e-01 9.178850359236285783e-01 2.275205845091231582e-01 1.899395443939643213e-01 7.103070862773533944e-01 9.450015289553428399e-01 1.691856364522159595e-01 7.368719616877857925e-01 9.600189536623833231e-01 5.128846522932454244e-01 6.209162727118655578e-02 7.992250598838029907e-01 9.141050280518014937e-01 1.471297785256820978e-01 7.466162372930541524e-01 4.656107650642931084e-01 6.399324135161845728e-01 2.023617619481610230e-01 1.019104648900100996e-01 4.390693688536728700e-02 9.822620353006089600e-01 2.881951852926285529e-01 6.191575015960482098e-02 8.989580763251467932e-01 4.635958631890454429e-01 1.781973138114967270e-02 7.906911683818984571e-02 6.525270776225711167e-02 3.620583622807886925e-01 2.651673718940715796e-01 5.829372395929610651e-01 2.118159824373908595e-01 5.900287159143694504e-01 9.405929925178391215e-01 9.262415619063500971e-01 5.639581506302312475e-01 4.529556154689695635e-02 2.873819210518682166e-01 5.718545934306838996e-01 9.877670791317306742e-01 4.120364488714320927e-01 9.896078045634184583e-01 3.796586997026456523e-01 1.178183652203194098e-01 6.641068305236120795e-01 4.045960610587706618e-03 2.262690437428437340e-01 7.839938005832693957e-01 7.695391333937223743e-01 3.713918392552509884e-01 4.245533341514018399e-01 1.475072494020331915e-01 6.011975181419888514e-01 5.158174017998343741e-01 1.788706151398071764e-01 8.880707130134481986e-01 6.463351030474082659e-01 6.499920635615744624e-01 8.570273676455353318e-01 6.055019270899113515e-01 2.123561211054603159e-02 2.027688787664126968e-01 1.930834215328548487e-01 5.131906052747271518e-01
|
| 4 |
+
2.599990881903107010e-01 6.767857524909899336e-01 7.188217446352963558e-01 3.037178903357997672e-01 4.252381412838680541e-01 4.070924411439535984e-02 8.426710493038247485e-02 8.301517457289483426e-01 8.254603255702420705e-01 7.258533909453509514e-01 9.958706809470796451e-01 1.323408451651194584e-01 8.523995455245143571e-01 2.572405385832454705e-02 4.715363690065482727e-01 7.920130365690022378e-01 7.613745641534582775e-01 5.108305991695683002e-01 7.908714335912382376e-01 4.641131983754837043e-01 3.112627109831845873e-01 4.218013908715474436e-01 3.291577909008427394e-01 2.538715054071232213e-01 1.362470842487485401e-01 2.716429790290709745e-01 1.485325814161112534e-01 4.514539027544387517e-01 6.900835128673067365e-01 7.793407072946112457e-02 5.938024345270752624e-01 1.497853829906865553e-01 5.399567982652856424e-01 1.419209916759478496e-03 7.719776132867679497e-01 3.130795105576239523e-01 6.670071611167494030e-01 8.900596881158256979e-01 8.011158503301568645e-01 7.089295605187424520e-01 4.671116382997058114e-01 6.682965170673403899e-01 6.524835265739736823e-02 5.454288420771494783e-01 7.751910790556310049e-01 8.192595541387335256e-01 3.098855848167891835e-01 3.689971355659119601e-01 8.666507475054133769e-01 2.749042684253171220e-01 3.566565602478318775e-01 4.838173174723044978e-01 1.032975933616413489e-01 5.063065339610417492e-02 5.791168455729079900e-01 3.573337411289496668e-01 6.714098909652352898e-01 2.917057662433912846e-01 2.654964332620638467e-01 7.171804039048814694e-01 3.314488637898249657e-01 5.230399837442840649e-01 6.866534136026025692e-02 1.252966394621071178e-01 5.349397882659551184e-01 2.841423847455760709e-01 4.158473635710734362e-01 7.197062989831272128e-01 5.123869045047864113e-01 8.675622821594339840e-01 8.097441845042540054e-01 7.317178252133832439e-01 3.300847596465853462e-01 5.922311859141077273e-01 8.852619511417836318e-02 2.673412917259408994e-01 6.878259052441990651e-01 3.223000927116328462e-01 8.859387123976615319e-01 5.722722388300067742e-01 8.254877606669521750e-01 5.705299682290687624e-01 7.046478734972855262e-01 1.316324413616759559e-01 3.056358395675535800e-01 2.396516834600909140e-01 2.041201422493257311e-01 1.610755140653103989e-01 1.617012564641111538e-01 4.449920510036902144e-01 2.731012972755201274e-01 7.826874666257994662e-01 5.193612375350010746e-01 8.688804522977213729e-01 3.742157602758655610e-02 6.649628920608219307e-01 5.978149424619171315e-01 5.345645500553952711e-01 9.443202650415919441e-01 6.105837075491723498e-01
|
| 5 |
+
6.387761328141735584e-01 4.210087412162694109e-01 3.777306694964789324e-01 3.576349403292201634e-01 7.272699618880260619e-01 9.173392803607671731e-02 1.212535698300880593e-01 3.871229381194544183e-01 7.735150198351389284e-01 4.687200483013695962e-01 5.161778571874678923e-01 9.839646447226980674e-01 8.626932748911960713e-01 9.618485576577924245e-01 2.997996427525421170e-01 3.955404657388794654e-01 8.480126027102616870e-01 8.194992325050480808e-01 2.800213436873294492e-01 7.188391466620779324e-01 2.289766105875049584e-01 3.838547514028287644e-01 1.363553401061209369e-01 2.131328253542326134e-01 2.666779468144075960e-02 3.252883844200405994e-01 4.207860197469600605e-01 2.991365385037647595e-01 9.180779845534067229e-01 8.787338732192649937e-01 5.404510999105649471e-01 1.735493827761729335e-01 7.405224640747264386e-01 3.927355563629583157e-01 3.957109873399460298e-01 1.313029813325972128e-01 6.434498219738993274e-01 7.162213694578050127e-01 6.454998257494671821e-01 3.808124530008022424e-01 2.027201015737234435e-01 6.667632842770417900e-01 1.609491052365198405e-01 1.192413785409307536e-02 4.546773323526854815e-01 7.733541911050207940e-01 3.902525737195561284e-01 4.006023779897505133e-01 5.156517815815246930e-01 6.135685498584592112e-01 7.062153114980724844e-01 5.505858882117883324e-01 3.541308807182554919e-01 5.237151122342533771e-01 5.230649229131387745e-01 1.973541027697351957e-01 7.940327858595511712e-01 9.998588700623055603e-01 3.878271015153827994e-01 4.455006584967207139e-01 8.376414508056347907e-01 3.310833863524501597e-01 8.020469097392601832e-01 1.890327633084128989e-01 3.830289472395409511e-01 8.605040171046141051e-02 9.978185524023941433e-01 8.333890591892906263e-01 4.509013468741837061e-01 6.355778557686052599e-01 1.422515991097305088e-01 9.549891485963732940e-01 7.535776302868563148e-01 9.306005301880662106e-01 2.444330347211679522e-01 5.828218427569508142e-01 1.261938242968304591e-01 2.829188731405173352e-01 8.100246952078660190e-01 2.032739130996042975e-01 3.997268448390065565e-01 3.882777703107541667e-01 1.102505652624736765e-01 5.826634725328041498e-01 6.508734477956333864e-01 1.777287661702166011e-01 4.857051012052149286e-02 6.850537712379254351e-01 5.012281307761055071e-01 3.329154880061502286e-01 5.006261767216675374e-01 4.542081454976160115e-01 6.777801995399822532e-01 4.271303586474960445e-01 7.820470659692947413e-01 5.143462618485082904e-01 4.071273891563575997e-02 8.503383643856671226e-01 6.877485768345151795e-01 6.498843855014626580e-01
|
| 6 |
+
5.539512747016193117e-01 6.329206647391879548e-01 2.798533500321682688e-01 4.825977295850051307e-01 7.625297023172977751e-01 9.081309101427640362e-01 4.124792086535029600e-01 3.647019658319609059e-01 7.529595202332928228e-02 3.072404010876803593e-01 7.890673660964639957e-01 4.079781478915127657e-01 1.440519120695739064e-01 2.538968953804546791e-01 1.595028243568367143e-01 9.066545851872198636e-02 6.367601114674349416e-01 7.622263643880089479e-02 3.015728236404162654e-01 2.424070469873378375e-01 5.711440390241000475e-01 5.717001375511508998e-01 2.237853674032181939e-01 7.112101625753678436e-01 4.321054197012103026e-01 2.505322169010260058e-02 5.877307077139551916e-01 4.415771174397812304e-01 3.766022855145171322e-01 9.803490652619811785e-01 1.229258314111529860e-01 8.108351868714478439e-01 8.558595456964329662e-01 2.168217533833206589e-01 2.034022719386595623e-01 8.687457137579783772e-01 9.013327195854559104e-01 8.156766512673154779e-01 2.717576187546973943e-01 1.756417893371479133e-01 7.555856977566548505e-01 6.708809351312817748e-01 8.998789237886926085e-01 1.936367585946979775e-01 7.949724635465026390e-01 3.164799312763589834e-01 5.493048513173155456e-01 1.608917269168268493e-01 3.048667492191803330e-01 5.599401537727016764e-01 5.779501360842279611e-01 1.296714605309662316e-01 9.160752328055997706e-01 8.058674476110374574e-01 4.385508937505578908e-01 9.212419718012100356e-01 2.249887451242467140e-01 6.283927745352599903e-01 3.778992451536005159e-01 3.571958698867505611e-03 7.276526470528231760e-01 9.051678673805297892e-01 8.465837072484881931e-01 4.548317505393462135e-02 3.189318261926020748e-01 4.446388607398673587e-01 4.292356336344156365e-01 4.203980977718795309e-01 4.698059253071955599e-01 6.151991200848159203e-01 8.479986139404802614e-01 9.870993262459623052e-01 3.164206525899861955e-01 6.464672171639846976e-01 8.508781429592480183e-01 4.733667503354813677e-01 8.076014176740163863e-01 6.671443255679101458e-01 6.639213267047979761e-01 3.681688930741919830e-01 4.679870252651611162e-01 1.790041740686979521e-01 8.446070273663058847e-01 3.350737544979878191e-01 6.600272349677447359e-01 4.356083218487936115e-01 7.995134167346013010e-01 9.083660261041469619e-01 9.743975306734570241e-01 8.144839650654719376e-01 6.865011984586443239e-01 1.709747281999153268e-01 8.534933687161740945e-01 9.494753729726415070e-01 8.140124992294850426e-01 8.936241255316055287e-01 9.087976860818796077e-01 9.030687493451383663e-02 4.025785149840914734e-01 9.592005611533803711e-01
|
| 7 |
+
5.714058727476275523e-01 7.913573761505965365e-02 9.301773447377043036e-01 4.302822433307075256e-01 4.618892554175407783e-01 1.882471300213742760e-01 6.231472878215863487e-01 2.350437450940777717e-01 8.483410480771292894e-01 8.580803842040533036e-01 4.246398783388435350e-01 5.667321565946502604e-01 7.247417018955526480e-02 5.373984417482219333e-01 8.794242091541510931e-01 9.699025554453030162e-01 8.254197752548814160e-01 7.739723972867470492e-01 6.365819416181199841e-01 3.451230687021222820e-02 1.829102490094791644e-02 9.179618383026147965e-01 4.481667270072077214e-01 4.771270250445739380e-01 1.588469404953456454e-01 3.766332499200618633e-01 5.057026248713025751e-02 9.125900914275182352e-01 8.438133644246305076e-01 3.282972411719701222e-01 6.042003956122835584e-01 7.423456085393266290e-01 1.389012737541106546e-02 3.674754266702850991e-02 2.126646727703802586e-01 3.085666164246750887e-01 4.303440338750976757e-01 1.749037978865556342e-01 2.177699993322510519e-01 6.675614739991906355e-01 1.926533336347433512e-01 8.032010572660308600e-01 4.611412981769049679e-01 9.907201268457492827e-01 8.973785930837320235e-01 6.286342392657409128e-01 8.111266245859546364e-01 1.154230969025437092e-01 8.382880466301794176e-01 1.053753927827069115e-01 9.921712862234919328e-01 9.041662667920956631e-01 3.626267376021269362e-01 2.262225368932846425e-02 8.669003741626111204e-01 7.597054897704164089e-01 4.700318514995387442e-01 4.338185014241978665e-01 1.205425463362067573e-01 2.413879270602589111e-01 5.483334840461459025e-01 2.042653841254596925e-01 5.452588940366013270e-01 3.164646091706100339e-01 1.878958248945691301e-01 2.188622304737641855e-01 2.970982599823450698e-01 5.952148400199362976e-01 9.614251220149501176e-01 5.446813400697393392e-01 5.900748097930779146e-01 2.653062526715309621e-01 5.459933097767216692e-01 3.174185404661935550e-01 1.412133354129242457e-01 1.487441669790685594e-01 3.953776242211952674e-01 5.274261039692862418e-01 1.756132307607755072e-01 4.481942852746899630e-01 6.390660088765629521e-01 2.860380430081067571e-01 5.866902519902850166e-03 3.026687645174785946e-02 1.952533570196290924e-01 2.154769096186736066e-01 8.920573593276575064e-01 5.644513191915436767e-01 5.551464696654353492e-01 4.378199413349500579e-01 8.685737643974280608e-01 7.493934764293597173e-02 9.556749726352036234e-01 6.386433482536227890e-01 8.714694524097754691e-02 1.722786161701279628e-01 6.526867532768643176e-01 8.950304705281527662e-01 6.158198776753203152e-01 9.587176904005377809e-01
|
| 8 |
+
7.705718397401561948e-01 3.165816092999733655e-01 4.334200859975760878e-01 8.639807015515663657e-01 5.576514209532534849e-03 2.456745447057938625e-01 1.664686313299922338e-01 9.637084729617834133e-01 1.083448720752323569e-01 1.865218070380464388e-01 3.730358890475884426e-01 5.015351872138350542e-01 7.420710795841709562e-01 4.919420674769692248e-01 3.426558201886464872e-02 8.669984854934246199e-01 2.204243734202966376e-01 4.109792246853891662e-01 4.361732572946559472e-01 6.819306998053020763e-02 9.986304248057148447e-01 4.119289455392274313e-01 8.533050041845835487e-01 3.416914861912183632e-01 6.522191951039880697e-01 4.162803668786793088e-01 9.051674379917418189e-02 4.552378661306888397e-02 2.122677193466918633e-01 7.461518531655018105e-01 4.654688019259497489e-01 7.877564083548750373e-01 4.518328005682387127e-01 7.173857464237374248e-01 6.940056370290903498e-02 2.804574410412373764e-01 6.095681113112718652e-01 3.680596478602831123e-01 1.814569150719304025e-01 6.505055517979729807e-01 2.759585245701871026e-01 1.429501104786028431e-01 7.813891153083207808e-02 8.925314279991185540e-01 6.692056941902108091e-01 1.915141341107173822e-01 5.750233129581091562e-01 2.051961006251528108e-01 3.849013692629975614e-01 9.503788222043518807e-01 7.690419386411734282e-01 9.978147530014782607e-01 1.719584162437415298e-01 4.890758882401113894e-01 7.195660736040896399e-01 2.485818040997200828e-01 9.706486601870933928e-01 5.182604282071262558e-01 8.082072245463804983e-01 4.889961284821118248e-01 8.042893959057633158e-01 3.200685313413229593e-01 8.983245016887355661e-01 2.811495336955205371e-01 3.986095833814048417e-01 8.607229214132059436e-01 4.827620119717191960e-01 6.715610252037491623e-01 9.330824374137768329e-01 7.537710530085762750e-01 9.840804224010484269e-01 2.319352541177217564e-01 9.569114943157627229e-01 5.821928104654411351e-01 6.700479524814679788e-01 5.663434680086896211e-01 8.851091082101365526e-01 6.800562815862243315e-01 3.578475213752868589e-01 2.900164669281133367e-01 8.379170683569914235e-02 9.929972839740475177e-02 5.946248553621906741e-01 1.991332889320840405e-01 8.115065723822508792e-01 2.023388190440008616e-01 4.056545651129230823e-01 2.966825350250481552e-01 7.457176343507545546e-01 9.856015771246517954e-01 2.264338016147812160e-01 8.366528670045663141e-01 6.116829813603242849e-01 2.605933184296719274e-01 5.765962146558850643e-01 5.064075092266390188e-01 5.499615769589756287e-01 9.240234698632640020e-01 7.169900155229913530e-02 3.544181364560751168e-01
|
| 9 |
+
8.154844535553099627e-01 4.797965609394789777e-01 7.476703385713100447e-01 9.086708404761600910e-01 3.191752505450355937e-01 7.611128630021511965e-01 6.246790343299296611e-01 1.942001426217137006e-01 2.789860414631386565e-01 3.236359785042408621e-02 3.178191288741717413e-01 8.372264298357038337e-01 8.872692914664047636e-01 9.589758852077276963e-01 3.123722260380168425e-01 8.980164015338999439e-01 7.260784140459818348e-01 6.567013512265649222e-01 1.028743505926521529e-01 6.821705410750319443e-01 6.889838995316139858e-01 5.587525493094736007e-02 6.921487028366646310e-01 3.616312929861494885e-01 1.673758008792780583e-01 6.626504595920326146e-01 9.125680913222075086e-01 1.424077784972291871e-01 6.508496429060767197e-01 6.615417385775157477e-01 9.654167310675311198e-01 5.536662974550183858e-01 7.092622144968085962e-03 6.694595400455760625e-01 1.828533619119211417e-01 3.421514408394116247e-01 1.242580151818144518e-01 9.888774797458224075e-01 9.777955172739735135e-01 4.271370765628749178e-01 1.211608384809655936e-01 1.580132417172936954e-01 3.242705395708289640e-01 3.268994391754735940e-01 5.213767653645562383e-03 4.475169480357120699e-01 9.593245219293577986e-01 6.994304536782350867e-01 7.063863152769014331e-01 8.381620829497931080e-01 2.760441799736219615e-01 3.755200946645842475e-01 3.627729621737311172e-01 9.518310606719182498e-01 3.577273025276901386e-01 3.991159901003488164e-01 4.187060513068554535e-01 7.422605403637314581e-01 6.697944269780702342e-01 6.020599837037767799e-01 1.571185850817550245e-01 7.519860911185742847e-01 6.635775704496444938e-01 9.487848173531471252e-01 7.900030232338028924e-01 4.143783957270819052e-01 5.618429740858444932e-01 3.737804619062014000e-01 6.179941187802344693e-01 6.553638605616040058e-01 1.009709416658691739e-01 4.935037098582963910e-01 5.485489972455533936e-01 1.024147956480448984e-01 1.195764707555347917e-01 4.910516327810896531e-01 3.551185778630389089e-01 3.857601645798814927e-01 2.074975219600547760e-01 2.084038664460790002e-01 5.268616653491025037e-01 6.948014877618717833e-01 6.179744044618615817e-01 7.063658085955483168e-01 7.925757227686872630e-01 6.199016959584816577e-01 1.163676037434490107e-01 7.425752264755586252e-01 5.403115665133301215e-01 2.546191951391015840e-01 6.961300925345208501e-01 4.003013072125547467e-01 5.906120962720950995e-02 5.879915846330325824e-01 1.213602408288709800e-01 3.801780679842765576e-01 1.731477742402802722e-01 4.624568816669496485e-01 3.304453744619206823e-01 8.810445876116090869e-02
|
| 10 |
+
5.140190515373614932e-01 1.419225260054487459e-01 7.777845802285945354e-01 3.327562899409282071e-01 8.916875699762913943e-01 7.212852862736146564e-01 5.727327199433507321e-01 5.897820225918504189e-01 7.318614954542906892e-01 7.393985144455500480e-01 4.531340740296823100e-01 9.903061584426188224e-01 4.213350938331624773e-01 4.542342471963995987e-01 9.788786426453045530e-01 1.881707000343846303e-02 8.005433413647761176e-01 1.523502822273363755e-01 5.630164732287495921e-01 5.946603842470724599e-01 1.225547698678740582e-01 1.531136594724622491e-01 8.157973612638946825e-02 2.752046015644330490e-01 6.809045821946161370e-01 6.455289724528190387e-01 3.830356726830793646e-01 4.446144649678575034e-01 4.969038423960672191e-01 5.497873820641221432e-01 9.471879627821714331e-01 5.933046675329255448e-01 4.099233758501530378e-02 5.790409810134594659e-01 9.546095885251496549e-01 2.608616052375664074e-01 6.910160339170060562e-01 1.293709850476291168e-01 6.407264616302255078e-03 6.186037089828009261e-01 5.537861302543241049e-01 3.527421038298221845e-01 8.033232052121624944e-01 8.128114152830284711e-01 8.319982582278713235e-01 5.939566376046836460e-01 2.291090283499520597e-01 5.438101817725821130e-01 6.881146379117278888e-01 2.421968586304659166e-01 5.874047918543783275e-01 6.210102709484541794e-01 7.041387566450251212e-01 6.959223476278774134e-01 9.133877300988062498e-01 9.230647706207778525e-01 6.856884219815310155e-01 6.997988808693775820e-01 6.177944932528769417e-01 5.512902545683161515e-01 5.818280341729102911e-01 6.538267999985679646e-01 6.946673485935980219e-01 4.817938258357623571e-02 9.352008817207906333e-01 4.774162142215661042e-01 5.768063588692976529e-01 4.589648891483899540e-02 7.998946815651652997e-01 4.434260476954369201e-01 9.850053510925722566e-01 6.648626681529369309e-01 4.606293826856903140e-01 3.309042418210563774e-01 1.438901922508034614e-01 7.986559119276418484e-01 7.037818421334554042e-01 3.605119534240813772e-01 3.785959549258922641e-01 9.562491516841659100e-01 4.997955143590974147e-01 1.029540300938682762e-01 1.819017177001992502e-01 3.665425750262368831e-01 1.688063588370778412e-01 7.030735208313992901e-01 8.922375654244527610e-01 1.055706412056253152e-01 2.664739907746691561e-01 9.906029568647586325e-01 6.043845090140997911e-03 3.495786295043534775e-01 5.989441999519146131e-01 6.776147193866479679e-01 7.012991789852640601e-01 1.825838783477321536e-01 7.612293578749116385e-01 1.564769891240175292e-01 2.762157292905387251e-01 7.641900040015234818e-01
|
| 11 |
+
4.746013333880729768e-01 7.609202966712714788e-01 2.537820854162747830e-01 1.709362234877408460e-01 1.886635378734374813e-01 2.439567014093724229e-02 7.640304718272151741e-01 3.483216170435471382e-01 7.744289278738043514e-01 4.190437573644867353e-01 5.319091476394965934e-02 8.580130976087452233e-01 6.259446446786639529e-01 8.793213970773006150e-01 2.441023074890465994e-01 7.753405549489799098e-01 8.760187573193888300e-01 5.946480724009295393e-02 2.873093046571124631e-01 8.710837851946537924e-01 9.103181731924696596e-01 6.534637257615111272e-01 4.128420398577182793e-01 4.905858108576378607e-01 6.178275806701372108e-02 6.368043900016381320e-01 2.865296941219959148e-01 6.371773028539067241e-01 4.924322796636745325e-01 1.709313290387282080e-01 1.856892551689268700e-01 9.592782603102242289e-01 5.402593764193130976e-02 7.287312244390512506e-01 5.679467572000697073e-01 6.255587794305905724e-02 3.069660218141317953e-01 1.089960430557104232e-01 5.550748245336984965e-01 2.555948886689661803e-01 4.140925514039996980e-01 1.180376445052062628e-01 8.832322629884041820e-01 7.784546946701487169e-02 3.177678935473182698e-01 6.681804863429485764e-02 7.047099396645268854e-01 4.133897376851528582e-01 5.600656990480865627e-01 3.883995683475501837e-01 4.459430113152932362e-01 4.214077227574740681e-01 4.763369230200156235e-01 2.701480661168440545e-01 4.296286564389811824e-01 9.601402258758658936e-01 6.326999441846863359e-01 2.442086919688498670e-01 8.407708423957936938e-01 3.626867985638081437e-01 3.641441713291436733e-01 7.932397565989488530e-01 8.902073520619256941e-01 1.929173010337000838e-01 7.309376779324568973e-01 7.305852858337777977e-01 6.510197444582447313e-01 9.512661608643838695e-01 8.461467164366111016e-01 9.245490147941206605e-01 2.658844813385705663e-01 9.538758859344749208e-01 8.215517204998477041e-01 8.217795540390903097e-01 7.569662091300560780e-01 6.262685322871274218e-01 5.597770510574888725e-01 8.155720175123675197e-01 8.545688745180864965e-01 8.986051518529034610e-01 2.477911506572628708e-01 8.462580108996445860e-01 6.065941220995090255e-01 6.500490804973033665e-01 1.120463882674053169e-01 9.299049132942927010e-02 1.388364074229719858e-02 5.901199124540731367e-01 2.795110110544174464e-02 1.644097083463245124e-01 5.341029647603202646e-01 5.276816677181681570e-01 5.439849107754858304e-01 5.371677986392331405e-02 4.515163125788429488e-01 5.036243367087100964e-01 5.721818679625961801e-01 5.271368612400184617e-03 7.720961020546839304e-01 9.015383457479009266e-01
|
| 12 |
+
8.301526916287945701e-01 8.704609696144033348e-01 2.955689129581380303e-01 1.762209253489944727e-01 2.698172933050072553e-01 1.138095349991521399e-01 4.092588531860634760e-01 8.202978121681584467e-01 2.822241377079557356e-01 6.117376205659387223e-01 7.169923068016897938e-01 9.310256256264415331e-02 3.989664052931106708e-01 1.651874953308862803e-02 7.890202597932294282e-02 9.068686774810821305e-01 5.203866694486933842e-01 4.297748572844445336e-01 5.208786995443430712e-01 2.163224881365530816e-01 7.274307306357226111e-01 1.675784956180090823e-01 5.969822786565782691e-01 8.959750832846602453e-02 1.253794151891943764e-01 5.352628522116801291e-01 2.562706125890066300e-01 6.030433202137867044e-01 8.330717547440393833e-01 9.603613683422040914e-02 7.569714244468559450e-01 3.184801677796517128e-01 1.667069341164499896e-01 3.132470247801235619e-01 6.417752836394801097e-01 6.433909425912354152e-02 4.056860213146201710e-01 3.166772891331335327e-01 9.574059746098845247e-01 1.492907964460536974e-01 8.311513764927496162e-01 6.652928354977717396e-01 2.396804722185036374e-01 5.812361618600220270e-01 9.724228681350225445e-01 2.853983236378453414e-01 5.337719354896472979e-01 6.779446197712412081e-01 5.485102006140557540e-01 9.010109155962182648e-01 5.724439967467525037e-01 5.965540527411405947e-01 1.598667990086183321e-01 1.363934512727023041e-01 5.327536522697270405e-01 4.123866715061276222e-01 4.617251396918636841e-01 6.935944951381239898e-01 4.300337419593377453e-01 1.892407993760835128e-01 1.666936825594794724e-01 4.625634184864588772e-01 4.805197636774838355e-02 7.003542850133466224e-01 2.130226006716084974e-03 8.678863343041013367e-01 4.874478520451258623e-01 7.043560228741558848e-01 6.317719270475393722e-01 5.372392256296196766e-01 2.982649812986511995e-01 1.272558612133412037e-01 2.467337555730741983e-01 6.546893200021091097e-01 6.291921159383098150e-01 8.505920470407707379e-01 4.046520490181828578e-01 3.875732096593392795e-01 8.551517214319142024e-01 4.152602284179877090e-01 9.587779137989138611e-01 6.977437468944928112e-01 3.240620775541913634e-02 4.025873770391376061e-01 5.485549335619134270e-01 7.146066156157020455e-01 3.012702534568838519e-01 3.526414480395153594e-01 3.309707144485515284e-01 4.315687014460974913e-01 6.641934530697197747e-01 2.172886798352815507e-01 4.807480925564590057e-01 5.006795397998469177e-01 5.818100901154411586e-01 2.107716091585690732e-01 6.606606051140029301e-01 9.317629042790995797e-01 9.840326342340242061e-01 5.752000964817773898e-01
|
| 13 |
+
9.843444595454536872e-01 1.339523968066913540e-02 6.082172659959028671e-03 7.828244785439336662e-01 5.069653703872761819e-01 2.804896494365415327e-01 2.112385836660957139e-02 6.016479440778699228e-02 7.457477935084961818e-01 3.445503949245375397e-01 4.063494277166557200e-01 8.630275274433116817e-01 5.948396018456146850e-01 1.400867933474212457e-01 6.997522422654076646e-01 5.766519767930851081e-01 5.419976500582250889e-01 7.474121304089603735e-01 2.951600193008566686e-01 7.980170422334191827e-01 1.829036799578199757e-01 6.317636496261300749e-01 2.812612231140887431e-02 5.464747656105657381e-01 3.909873503320924204e-01 4.940850205957293406e-01 8.157850130814222611e-01 5.111092739445756150e-01 9.336823640685747439e-01 7.157105167170837445e-01 7.778989455994214097e-01 1.398722535910470466e-01 5.642653936300449091e-01 3.218717164845980028e-01 9.717427501967056402e-01 3.665791984428700134e-01 3.874321311211759156e-02 9.437600858738082188e-02 5.679526822961932231e-01 5.141385991358327079e-01 7.497840799582222715e-02 5.736515309094968318e-01 1.928132849879083954e-01 6.924244068001785823e-01 1.748389677952593146e-01 4.469577663506929532e-01 1.738527450963387455e-01 7.195287763517190793e-01 8.861150811892871682e-01 1.058443750714600506e-01 1.941789362229970894e-01 9.188374820700584422e-02 7.706736301449305104e-01 6.718642548609364828e-01 5.981029087121966237e-01 4.832880127232569434e-01 3.073688779938709148e-01 5.156312334804930009e-01 1.777418420119527553e-01 8.885462205165685079e-01 4.486254681289014723e-02 1.345398129556140132e-01 7.467627984379916484e-01 4.384565546058830643e-01 7.217750080760946263e-01 3.949550352625393890e-01 4.307950907642028593e-01 6.087680934849041270e-01 3.294516167246774874e-01 1.316682090209408962e-01 1.824857738754404046e-01 5.332379826483617524e-01 3.567136182864261151e-02 1.976220743086236631e-01 5.849349042822560296e-01 1.133174406357483344e-01 7.711522754393199675e-01 8.557306786807005183e-01 3.038353471344266143e-01 4.422747047768413875e-01 2.537160404215925702e-01 2.372714099723788328e-01 5.906462765375103396e-01 4.849909323133470007e-01 2.692576210504484813e-01 4.540849506602829821e-01 9.664935719107857759e-01 2.044371576459835804e-01 4.505417469690352616e-01 7.110722322201217249e-01 3.051357995214963870e-01 8.978937034341526457e-01 6.090501112506481185e-01 6.595415779178889215e-01 6.565426836745864581e-01 6.565608489824376059e-01 2.679102664248229626e-01 3.819533138204529443e-01 6.609794961162380744e-01 2.289558446859882856e-01
|
| 14 |
+
9.274935298374649140e-01 1.174096651033715855e-01 3.030761852629033637e-01 1.605508209527917174e-01 9.601854834873225775e-01 4.341959513718630648e-01 6.320768160802121560e-01 4.213429090614078110e-01 3.695553969042019160e-01 5.965457437116089556e-01 3.520335041155040479e-01 7.702703502247409961e-01 8.571112772962534709e-01 7.904077282532658844e-01 2.247339318352784554e-01 6.823720204503556097e-01 5.883435710582129996e-02 6.786037033312407596e-01 9.721137137641507886e-01 2.042576970668320557e-01 8.394085754806240862e-01 7.433082729552867862e-01 4.072614159870893147e-01 7.451483066617257123e-01 1.699472962789440045e-01 1.753052015584344314e-01 2.255269204788400428e-01 7.794755643807432799e-01 8.407732260470973662e-01 9.301182862857163558e-01 3.701995309382508648e-01 4.481909027604019657e-01 1.261889085033987001e-01 5.600591735875248833e-01 8.244692493969552061e-01 8.969188061645969601e-01 4.802217973423368313e-01 3.556164122713412201e-02 3.393317823164623270e-01 2.491242957582864292e-01 9.863253789366602797e-01 5.585415885291432625e-01 3.702350606362231344e-01 6.766101432620400535e-01 6.999259389475386284e-01 6.676108316872160220e-01 7.870681827507105544e-01 8.746765411259082024e-01 9.125268371282718727e-01 6.638849997061806452e-01 3.253268113800632522e-01 7.968625619248901337e-01 7.584122525443606211e-01 9.028886850768532701e-01 5.381622293189292083e-02 8.097562873320752752e-01 7.092942088208666895e-01 9.915538877968065323e-01 4.319294903327922652e-01 4.307127933969153721e-01 2.768507739641907772e-01 8.076253078288621046e-01 2.569233696442670967e-01 7.595893829724666979e-01 5.768081727897018673e-01 2.537536777625452045e-01 8.874419624636734616e-01 5.091705681832693342e-01 4.811826624992353585e-01 2.794462461940371290e-01 3.846927898276129021e-01 5.129562951959991679e-01 8.515004062224775794e-01 7.103144978683579858e-01 9.526388607201888847e-01 2.367905569592337889e-01 9.137336039323161740e-01 5.722969943101696710e-02 2.019723935481291255e-01 3.098764675203513619e-02 1.121146613918624357e-01 9.937693067724532314e-01 8.476717958861412772e-02 2.059652110343795917e-01 2.139791918759540446e-01 9.137860316709250919e-01 9.530862653366889425e-03 2.027843281683039400e-03 2.506229951837134484e-01 6.244523528392044165e-01 5.523937894075592325e-01 3.712168074031840792e-01 4.218847794299319665e-01 4.827576239387890711e-01 5.244634168840578425e-01 5.182241092381567604e-01 3.308639956263292881e-03 9.370528021570383448e-01 4.694554875029453012e-01 4.950447554541728135e-01
|
| 15 |
+
1.525818111800841814e-01 4.708012184002630107e-02 3.899035965341954846e-01 3.928304521031263929e-01 5.602286661727436945e-01 9.738256658043862313e-01 9.404465779766183475e-01 5.750862754958349088e-01 9.547546956257608741e-01 2.750275291553152535e-01 1.682773435862793265e-01 5.865928471016079726e-04 8.543378154943809255e-01 3.547649971465383079e-01 5.058056647397523031e-01 9.116332486700751137e-02 7.534666421106954726e-01 3.082429494433007733e-01 4.527145111847344916e-01 5.456680635225539255e-01 2.504131242494785914e-01 2.509240770568589296e-01 3.949236999582302898e-01 8.782959620323271821e-03 2.474641132111736752e-01 8.229417958971670943e-01 3.444225768479134420e-01 4.000027489436257522e-01 4.247741954177396417e-01 2.497745404169693373e-02 4.325768602588443423e-01 7.336592463477830117e-01 7.667663267650381975e-02 4.179022553581047683e-01 8.745172741480690126e-01 9.417705509525042817e-02 2.807522782799587446e-01 8.212710101351362590e-01 2.211181944001613386e-01 4.319929503523877168e-01 1.858636923768219873e-02 6.737037795085246694e-01 7.997187114913413275e-01 2.976552505976116647e-01 3.272347030789168887e-01 5.550935453236346406e-01 9.224109746648162522e-01 3.192827922106745708e-01 3.500098324549234530e-01 7.821988386980260888e-01 4.478417135239194380e-01 1.580956175222456572e-01 5.300807813550156844e-01 5.806154798468634581e-01 9.456842911054151868e-01 7.688127895655872956e-01 8.456527833650537840e-01 1.784229089865225770e-01 8.114517450321339087e-01 8.062506298824222428e-01 2.113482500442499523e-01 2.629226789210241666e-01 6.478686221690072022e-01 6.006672861605766300e-02 7.013679843242253131e-01 8.784753961212666828e-01 3.487138165323044880e-02 4.928426758517070461e-01 5.976224683315064512e-01 7.629063997052759616e-01 2.761721278953045422e-01 7.240740503283805696e-01 6.131065729985127888e-01 1.630885615792579957e-01 8.473783868551159060e-01 8.347614542399306448e-02 8.137265626844719657e-01 8.512508664918938539e-01 2.777097816703766320e-01 1.729154355214796990e-01 2.203382750835449766e-01 6.134780912629795857e-01 3.524352564238901753e-01 5.370314860129862256e-01 8.013986113284543578e-02 2.555842138998117852e-01 6.553915758947851389e-01 9.679125599178584061e-01 2.549566319678178150e-01 4.008180804370896633e-01 9.145789951670967310e-01 2.787926039163850511e-01 8.599455912576436933e-02 9.637558000691170967e-02 8.274101203974880692e-01 1.803747268179315411e-01 2.175735407836230095e-01 7.825994939720237742e-01 7.928519890958951599e-02 8.707949373106749213e-01
|
| 16 |
+
6.398420210047787160e-01 5.739624494012524059e-01 3.359672805578653998e-01 1.130399363175038641e-02 3.349439685346782269e-01 2.315484030880912147e-01 4.575228302577399875e-01 1.149494135594463229e-01 2.888244352925943836e-01 3.625470995156252485e-01 3.795973190611611203e-01 6.567047810450010736e-01 1.484039742710284715e-01 9.273251916560719676e-01 4.334256728976307871e-01 6.734771102219323513e-01 9.125080197222198430e-01 4.974393931097168542e-01 8.301481563280355136e-01 4.526450714147856047e-01 2.414236092573898151e-01 8.070129698367667359e-02 7.260400697427102923e-01 1.396509691839398215e-02 2.496450588391967429e-01 4.335741205447194435e-01 3.089314419194891803e-01 9.543503534526003307e-01 5.457977547458532364e-01 3.139663643587058406e-01 5.034762326753475792e-01 4.756788330475764104e-01 6.849334942793482428e-01 3.880666613022351052e-01 6.483446580176778218e-01 5.217503801099343530e-01 5.371145824070304720e-01 3.121260159429154468e-01 8.314121854062171968e-01 4.538695969561833410e-01 8.598896961203845724e-01 9.961993522734106099e-01 8.865717795946430613e-01 7.828987966783660379e-01 3.412415531643435695e-01 7.421170530151157685e-01 4.484104178639959359e-01 6.793217012099640462e-01 3.756179958191659951e-01 7.821287098222597933e-01 6.227726265188193722e-02 8.552983413221663112e-01 4.824668768009222619e-01 2.241531065858231031e-01 4.939536577599041856e-01 5.129566641128722182e-01 1.057984177672518511e-01 9.541452507300716146e-01 3.396646181755047511e-01 7.452588103611947901e-01 5.315559265659929311e-01 5.493475179850665358e-01 5.214824278139198466e-01 5.150075718147916204e-01 1.196075368500321146e-01 9.035665331176232495e-01 7.522653903639873185e-01 6.638708679914825384e-01 5.584174553800479446e-01 5.015819402508836511e-01 5.507698483308445248e-01 5.978677577011723976e-01 8.450418028759657529e-01 3.266677322748618995e-01 1.321610045897971819e-01 2.394354042746985600e-01 2.723972163557076831e-01 5.523301747352814539e-01 5.518043850608547185e-01 5.283968096837132755e-02 8.192733312104071297e-01 2.277106024970321219e-02 1.414998099027269252e-01 6.517281615256080851e-01 1.811694734825117781e-01 9.472370614713256920e-01 5.454497319021770485e-01 1.364119913158231556e-01 8.446142008509562871e-01 7.671725984742419069e-01 2.461161648406858804e-01 1.421724627107351369e-01 6.290652581179481118e-01 7.094144689448004248e-01 4.419656923472803367e-02 6.614741876652251440e-01 8.712193265403500586e-02 4.734931280852430202e-01 5.382037050480286133e-01 1.396459758005891283e-01
|
| 17 |
+
9.709329844415439670e-01 8.998575745276288229e-01 9.151313462895852568e-01 6.920489275523904471e-01 2.892231405199537919e-01 6.750679746268205550e-01 5.515642485826798280e-01 1.065253097812824956e-01 2.957026803465776510e-01 8.937347659632134400e-01 9.800016515925590310e-01 7.745900896182087436e-01 1.570977683146633774e-01 1.482028765821026273e-01 2.111147779712029271e-01 9.683759902485811200e-01 6.550951580826911425e-01 8.728324682592377703e-01 5.044803166579884257e-01 8.285704754811143991e-01 1.693574499337324735e-02 6.032669995180495182e-02 1.687026879086964692e-01 7.701554026145973619e-01 1.429888016593102718e-01 5.881172815379975827e-02 9.704206919487038396e-01 4.450807650730836951e-01 1.597445784258376689e-01 9.849229394397314152e-01 4.220083573536804744e-01 9.357693600374825671e-01 2.313199262338369033e-01 4.556443403861323294e-01 2.590791012828855822e-01 8.438664994487065085e-01 5.519045677502344427e-01 4.702170125676508050e-01 6.814723205638187897e-01 7.418295483665861001e-01 3.684921032028853904e-01 1.501895844844561845e-01 4.214513377519605308e-01 8.600279963652578408e-01 6.625616611189292238e-01 5.200151456470966105e-01 7.881072743086801058e-01 2.771703241081423519e-01 9.034135930616548071e-01 5.848441705791300738e-01 8.341698181274771473e-01 1.966638677318299777e-01 7.059747894371543042e-01 7.013854316067694716e-01 1.828430942760242983e-01 4.745548949934464966e-01 6.306422394641082452e-01 7.760751707194470939e-01 9.813187212598396547e-01 2.293595795266353266e-01 7.749261876107090830e-01 2.384106107787011819e-01 9.721209688979495223e-01 2.715569353686980714e-01 2.915573577694993146e-01 3.579601509630966349e-01 3.085697512342830962e-01 4.070219981627976047e-01 1.989632411372218579e-01 7.330003339460906542e-01 5.397259604481572381e-01 6.931009942216573849e-01 1.385457419653816080e-01 1.140339999976658358e-01 3.980752590866034613e-01 9.471822621683767540e-01 5.476643721405823895e-01 6.824131903515884279e-02 5.844099130744569992e-01 2.346881692012994236e-01 9.436439228519653000e-01 4.855518260479008141e-02 8.157036123302675579e-01 1.169761256455048581e-01 5.532962903488753970e-01 1.100965596251435308e-01 9.789490602992410029e-01 8.433487462016989733e-01 1.272410782852178013e-01 2.885715258680641160e-01 7.990943955388217779e-01 1.565305358979097727e-01 9.160846960406943129e-02 8.521842244411678147e-01 4.474243106736998099e-01 3.843945818845087015e-01 4.710645906071458944e-01 2.398348154123419729e-01 6.435351435258193087e-01 7.656897921129046658e-01
|
| 18 |
+
4.894328120406804539e-01 7.881019629214267574e-01 6.974585354155089512e-01 2.023858939857701156e-01 1.660984914264745926e-01 4.854517801734643534e-01 2.789848572630315715e-01 2.311636522410289718e-01 9.821076233980715608e-01 1.220641257408076052e-01 2.614036146663852866e-01 7.657560715165320220e-01 3.968360577545695378e-01 4.566023622802184434e-02 1.049701948619241598e-02 9.281162949127452766e-01 4.490137965769909201e-01 2.095846458383606725e-01 9.195504656719085679e-01 9.683515436855471004e-01 9.800174878114910060e-01 5.517610861380117804e-01 6.711570559348770670e-01 5.125258050287277989e-01 2.105581493613526423e-01 8.281813206544574868e-01 4.964783994807770995e-01 7.284974208756571645e-01 1.320629592816270348e-01 6.652194518096135045e-01 9.430156297917950958e-01 7.477263137894260003e-01 2.054087806450300979e-01 4.248209124837907247e-01 7.657518666018259257e-02 1.031614100713345028e-01 4.122242287567021712e-01 4.919658859336810686e-01 3.752650167259050651e-01 4.175771429986683270e-01 6.131376293448997927e-01 5.463797405837259591e-01 3.119918548921774004e-01 6.331762507678504459e-01 5.484632429281035559e-01 6.815448032785871302e-01 8.065695507425107991e-02 8.720129122297424207e-01 8.318188557125294480e-03 2.199323537180564170e-02 8.933872719887463454e-01 1.953120287872067706e-02 2.478721941404590234e-01 5.994061179859005994e-01 6.588362611693047155e-01 6.332808851020984564e-01 3.823849348043323326e-01 5.111091324899629251e-01 7.034808459110406531e-01 4.347681568463539481e-01 4.316973576672314961e-01 9.620411080123215664e-01 6.247837467655984467e-01 8.196961678222113301e-01 5.574601810887074294e-01 8.800635018469276094e-01 8.772255241161972528e-01 5.075275933138404527e-01 8.022583187266906224e-01 2.320670802521890286e-01 1.165626629103270195e-01 4.623759662685936744e-01 7.938327000737943617e-02 7.986374689793115378e-01 6.728842751465858862e-01 8.133909095059230765e-01 1.202639390769081329e-01 1.052937257108800262e-01 8.717600467040409473e-02 2.163819956545051104e-01 6.596483385763984852e-01 1.202843170392309258e-02 1.538789195854695091e-01 3.120247727263308901e-01 3.408168327248596308e-01 3.241861797851740556e-01 3.637074533655986208e-01 1.533669345890729119e-01 4.455921334699539660e-01 5.619140093874478437e-01 1.881731359879111887e-01 9.416670800570559052e-01 1.740018593664415247e-01 7.030242331869680505e-01 5.922055553954849172e-01 9.326211623391688077e-01 6.608322881013140027e-01 7.009721551241574478e-01 1.079126054675583202e-01 6.158176671761947940e-01
|
| 19 |
+
5.185079639625639336e-01 9.613742991518259284e-01 5.555312825626229634e-01 2.647628827924735084e-01 6.003697207460141350e-01 5.392112376769145898e-01 6.781186965667050925e-01 9.908971748181496508e-01 4.124155872095397468e-01 9.814941401724619485e-02 2.684237785531295994e-02 1.774652505962848181e-01 1.707589529595294753e-01 4.640932098465534450e-01 2.882179883914587348e-01 7.276822905806898945e-01 6.145789546745269449e-01 1.100959863917608805e-01 6.798859723042820491e-01 9.096984032948918220e-01 3.971368455178179158e-01 2.959494950971321980e-01 3.742088799298171065e-02 1.960739526210202310e-01 7.536102695342027369e-01 6.680915510628401277e-01 4.136507204312135366e-01 3.613996339406737590e-01 3.605422038261204554e-01 7.098503555159476619e-01 8.093719147087541366e-01 6.344097009128880638e-01 3.990082448083617228e-01 2.805918009906902544e-01 7.078488167363675698e-01 9.969917259866583059e-01 9.442054998992396309e-01 1.329075240769165278e-01 6.810681350588387861e-02 8.503491437913293094e-01 8.347117439165431252e-01 2.381858201903953587e-01 7.884260706938626129e-01 7.109907917419661105e-01 6.390916681983604963e-02 6.174365227062991179e-01 5.085733343630816083e-01 1.716846139694149231e-01 9.065664924270055991e-02 5.625330757196970177e-01 3.539663480209681579e-01 8.937139525947165319e-01 3.981380511900556307e-02 7.403597927449541150e-01 3.803872284089604427e-02 6.729519695709765825e-01 5.306080908840085097e-01 2.091237680402112664e-01 5.902903662907804661e-01 2.094778612095482551e-01 7.323447855684165342e-01 3.644574495843493356e-01 2.006215478057034041e-01 3.737617545555030896e-01 5.253471759602216240e-01 4.287889547869583318e-01 7.086098806190446187e-01 4.510792335515292351e-01 6.383187180169215269e-01 8.779355722397681472e-01 4.221338898667141848e-01 6.375840144651815367e-01 8.683057298299173832e-01 6.093730356952498095e-01 9.297141161056151626e-01 7.770838342807246946e-01 6.549661287008456956e-02 2.835060738158660110e-01 4.474138867374952699e-01 8.530336387421445510e-01 3.160209657891883683e-01 8.301538680518486535e-01 6.646903097549101691e-01 7.187130118106234145e-01 1.651862041735395747e-01 9.578252676762609719e-01 6.490273812885494209e-02 9.777273484666341163e-01 8.930729829254262508e-01 9.851054752118463265e-01 4.094323402286751401e-01 1.139176240124337713e-01 7.612865863899589414e-01 2.266379302491570158e-01 6.998882496157835531e-01 9.945043379099228753e-01 7.111578056749194854e-01 7.806190603886183910e-01 3.410170920712443099e-01 9.446084168886822452e-01
|
| 20 |
+
5.015172758330755931e-01 5.569527971282052237e-01 1.122406928736449094e-01 8.960352822124777461e-01 6.049568585854003810e-02 1.202196001338627918e-01 1.870314295763603196e-01 9.017590029396971296e-01 3.597904628087450485e-01 2.130941062746317671e-01 2.556281834629479111e-01 5.123669364829196438e-01 4.754061129282013409e-01 9.764470380372083369e-01 8.038663983900646848e-01 6.960491266420890666e-01 2.940135977911654264e-01 2.857282759910040326e-03 4.599343225832352999e-02 5.597554495210212977e-01 7.445266674304001908e-01 3.387528030535971180e-01 6.429542922125383031e-01 2.123331785532429627e-01 5.302332654117811739e-01 7.262555377662539557e-01 3.982425859900724507e-01 3.243388301740235402e-01 6.191064123738921898e-01 8.988047781373914580e-01 7.819700328765150088e-01 7.664269102804815992e-01 6.734095355422575757e-03 2.904762329148526945e-01 5.097537644843168625e-01 9.524734606001823423e-01 4.812869576591960463e-01 6.236868013640477493e-01 1.459170943214320726e-01 9.874505139403206844e-01 7.561708982837871407e-01 3.798591332432484924e-01 6.056633451375117438e-01 7.935708170258731764e-01 1.458141583518740569e-01 7.082511296391911237e-01 1.098798009731616343e-02 3.655618484905173160e-01 9.551862303858617009e-01 8.148959351152762487e-02 4.739306219219985294e-02 7.963357515359494876e-01 6.208332695202813944e-01 3.884182264923189409e-01 4.589167647950288531e-01 6.496652974138312775e-01 2.467528128074852889e-01 5.309593064844935206e-01 5.364606369543487574e-01 2.421352989851309756e-01 3.776834556696828660e-02 1.564861233558080267e-01 5.197231021782636740e-01 8.725375120634637494e-01 2.441225493455024820e-01 2.320363366041028330e-01 5.026358683423555185e-01 7.035766000474735771e-01 8.347805591467084563e-01 2.303229841813967393e-01 6.908373419683054850e-01 2.646662377366995056e-01 1.259467197942290007e-01 9.372770922994989595e-01 6.674216272867254940e-01 1.027944489143072238e-01 5.686267290346079806e-01 3.948222804451942958e-01 4.689706944496729868e-01 4.446117700449114807e-02 6.817992275557515081e-01 9.084821829413957106e-01 9.184021015315092518e-01 3.045815734169987632e-01 2.204958624923980537e-03 7.542672057172502553e-01 9.460844786545006269e-01 3.373139094575949848e-02 9.059565314915285494e-01 9.938525461318854504e-01 2.542072661725306437e-01 9.685734112479216229e-02 8.223629541824816203e-01 1.057429056898460118e-01 8.080679390260248063e-01 5.823014244609205914e-01 6.413551528031806725e-01 1.787341975438894170e-01 1.250471413912357388e-01 8.390281297596062782e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-euclidean-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
4.0515260e+00 4.2121458e+00 3.7357405e+00 4.2313317e+00 3.9136009e+00 4.3843298e+00 3.9811426e+00 4.3624182e+00 4.0642508e+00 4.2105933e+00 4.0747226e+00 3.9068586e+00 4.1637004e+00 4.4303203e+00 4.1841564e+00 4.1063279e+00 4.1862390e+00 4.0719925e+00 4.2227579e+00 4.3173531e+00 3.8811067e+00 3.7577567e+00 4.0623722e+00 3.9882453e+00 4.0432671e+00 3.9085109e+00 4.0283414e+00 4.0846110e+00 3.6459235e+00 3.9544001e+00 4.1134244e+00 4.1805752e+00 3.5121011e+00 4.2747789e+00 4.1048323e+00 3.9269426e+00 3.8932032e+00 3.8281172e+00 3.7288430e+00 4.0863477e+00 4.1527428e+00 4.1646409e+00 4.2027433e+00 3.8441594e+00 4.8419117e+00 4.2455384e+00 3.7622220e+00 4.3967923e+00 4.4663183e+00 4.0435853e+00 4.0421692e+00 4.3124625e+00 4.6499961e+00 4.5595743e+00 3.4230430e+00 4.2612266e+00 3.5676603e+00 4.0866580e+00 4.2307103e+00 3.8521940e+00 3.9951183e+00 3.1022409e+00 3.7290193e+00 4.1931517e+00 4.1127027e+00 3.6633651e+00 4.0235815e+00 3.9729858e+00 4.1980132e+00 4.1579993e+00 3.9948955e+00 3.9081966e+00 3.9031152e+00 3.5069036e+00 4.0015727e+00 3.6763496e+00 3.6614339e+00 3.6227109e+00 3.7357992e+00 4.0170026e+00 3.5216829e+00 3.9322227e+00 3.9094621e+00 4.0170286e+00 4.3264246e+00 4.3435483e+00 4.0788635e+00 4.4761765e+00 3.8468186e+00 4.1490333e+00 4.2800007e+00 4.2260191e+00 4.3031858e+00 4.1897413e+00 4.0530244e+00 3.5893641e+00 4.2186615e+00 3.7979503e+00 4.0915473e+00 4.1343073e+00 4.5063851e+00 3.6394889e+00 4.2508448e+00 3.7160826e+00 4.0105262e+00 4.1578269e+00 4.0290590e+00 3.6971819e+00 3.9414087e+00 4.2522313e+00 4.4091714e+00 4.1542292e+00 3.9594691e+00 4.0923600e+00 4.0855497e+00 3.8253075e+00 4.3034717e+00 4.0976731e+00 4.1316523e+00 4.0872717e+00 4.2643353e+00 3.8887280e+00 3.9411273e+00 3.8848001e+00 4.3481996e+00 3.8716733e+00 3.9084684e+00 3.7546361e+00 3.9354816e+00 3.8293694e+00 3.7568515e+00 3.7184961e+00 3.8404278e+00 4.2570811e+00 4.1423777e+00 4.0291411e+00 4.2094682e+00 3.6127418e+00 4.0459839e+00 3.7737985e+00 3.7647653e+00 3.9762006e+00 3.8999512e+00 3.8509090e+00 3.8975941e+00 3.8432839e+00 4.2109046e+00 4.1339124e+00 3.5898873e+00 4.0794519e+00 4.3504966e+00 3.8862612e+00 3.8332931e+00 4.2190310e+00 4.1366595e+00 3.7220268e+00 4.1250795e+00 3.3169452e+00 4.0757181e+00 3.6487114e+00 3.9513724e+00 4.0735549e+00 3.9137880e+00 3.9656942e+00 3.7724953e+00 4.0505153e+00 3.9062302e+00 4.5671852e+00 3.7542175e+00 4.3731708e+00 3.6733907e+00 4.4667545e+00 4.1004635e+00 4.0530038e+00 4.0346958e+00 4.2145752e+00 4.4298637e+00 4.2982360e+00 4.0878239e+00 4.4061563e+00 4.2115971e+00 3.8263277e+00 3.8603258e+00 3.8572375e+00 4.1051910e+00 4.3787786e+00 4.5309659e+00 4.0047055e+00 4.1308854e+00 3.6283561e+00
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-hamming-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
4.6000000e-01 4.3000000e-01 4.3000000e-01 5.4000000e-01 4.1000000e-01 5.3000000e-01 4.3000000e-01 5.9000000e-01 4.8000000e-01 4.7000000e-01 4.6000000e-01 4.9000000e-01 4.5000000e-01 5.5000000e-01 5.3000000e-01 4.5000000e-01 4.8000000e-01 4.7000000e-01 4.8000000e-01 5.1000000e-01 4.9000000e-01 4.4000000e-01 4.9000000e-01 4.7000000e-01 4.9000000e-01 4.7000000e-01 5.2000000e-01 4.7000000e-01 4.2000000e-01 4.9000000e-01 4.7000000e-01 5.5000000e-01 3.9000000e-01 5.5000000e-01 4.6000000e-01 4.5000000e-01 4.0000000e-01 4.8000000e-01 4.5000000e-01 4.8000000e-01 4.8000000e-01 5.0000000e-01 4.8000000e-01 4.5000000e-01 6.4000000e-01 5.7000000e-01 4.6000000e-01 5.4000000e-01 5.6000000e-01 4.8000000e-01 4.8000000e-01 5.3000000e-01 5.4000000e-01 5.3000000e-01 4.5000000e-01 5.8000000e-01 4.2000000e-01 5.4000000e-01 6.0000000e-01 5.1000000e-01 4.6000000e-01 4.1000000e-01 4.4000000e-01 5.6000000e-01 5.4000000e-01 4.8000000e-01 4.8000000e-01 5.1000000e-01 5.2000000e-01 5.5000000e-01 4.5000000e-01 4.3000000e-01 4.7000000e-01 4.7000000e-01 5.6000000e-01 4.9000000e-01 4.8000000e-01 4.5000000e-01 4.9000000e-01 4.7000000e-01 4.5000000e-01 4.5000000e-01 5.6000000e-01 4.9000000e-01 5.8000000e-01 5.4000000e-01 4.6000000e-01 5.8000000e-01 5.3000000e-01 5.4000000e-01 5.5000000e-01 5.0000000e-01 5.2000000e-01 4.8000000e-01 5.0000000e-01 3.8000000e-01 5.3000000e-01 4.8000000e-01 5.1000000e-01 4.8000000e-01 5.2000000e-01 4.7000000e-01 5.0000000e-01 4.3000000e-01 4.8000000e-01 5.2000000e-01 5.0000000e-01 4.2000000e-01 4.2000000e-01 4.7000000e-01 5.4000000e-01 5.1000000e-01 5.4000000e-01 5.1000000e-01 4.8000000e-01 4.7000000e-01 5.2000000e-01 5.2000000e-01 5.4000000e-01 5.4000000e-01 5.0000000e-01 4.5000000e-01 4.4000000e-01 4.1000000e-01 5.7000000e-01 4.6000000e-01 5.1000000e-01 5.2000000e-01 5.0000000e-01 4.8000000e-01 5.0000000e-01 4.4000000e-01 5.3000000e-01 5.2000000e-01 4.9000000e-01 5.7000000e-01 5.8000000e-01 4.9000000e-01 5.1000000e-01 4.5000000e-01 5.3000000e-01 4.5000000e-01 4.4000000e-01 3.5000000e-01 4.2000000e-01 5.3000000e-01 5.2000000e-01 5.0000000e-01 3.8000000e-01 5.2000000e-01 5.6000000e-01 4.7000000e-01 4.4000000e-01 5.1000000e-01 5.7000000e-01 4.5000000e-01 5.7000000e-01 4.3000000e-01 5.1000000e-01 3.8000000e-01 5.3000000e-01 4.8000000e-01 4.4000000e-01 5.0000000e-01 4.8000000e-01 5.0000000e-01 4.7000000e-01 6.4000000e-01 4.9000000e-01 5.2000000e-01 4.8000000e-01 5.6000000e-01 4.3000000e-01 4.8000000e-01 4.7000000e-01 6.0000000e-01 5.4000000e-01 5.5000000e-01 4.0000000e-01 5.5000000e-01 5.6000000e-01 4.9000000e-01 5.0000000e-01 4.3000000e-01 5.7000000e-01 5.0000000e-01 5.7000000e-01 4.9000000e-01 4.2000000e-01 3.9000000e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jaccard-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
6.5714286e-01 6.0563380e-01 6.3235294e-01 7.3972603e-01 6.0294118e-01 7.3611111e-01 6.4179104e-01 7.7631579e-01 6.4000000e-01 6.6197183e-01 6.6666667e-01 7.0000000e-01 6.4285714e-01 7.7464789e-01 7.1621622e-01 6.4285714e-01 6.8571429e-01 6.4383562e-01 6.6666667e-01 6.5384615e-01 6.6216216e-01 6.1971831e-01 6.5333333e-01 6.5277778e-01 6.7123288e-01 6.4383562e-01 6.5000000e-01 6.3513514e-01 6.0000000e-01 6.7123288e-01 6.3513514e-01 7.4324324e-01 5.5714286e-01 7.0512821e-01 6.3888889e-01 6.0000000e-01 5.6338028e-01 6.3157895e-01 6.0810811e-01 6.2337662e-01 6.4000000e-01 6.5789474e-01 6.3157895e-01 5.6962025e-01 7.5294118e-01 7.1250000e-01 6.2162162e-01 6.7500000e-01 7.2727273e-01 6.2337662e-01 6.2337662e-01 6.7948718e-01 6.5853659e-01 6.6250000e-01 6.3380282e-01 7.3417722e-01 6.0869565e-01 7.2000000e-01 7.5949367e-01 6.4556962e-01 6.3013699e-01 5.9420290e-01 6.2857143e-01 7.1794872e-01 7.3972603e-01 6.4864865e-01 6.4864865e-01 6.8918919e-01 6.6666667e-01 7.0512821e-01 6.2500000e-01 6.2318841e-01 6.6197183e-01 6.5277778e-01 6.9135802e-01 6.6216216e-01 6.6666667e-01 6.4285714e-01 6.6216216e-01 6.8115942e-01 6.2500000e-01 6.2500000e-01 7.3684211e-01 6.4473684e-01 7.3417722e-01 7.1052632e-01 6.3888889e-01 7.3417722e-01 6.5432099e-01 6.9230769e-01 7.1428571e-01 6.7567568e-01 6.7532468e-01 6.7605634e-01 6.5789474e-01 5.4285714e-01 6.9736842e-01 6.2337662e-01 6.6233766e-01 6.7605634e-01 7.0270270e-01 6.1842105e-01 6.7567568e-01 6.2318841e-01 6.7605634e-01 6.9333333e-01 7.1428571e-01 6.0000000e-01 6.0000000e-01 6.6197183e-01 6.9230769e-01 6.8000000e-01 7.2000000e-01 6.5384615e-01 6.5753425e-01 6.6197183e-01 7.1232877e-01 6.9333333e-01 7.5000000e-01 7.1052632e-01 6.7567568e-01 6.4285714e-01 6.0273973e-01 5.8571429e-01 6.9512195e-01 6.3013699e-01 6.8918919e-01 7.0270270e-01 6.6666667e-01 6.8571429e-01 6.6666667e-01 6.1111111e-01 7.0666667e-01 6.6666667e-01 6.5333333e-01 6.8674699e-01 7.0731707e-01 6.3636364e-01 6.3750000e-01 6.1643836e-01 6.5432099e-01 5.8441558e-01 5.8666667e-01 4.7297297e-01 5.5263158e-01 6.9736842e-01 6.9333333e-01 6.5789474e-01 5.7575758e-01 6.7532468e-01 7.0886076e-01 6.4383562e-01 5.8666667e-01 6.6233766e-01 7.5000000e-01 6.2500000e-01 7.7027027e-01 6.0563380e-01 6.8000000e-01 5.6716418e-01 6.7948718e-01 6.4864865e-01 6.1971831e-01 7.1428571e-01 6.5753425e-01 6.7567568e-01 6.6197183e-01 7.7108434e-01 6.6216216e-01 7.1232877e-01 6.4000000e-01 7.0886076e-01 6.0563380e-01 6.2337662e-01 6.2666667e-01 7.7922078e-01 7.2972973e-01 7.5342466e-01 5.7971014e-01 7.3333333e-01 7.0886076e-01 6.6216216e-01 6.4102564e-01 5.8904110e-01 7.3076923e-01 6.4102564e-01 7.1250000e-01 6.4473684e-01 5.9154930e-01 5.3424658e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-jensenshannon-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
0.320369972991 0.338972466 0.308199372323 0.3452431902 0.310024768313 0.357115225615 0.311131096357 0.357391534414 0.329718053755 0.347365921475 0.335272625287 0.336451560653 0.33015370606 0.369628769749 0.344499490029 0.321622508707 0.345377707016 0.321007207534 0.350728979121 0.32809430086 0.30207071308 0.291663252492 0.30760470102 0.315976639534 0.308132467187 0.313014586878 0.310463895925 0.321091616502 0.290044394125 0.322213459935 0.315509196522 0.3331114403 0.281071919202 0.320854431887 0.332190658438 0.299342730178 0.313528775154 0.310049073937 0.288821516545 0.307662081954 0.328387688508 0.317185603454 0.332046170365 0.291912213887 0.37870970117 0.336080073379 0.304593343921 0.330138983604 0.355071759299 0.311946140607 0.302025400768 0.330940761586 0.351140062502 0.354772884287 0.272605322053 0.327957349848 0.28871110366 0.320821172951 0.340976919806 0.30757488831 0.320975346884 0.252776262329 0.314549731907 0.326876483 0.337684418756 0.296520013735 0.31493077245 0.327721982167 0.325802862624 0.341908184107 0.300481749419 0.312499767894 0.301061762121 0.27665157989 0.3082566692 0.287466396145 0.288313694552 0.296629698731 0.283556095025 0.322489360684 0.280765581604 0.297958166613 0.313189657041 0.303470399659 0.348652898212 0.331594734387 0.299446687464 0.339047458559 0.286979246044 0.316326095312 0.321618884109 0.330065896317 0.324500638067 0.328300795872 0.309002568222 0.262587468469 0.31974123777 0.286316182293 0.321162329165 0.328160620315 0.356618051635 0.289733970648 0.344507756538 0.301485561986 0.335785898715 0.322635066518 0.331480718646 0.297897604494 0.306942928189 0.350843442517 0.342585296966 0.341311053315 0.306780105123 0.313401804298 0.319978145568 0.302460397612 0.346105758567 0.312802351189 0.331552275517 0.321624157344 0.318798118247 0.301906095501 0.301585920138 0.314556178985 0.333215221158 0.306929663844 0.317083256901 0.309667679181 0.306529028004 0.30865993751 0.296031907986 0.28742420979 0.311584483038 0.319043629504 0.330278008622 0.314466433681 0.327937382021 0.296448162218 0.307033121385 0.296391953011 0.292691206116 0.297146209653 0.307929858983 0.291863681454 0.307300188104 0.306597817799 0.34718100163 0.317436210259 0.29952626739 0.330762834707 0.334951064852 0.323806678898 0.296203706701 0.33398466797 0.344931265559 0.293948734727 0.332764639313 0.272651853935 0.317324315923 0.300493570867 0.307008231016 0.333263322802 0.31390648462 0.332416491248 0.314766869708 0.321015549211 0.322909289307 0.356882966656 0.310596945263 0.343939748528 0.286269629586 0.33173459898 0.323848483719 0.305841388975 0.319266258167 0.34012363898 0.3443280395 0.353885654057 0.320544729867 0.353280499623 0.315621795536 0.312176062734 0.301562130879 0.312061680573 0.312642847966 0.326222109701 0.357417912858 0.313083593142 0.334033412713 0.295630506074
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
2.0215050e+00 2.0988154e+00 1.8614681e+00 2.0510161e+00 1.9210911e+00 2.1323516e+00 1.9565454e+00 2.1029889e+00 1.9617871e+00 2.0544792e+00 2.0357408e+00 1.8811414e+00 2.0694693e+00 2.1245977e+00 2.0632165e+00 2.0452823e+00 2.0249330e+00 1.9635489e+00 2.0508580e+00 2.0838578e+00 1.9324052e+00 1.8224609e+00 1.9795343e+00 1.9536534e+00 1.9694910e+00 1.9075569e+00 1.9590397e+00 2.0022087e+00 1.8814000e+00 1.8884208e+00 1.9961121e+00 2.0215351e+00 1.7515769e+00 2.0756437e+00 2.0109476e+00 1.9234849e+00 1.9160076e+00 1.8550862e+00 1.7733640e+00 2.0071906e+00 2.0209542e+00 2.0616569e+00 2.0565503e+00 1.9083573e+00 2.2732431e+00 1.9975503e+00 1.9080072e+00 2.1437809e+00 2.1296295e+00 1.9739085e+00 1.9834166e+00 2.1078664e+00 2.2016840e+00 2.2080962e+00 1.7340579e+00 2.0549287e+00 1.7331748e+00 1.9559688e+00 2.0343364e+00 1.8736929e+00 1.9730416e+00 1.5308944e+00 1.8421831e+00 2.0174240e+00 2.0137378e+00 1.7956151e+00 1.9606596e+00 1.9074857e+00 2.0413879e+00 2.0070305e+00 1.9584677e+00 1.8977851e+00 1.9176239e+00 1.7067419e+00 1.9461927e+00 1.8431700e+00 1.8284576e+00 1.7778704e+00 1.8350329e+00 2.0175415e+00 1.7459063e+00 1.9242505e+00 1.8757370e+00 1.9312506e+00 2.0574808e+00 2.0894636e+00 1.9780203e+00 2.1374036e+00 1.8900436e+00 2.0273032e+00 2.0681953e+00 2.0234699e+00 2.0666449e+00 2.0663485e+00 1.9281402e+00 1.7846314e+00 2.0372479e+00 1.8831230e+00 2.0186015e+00 2.0193231e+00 2.2022665e+00 1.8145737e+00 2.0466545e+00 1.8092421e+00 1.9600687e+00 2.0322961e+00 1.9556364e+00 1.8266422e+00 1.9950345e+00 2.1038429e+00 2.1164145e+00 2.0188062e+00 1.8863331e+00 2.0006971e+00 1.9971068e+00 1.8771862e+00 2.1148855e+00 1.9570638e+00 1.9859615e+00 2.0030854e+00 2.0737344e+00 1.9739259e+00 1.9266524e+00 1.9200535e+00 2.1376689e+00 1.8944425e+00 1.9330553e+00 1.8561590e+00 1.9422954e+00 1.8874178e+00 1.8624808e+00 1.8265563e+00 1.8840519e+00 2.0515092e+00 2.0174226e+00 1.9771196e+00 2.0635988e+00 1.7334466e+00 1.9912604e+00 1.8915711e+00 1.8262636e+00 1.9369173e+00 1.9560446e+00 1.9549934e+00 1.9279230e+00 1.9021073e+00 2.0113391e+00 2.0305786e+00 1.8066806e+00 1.9656739e+00 2.1219217e+00 1.8820250e+00 1.8936826e+00 2.0565131e+00 1.9839441e+00 1.8553479e+00 1.9923760e+00 1.6393276e+00 1.9786440e+00 1.8274394e+00 1.9322611e+00 2.0404318e+00 1.9216532e+00 1.9361171e+00 1.8401373e+00 1.9908059e+00 1.9495117e+00 2.1975655e+00 1.8413913e+00 2.1528773e+00 1.8434374e+00 2.1668863e+00 2.0429273e+00 1.9980016e+00 1.9790129e+00 2.0264829e+00 2.1478843e+00 2.0899600e+00 2.0280670e+00 2.1210881e+00 1.9993891e+00 1.8646871e+00 1.9099983e+00 1.9263353e+00 2.0042495e+00 2.1365919e+00 2.1830279e+00 1.9631961e+00 2.0880004e+00 1.8348369e+00
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-seuclidean-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
1.4330520e+01 1.4635426e+01 1.3450855e+01 1.4761140e+01 1.3508642e+01 1.5434417e+01 1.3887693e+01 1.5166776e+01 1.3966038e+01 1.4950451e+01 1.4564587e+01 1.3834201e+01 1.4347008e+01 1.5641962e+01 1.4689053e+01 1.4418720e+01 1.4545856e+01 1.4151822e+01 1.4669017e+01 1.5150750e+01 1.3770166e+01 1.3288969e+01 1.4048191e+01 1.4049959e+01 1.4164158e+01 1.3727834e+01 1.4074687e+01 1.4321303e+01 1.2497330e+01 1.3820273e+01 1.4441030e+01 1.4780222e+01 1.2504339e+01 1.5022245e+01 1.4263650e+01 1.3704507e+01 1.3694385e+01 1.3667517e+01 1.3177468e+01 1.4391931e+01 1.4893903e+01 1.4475753e+01 1.4440707e+01 1.3603096e+01 1.6889651e+01 1.4731174e+01 1.3337775e+01 1.5187532e+01 1.5667271e+01 1.4226037e+01 1.4203554e+01 1.5272898e+01 1.6031460e+01 1.5991549e+01 1.1855060e+01 1.4844776e+01 1.2475182e+01 1.4408126e+01 1.4836870e+01 1.3472986e+01 1.4089281e+01 1.1018298e+01 1.3183296e+01 1.4590802e+01 1.4404230e+01 1.2717623e+01 1.3983283e+01 1.4017133e+01 1.4608005e+01 1.4402553e+01 1.3977803e+01 1.4091040e+01 1.3977459e+01 1.2630449e+01 1.4160109e+01 1.3029417e+01 1.2654432e+01 1.2794946e+01 1.3194978e+01 1.4378745e+01 1.2431908e+01 1.3852651e+01 1.3748358e+01 1.4003568e+01 1.5066681e+01 1.5192826e+01 1.4370013e+01 1.5792545e+01 1.3547546e+01 1.4411543e+01 1.4794215e+01 1.4924312e+01 1.4789153e+01 1.4875055e+01 1.4208537e+01 1.2786148e+01 1.4882476e+01 1.3302010e+01 1.4354774e+01 1.4542129e+01 1.5889633e+01 1.2928185e+01 1.4877868e+01 1.2890902e+01 1.4406165e+01 1.4498123e+01 1.4303273e+01 1.3207002e+01 1.3954732e+01 1.4841248e+01 1.5427799e+01 1.4363463e+01 1.3976277e+01 1.4284878e+01 1.4457991e+01 1.3369469e+01 1.5246610e+01 1.4487573e+01 1.4525176e+01 1.4505865e+01 1.5037347e+01 1.3834927e+01 1.3758988e+01 1.3424987e+01 1.4914766e+01 1.3783923e+01 1.3434291e+01 1.2895927e+01 1.3870360e+01 1.3342977e+01 1.3094322e+01 1.3057847e+01 1.3322375e+01 1.4940650e+01 1.4476829e+01 1.4197503e+01 1.4597035e+01 1.2963234e+01 1.4011414e+01 1.3181409e+01 1.3339615e+01 1.3928735e+01 1.3508015e+01 1.3170749e+01 1.3529133e+01 1.3454724e+01 1.4883437e+01 1.4564565e+01 1.2474313e+01 1.4435790e+01 1.5285703e+01 1.3701736e+01 1.3578312e+01 1.4807311e+01 1.4281072e+01 1.2920213e+01 1.4427803e+01 1.1408611e+01 1.4097334e+01 1.2868115e+01 1.3903683e+01 1.3800332e+01 1.3439339e+01 1.4062651e+01 1.3242107e+01 1.4400424e+01 1.3826132e+01 1.5991146e+01 1.3118258e+01 1.5377390e+01 1.2858378e+01 1.5249567e+01 1.4081585e+01 1.4458052e+01 1.4175623e+01 1.4850069e+01 1.5506668e+01 1.5014770e+01 1.4337030e+01 1.5214705e+01 1.4803729e+01 1.3188675e+01 1.3437739e+01 1.3409394e+01 1.4607386e+01 1.5394271e+01 1.5946451e+01 1.3769364e+01 1.4181208e+01 1.2551765e+01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/pdist-spearman-ml.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
9.3540954e-01 9.7904590e-01 8.6703870e-01 1.1569997e+00 8.7174317e-01 1.0627183e+00 9.1272727e-01 1.1593999e+00 9.7573357e-01 1.0072127e+00 1.0536814e+00 9.6276028e-01 9.7700570e-01 1.1513951e+00 1.0719592e+00 9.2178818e-01 1.0004680e+00 9.3689769e-01 9.8205821e-01 1.0332673e+00 9.4517852e-01 8.9437744e-01 9.7556556e-01 9.0460246e-01 9.7210921e-01 9.2230423e-01 9.9605161e-01 9.6852085e-01 8.4162016e-01 9.6667267e-01 9.7759376e-01 9.9757576e-01 7.6992499e-01 1.0151695e+00 9.8691869e-01 9.0325833e-01 8.6665467e-01 8.8844884e-01 8.4553255e-01 9.7700570e-01 9.5159916e-01 9.8906691e-01 1.0551935e+00 9.1973597e-01 1.3266247e+00 1.0982778e+00 8.4531653e-01 1.0887369e+00 1.0984938e+00 9.9851185e-01 9.0701470e-01 1.0639304e+00 1.2392919e+00 1.1422502e+00 8.1725773e-01 1.1844944e+00 7.8219022e-01 1.0817162e+00 1.2196100e+00 1.0003120e+00 1.0164536e+00 7.0724272e-01 9.7981398e-01 1.1134953e+00 1.0671107e+00 9.3600960e-01 9.9984398e-01 1.0356916e+00 1.1248005e+00 1.0696310e+00 1.0634263e+00 9.6472847e-01 9.9365137e-01 8.5724572e-01 1.1257846e+00 8.9930993e-01 9.4903090e-01 9.0667867e-01 9.1231923e-01 1.0573777e+00 9.0105011e-01 9.5255926e-01 1.0177978e+00 1.0606901e+00 1.1966997e+00 1.0891929e+00 1.0085089e+00 1.2640264e+00 9.3246925e-01 1.0198020e+00 1.2055806e+00 1.1237924e+00 1.1060666e+00 1.0517252e+00 1.0684668e+00 7.6844884e-01 1.0572697e+00 8.7373537e-01 9.6283228e-01 9.9350735e-01 1.2412601e+00 7.6322832e-01 1.0298950e+00 8.6148215e-01 1.0042724e+00 9.7012901e-01 9.3712571e-01 8.5845785e-01 8.5862586e-01 1.0336634e+00 1.0955536e+00 9.5302730e-01 9.8696670e-01 1.0633063e+00 1.0026643e+00 9.6380438e-01 1.1711251e+00 9.9273927e-01 1.0260906e+00 1.0863966e+00 1.0482808e+00 9.0361836e-01 9.2358836e-01 8.7794779e-01 1.2461206e+00 9.2985299e-01 1.0418962e+00 9.4660666e-01 9.5636364e-01 9.0646265e-01 9.9113111e-01 8.3027903e-01 9.3341734e-01 1.1378938e+00 1.0548215e+00 1.0086889e+00 1.1998920e+00 8.6063006e-01 1.0255506e+00 8.4786079e-01 1.0090729e+00 9.2542454e-01 9.5176718e-01 9.3477348e-01 9.0091809e-01 9.6404440e-01 1.1158716e+00 9.9614761e-01 7.7682568e-01 1.0605461e+00 1.0895650e+00 9.0065407e-01 8.7173117e-01 9.9821182e-01 1.2165617e+00 8.6127813e-01 1.1111071e+00 7.9015902e-01 1.0433843e+00 8.6510651e-01 1.0019202e+00 1.0154815e+00 9.4381038e-01 9.8646265e-01 1.0062526e+00 9.7426943e-01 9.8191419e-01 1.3038944e+00 8.6277828e-01 1.0830243e+00 8.6851485e-01 1.1192559e+00 9.9120312e-01 9.6540054e-01 9.1072307e-01 1.1775698e+00 1.1139154e+00 1.1083468e+00 9.9593159e-01 1.0825923e+00 1.1115032e+00 9.7430543e-01 9.5605161e-01 9.2800480e-01 9.4369037e-01 1.1136034e+00 1.1382898e+00 9.5937594e-01 9.8843084e-01 7.4563456e-01
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-bool-data.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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1 1 1 1 1 1 0 0
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-double-data.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1.172993630434470589e+02 1.905532343119886605e+02 2.613653823499444115e+02 1.570270816248337269e+02 2.373767637129340642e+02 2.175366144750510671e+02 2.609909144757107242e+02 2.086671686166440622e+02 2.674986450118991002e+02 1.395992762090408235e+02 1.115453060949917159e+02 1.531034842395609701e+02 2.621042034264289668e+02 2.958729454449504033e+02 2.137960368830719062e+02 2.606436280968571282e+02 2.492136530687155869e+02 2.770806237064748530e+02 2.667325121892417883e+02 2.909243437665674037e+02 1.570328417294508085e+02 1.738762543815240917e+02 1.514157955792608163e+02 2.264748814818163396e+02 1.911869834397498380e+02 2.083706054660671043e+02 2.778115921852293013e+02 1.330374814391803397e+02 2.988697222234711717e+02 2.534167825404447001e+02
|
| 2 |
+
2.090964891529778242e+02 1.322006104643973003e+02 1.443415945355371832e+02 2.991388772264980389e+02 1.649302344777914868e+02 2.839528641910463875e+02 1.677159709681393736e+02 2.597553832458208944e+02 2.861055547321268477e+02 1.866431671806918189e+02 2.131812134614140177e+02 1.881465139477683124e+02 1.271865139985419262e+02 1.821608865941132649e+02 2.793653846657656459e+02 1.745982981552271838e+02 2.440893905635109888e+02 1.926469151980868446e+02 2.752453852984189098e+02 1.333479229516146347e+02 1.756311805755703404e+02 2.039367615619088383e+02 2.441861159155101575e+02 2.136111324500645594e+02 2.893808960992043922e+02 2.723220466017930335e+02 2.367879096909125565e+02 2.831541206793258425e+02 2.017643187924728068e+02 1.293072046241175030e+02
|
| 3 |
+
2.311242818257193221e+02 2.180694109009666306e+02 2.728791416531455525e+02 1.239345918565636993e+02 2.885729762050686418e+02 2.082619393005260804e+02 2.331416004257805525e+02 1.003112528445347778e+02 2.796331120515330895e+02 2.804679740148056339e+02 2.466936828597247597e+02 1.422398585800914361e+02 1.312115029632765015e+02 1.324417143647877708e+02 2.161716508991076466e+02 1.791489656100356171e+02 2.239038785146145472e+02 2.456511993086799919e+02 2.885023077068626662e+02 2.127338775308419940e+02 2.468090724782538246e+02 2.704135008577740109e+02 1.144148504575758665e+02 1.641571759150080538e+02 2.473349551308716343e+02 2.366620528761779667e+02 1.208143167141831498e+02 1.403705034199327599e+02 2.061073908129479548e+02 1.482034962693051057e+02
|
| 4 |
+
1.938319500339997035e+02 2.000523826243218650e+02 1.356134735235139317e+02 1.224357428573656250e+02 1.262840705282213918e+02 1.112797762573139977e+02 1.727826315738305993e+02 2.199559683100150664e+02 1.817290208723558180e+02 2.185579898773881951e+02 1.772844462934412491e+02 1.589145011846130728e+02 1.017520743541414703e+02 2.836990856171782980e+02 1.265544072638776640e+02 2.503473341476423855e+02 2.178539278172635534e+02 2.063574432066289432e+02 1.473169457524925861e+02 1.112719632489760784e+02 1.195996070145015722e+02 1.345099678548529312e+02 2.992645259487585463e+02 2.692242364540683752e+02 2.139649193607747861e+02 2.313659165106297451e+02 2.524185025119667785e+02 2.678714004815313388e+02 1.111457754393238702e+02 1.296443575800298902e+02
|
| 5 |
+
1.183944097426736306e+02 2.750477277868330930e+02 1.688558971333346790e+02 1.432283295687057034e+02 2.226043174503911359e+02 1.825124733235978169e+02 1.806485153578007612e+02 2.270256019866706936e+02 2.852913053786990076e+02 2.867562520175486043e+02 2.795056496733417362e+02 1.142488895870292822e+02 1.502985045661773427e+02 2.246907359526948937e+02 2.051158858061974115e+02 2.663351441156772808e+02 2.864853431806749882e+02 2.276548949573071070e+02 2.678087640355958001e+02 2.266463576941352187e+02 1.886763304826383774e+02 1.150603609957262563e+02 1.596187994714221929e+02 1.844565420383776484e+02 1.730173420200940768e+02 1.427940137102308995e+02 1.774757620992130001e+02 2.563086691508434001e+02 1.666317348809653822e+02 1.878143419608473437e+02
|
| 6 |
+
1.642344698640436036e+02 1.591648429561690818e+02 1.561851029939521140e+02 1.854367091922420059e+02 1.494951311500319093e+02 2.443780767043579942e+02 2.741090240793212160e+02 1.519200656263381006e+02 1.391711947382712538e+02 1.482414334940778815e+02 2.574425018646875287e+02 1.455120022089010945e+02 1.620904376421240727e+02 2.098493186451893848e+02 2.377904829227144887e+02 2.881187570801528750e+02 1.785609418793050054e+02 1.500483139796714340e+02 1.697371065898091729e+02 1.824143324642365087e+02 2.329862749140337712e+02 1.372006180078979298e+02 2.250666134242961789e+02 1.760894707637434067e+02 1.874161150869196035e+02 2.860410495381969440e+02 1.539271628213176086e+02 1.051658254213322152e+02 1.501619097950496666e+02 1.205717364486104515e+02
|
| 7 |
+
1.275638286377957371e+02 2.620802183565458563e+02 2.290828196339760723e+02 2.591630015014513333e+02 2.102568650793322149e+02 2.385080320420775593e+02 2.683788150825365619e+02 1.808700201925492763e+02 1.972184450648797451e+02 2.382313686117472287e+02 1.733526990293641177e+02 2.369802981553972074e+02 1.835652530901061823e+02 1.274084560526275141e+02 2.403488205519001326e+02 2.713515297463850402e+02 1.455311801633137065e+02 1.889430214806582171e+02 1.676324321357484735e+02 2.327799977696781184e+02 2.846419393176552148e+02 1.510702433968490936e+02 1.361559014852734606e+02 1.732199851325496525e+02 2.451323003571785364e+02 1.833444866660036894e+02 2.451280287301300405e+02 1.669088211440060832e+02 2.768492228383354359e+02 2.445882168033535038e+02
|
| 8 |
+
2.905092787520428601e+02 2.948076984760371033e+02 1.731080208454208673e+02 2.825532355845657548e+02 1.108820315678514845e+02 2.862013985457700755e+02 2.111453776876104769e+02 2.614428154999528147e+02 1.461523265575596042e+02 2.304914832379158156e+02 2.502987607420118934e+02 2.474276046141548875e+02 1.739607960146905725e+02 2.098700376203710789e+02 2.373226438948917121e+02 1.258493219462072119e+02 2.692932028872633055e+02 2.819145908444669999e+02 1.941653933285864468e+02 1.666395497972145847e+02 2.371919109091950588e+02 1.978302896313488191e+02 1.951483674191611613e+02 2.694357972099330141e+02 2.387068160427941450e+02 2.826084316255729618e+02 1.350954172043159929e+02 1.414479610501084039e+02 1.407657276334374501e+02 2.725513503737778365e+02
|
| 9 |
+
2.055761393809777360e+02 1.070553196069381556e+02 1.045726024365074096e+02 1.611577217417760153e+02 1.258091705742062629e+02 1.038769334534844120e+02 2.956016304760584035e+02 1.586570076132481972e+02 1.636816353299032585e+02 2.375674325770941095e+02 2.085436646116971531e+02 2.088922128397473443e+02 2.316234644183506930e+02 2.623581653234684268e+02 1.714245300492981698e+02 2.844387943099641234e+02 1.469270259610659650e+02 1.157700922187784727e+02 2.367694595159086361e+02 1.548671738744121740e+02 2.013687686570863207e+02 1.860374943080277887e+02 1.733446602950305930e+02 2.488507085609763010e+02 2.929099979257852056e+02 1.825615338506695480e+02 1.338575452835397925e+02 1.491478381149757979e+02 1.116052925520655066e+02 2.341983606431906537e+02
|
| 10 |
+
1.014445800974648222e+02 2.539987638010908597e+02 1.871788778457793399e+02 1.454231386314719998e+02 2.284640297096368045e+02 1.174773591296971915e+02 1.395683165851895637e+02 1.137193571402578414e+02 2.370662356797280950e+02 1.767292649815032064e+02 2.688513591587910696e+02 2.913902923086397436e+02 1.122392290694582897e+02 1.366157623619356229e+02 2.667409125457835444e+02 1.834435599491967537e+02 1.437174343391732236e+02 1.130622879516462120e+02 2.898543289046954214e+02 1.559795378531963479e+02 1.765577834073310157e+02 2.422955620302867885e+02 2.384835032255701321e+02 1.708163174135501094e+02 2.012159081107001839e+02 2.825663186839160517e+02 2.627299211659199045e+02 2.173916205317264883e+02 1.878835852278120910e+02 2.578733373077019451e+02
|
| 11 |
+
2.843897417914848802e+02 2.685865547709703378e+02 2.810255710736182664e+02 2.572690897085278152e+02 2.416998564827035523e+02 1.770932574976374099e+02 2.021652319180342943e+02 1.414744641219446351e+02 1.464677002516696405e+02 1.831165552459343644e+02 1.157177632931430651e+02 2.625289386264841482e+02 2.972225480003540952e+02 1.024156386789293265e+02 2.305099741095138768e+02 2.241903749843916671e+02 1.157222019118702292e+02 1.533205318359311775e+02 1.179505454242311799e+02 2.666741766563739020e+02 2.792728900733587238e+02 1.222170248460037811e+02 2.573772727215269924e+02 1.535874607134987286e+02 1.231830862844115728e+02 2.584552954023608891e+02 2.541883057030129862e+02 1.001259630352790566e+02 2.332879439260797767e+02 2.240027888381033563e+02
|
| 12 |
+
1.537092645679641123e+02 1.737278083620151392e+02 1.736358049797527201e+02 2.251608985235982630e+02 1.812387130195175473e+02 1.605621432944637377e+02 1.880655312831545700e+02 2.234500385148787700e+02 1.156918728696038272e+02 2.243685096423413654e+02 1.934342626327970720e+02 1.850952349553267027e+02 2.629944548485545965e+02 1.410418270562070973e+02 1.442479234012843960e+02 2.244518961458842909e+02 1.350755563946989923e+02 1.207094763037939913e+02 1.849900977633715797e+02 1.712315707730903398e+02 1.136025349108833495e+02 2.266901327137990734e+02 2.049289406654929735e+02 2.168279721613268407e+02 2.802488024880154285e+02 2.288593244920211873e+02 2.512942787545493957e+02 1.605416563468323261e+02 1.449848598254574483e+02 1.444073785399158396e+02
|
| 13 |
+
1.576600406756634243e+02 1.316580100950168912e+02 2.530050469343043460e+02 1.319013133578224028e+02 2.708693079386434306e+02 1.256852413190491689e+02 1.471714019119002046e+02 1.119112141125198576e+02 1.482405279774543772e+02 2.151504825709631064e+02 1.449998801809978488e+02 2.163638771503673581e+02 1.272949254250747657e+02 2.476027791419436141e+02 2.891208457332292028e+02 2.642744540427622724e+02 1.972643066216432999e+02 2.480891057982425423e+02 1.265454595896786003e+02 2.957735252703171227e+02 1.831389323451852533e+02 2.674516147697771657e+02 1.404389674972707667e+02 1.350952754772052913e+02 2.169062951790871807e+02 2.445227715623778408e+02 1.771545655819627427e+02 2.729961759152714649e+02 2.655105689521545855e+02 1.887977700062222084e+02
|
| 14 |
+
1.336462666694000632e+02 1.333709897858500995e+02 2.263366393511863350e+02 1.847175439991091821e+02 1.121699721143812383e+02 1.985314153845103533e+02 2.097626398761568396e+02 1.994292542548276970e+02 2.119822099620050722e+02 1.121578896112172430e+02 2.285640262135607372e+02 1.530452060058861719e+02 2.280757825791220625e+02 1.002584314437652893e+02 1.549763597162410349e+02 1.962603185897801836e+02 1.520023734031539107e+02 2.188357004065238129e+02 2.078620274892635678e+02 2.253215106546470281e+02 1.707542413836397373e+02 2.818584030117174279e+02 2.256862624833151472e+02 1.123882683852972377e+02 2.188298604829752776e+02 1.623779544769217296e+02 2.272253780943444212e+02 1.236449568833132560e+02 1.456708971140968174e+02 2.173334506159979753e+02
|
| 15 |
+
1.355111076933105210e+02 2.882277378633141325e+02 1.458332953325788139e+02 2.038461345794760007e+02 2.077052275373579278e+02 2.430957456359013804e+02 2.398926697516154150e+02 1.861334604823129553e+02 1.056851094080089695e+02 1.250491536199931772e+02 1.475324860190441427e+02 2.446126161547439324e+02 2.283994822545897705e+02 1.411463500178549850e+02 1.017206978570942510e+02 2.805514386584911790e+02 1.128847993259780083e+02 2.326583828053989862e+02 1.968387029218569069e+02 2.013375618903088480e+02 2.981010702857409456e+02 1.018614681114941902e+02 1.799507821883679526e+02 1.133741465580100396e+02 1.235533581072856038e+02 1.980629645203880500e+02 2.289642287691829097e+02 1.596082722591768288e+02 1.905110471998515322e+02 1.789448781159623820e+02
|
| 16 |
+
2.588286452268601465e+02 1.978130463173739599e+02 1.052689337312009599e+02 1.316763830509305251e+02 2.659236586726388509e+02 1.637014132384438767e+02 1.416031833329826668e+02 2.638665530652568236e+02 1.007257384115875425e+02 1.143900271701907769e+02 2.977834670475828602e+02 1.589765734727692745e+02 1.903975572290986520e+02 2.371635535037608804e+02 1.840341975670916668e+02 2.047003785265828242e+02 2.798969769773281655e+02 2.731706896262927557e+02 1.266878907904394254e+02 1.882415083052244427e+02 2.273996647906652129e+02 1.051754139634791869e+02 1.949647447346334843e+02 2.153583447980240919e+02 2.763468452623635585e+02 1.126493843527773322e+02 1.566047572050934491e+02 1.655928523150526246e+02 1.733528322945315949e+02 1.292815908595541146e+02
|
| 17 |
+
1.453195062153936874e+02 1.443849872704900008e+02 2.393030362110915519e+02 2.203850914291498668e+02 2.628192548589183275e+02 1.142161203389242132e+02 2.954875947743198594e+02 1.914138981839176950e+02 1.956478457154231023e+02 1.282875398486639824e+02 2.801001077571227142e+02 2.478095646281364566e+02 2.467477848581343949e+02 2.819656424464902784e+02 2.951823714077539194e+02 1.777239847229775478e+02 1.197979896746704185e+02 1.481181033052623661e+02 1.906710229153984528e+02 2.142395628283543658e+02 2.300980272040501973e+02 2.228884003748859186e+02 2.473330601440014220e+02 1.391193242835927322e+02 2.836257563055140736e+02 1.510096324299383923e+02 2.202302141125946946e+02 1.931468179284185851e+02 1.332427495686727639e+02 2.591048546650930575e+02
|
| 18 |
+
1.878681542531208208e+02 1.576240359584147654e+02 2.653849736815447500e+02 2.963544993865212973e+02 2.044592436730770828e+02 2.022626486161902903e+02 2.692262675681025144e+02 2.660999355751699227e+02 2.275843495473382347e+02 1.090849337992742818e+02 2.095602584555617227e+02 1.896271059113536808e+02 1.103822849104477513e+02 2.916911739044173260e+02 1.131212278363718582e+02 2.998892666268029643e+02 2.476782245756396605e+02 2.259689579913920738e+02 1.853942231198421950e+02 1.358270117521841200e+02 1.538630682720535674e+02 1.002148317174243601e+02 2.538393939061405433e+02 1.631649956267838206e+02 2.086654853664906000e+02 2.065167771482954322e+02 2.184161808630845485e+02 2.204789814939956045e+02 2.876785893506615821e+02 2.415299687386639675e+02
|
| 19 |
+
2.578989465605797591e+02 2.309888943086805853e+02 2.139372792253111584e+02 1.438019921733897775e+02 2.686852572045135616e+02 1.347038004304963579e+02 2.662658866335509060e+02 2.378358170108797367e+02 2.901455078003721155e+02 2.653867524737770509e+02 1.011162296015096302e+02 1.236447329941733528e+02 2.440241295351771669e+02 1.285889645706482725e+02 1.234088480316093808e+02 2.765916670935633874e+02 1.132915304101479421e+02 2.967043774237617413e+02 2.960414394814537786e+02 1.923965028192617410e+02 2.177448618307050765e+02 2.328047369831131732e+02 1.702256773965170282e+02 2.320080409490440729e+02 2.962065584958517093e+02 1.421971909775941185e+02 1.416181340866144183e+02 2.318260414882616374e+02 1.990521696869427046e+02 1.291045564046920333e+02
|
| 20 |
+
1.562042774178686386e+02 1.004265446278790392e+02 2.987714610921041185e+02 1.843637355858842284e+02 1.975513718825063165e+02 2.869996482942455032e+02 1.598134132589713943e+02 1.814921031876193638e+02 2.433389905907341983e+02 2.220363745053336970e+02 1.548306942100590504e+02 2.274512269554506361e+02 2.173006200058655963e+02 2.139515436667214772e+02 1.820439741095771353e+02 2.954110718222074183e+02 2.706126458816278273e+02 2.546812106115172583e+02 1.499899738326257363e+02 1.498010641912065921e+02 1.897725780579399668e+02 2.531561160917130167e+02 2.568891780637028432e+02 2.223136077092870551e+02 1.518604819103856585e+02 1.610422120589223027e+02 1.090455809489133259e+02 1.950503873748027388e+02 1.235704160644129388e+02 2.711492093024702967e+02
|
| 21 |
+
2.039597038432034424e+02 2.026680584622021684e+02 1.365818873512059213e+02 2.909476552420245525e+02 1.721994194158640425e+02 1.854386667051114443e+02 2.287109571295530372e+02 1.912591665763447963e+02 1.607322994166321450e+02 2.949516230628389053e+02 2.522065912002103403e+02 1.869433122585654701e+02 1.235797649248940644e+02 1.522422059501078024e+02 2.738245135411146975e+02 1.059681837441489307e+02 1.013027238331489173e+02 1.660100598156148237e+02 2.454471731623151243e+02 2.467503196183328100e+02 2.584564749953993896e+02 2.079587352810677316e+02 1.650926041957846451e+02 2.269719270682073784e+02 2.376254891983122093e+02 1.510146656008620596e+02 2.672848371954185041e+02 2.692845974117340688e+02 2.180714754246087921e+02 2.186797802447831884e+02
|
| 22 |
+
1.704231257711912519e+02 1.993416036368699906e+02 2.293703655438095268e+02 1.494582642918422266e+02 1.988970317734676030e+02 2.329763291241497711e+02 2.594871448385057420e+02 2.168089936885102134e+02 1.825320854593447280e+02 1.816754553181755796e+02 2.164740515812325725e+02 2.676208645391697019e+02 1.298365075936954725e+02 1.802664596093496243e+02 1.015344620621038132e+02 1.955048336384612639e+02 1.938953913674110083e+02 2.716932071347151805e+02 2.391085978949223829e+02 1.852300387899809380e+02 2.933293185307651356e+02 2.502753353909542966e+02 1.326128348575908262e+02 1.132638325194699433e+02 1.382024010322260494e+02 1.899310337488860796e+02 2.577639546186944699e+02 2.130234590296898887e+02 2.056292296528304746e+02 2.070746044453983927e+02
|
| 23 |
+
2.712524956603344890e+02 1.103212761114690750e+02 1.501201791543782917e+02 1.588084859702673555e+02 1.780379814134324192e+02 1.938691258391782810e+02 1.322057441019641146e+02 1.105823874551086590e+02 2.879365916037821194e+02 2.457617763012990224e+02 1.036189749330240488e+02 1.682919366264929124e+02 2.271749409116763161e+02 2.468308259697249127e+02 2.530034131464132088e+02 2.481420904342841709e+02 1.546080547019561209e+02 1.278414739842506265e+02 2.234886960240669111e+02 2.535365186455997843e+02 1.599130733896959669e+02 1.151371295028686035e+02 2.378656188176093451e+02 2.901072209563180877e+02 2.524076257924749882e+02 2.849501171254129304e+02 1.802791659856764568e+02 1.527418387706650833e+02 2.578820596338672431e+02 1.208856989199291263e+02
|
| 24 |
+
1.884906470590645711e+02 2.304295185581007672e+02 1.035923344330140736e+02 1.647061655195892627e+02 1.910201770870304472e+02 1.752788518438422614e+02 2.763014227316762117e+02 2.545709641405486252e+02 1.642694881393259152e+02 1.850698110761380804e+02 2.423689469305483328e+02 2.821007056776016384e+02 1.440765548977453250e+02 1.082195827231368952e+02 1.292487205530619008e+02 2.136496853657876613e+02 2.268509220579896635e+02 2.999629735037570981e+02 2.135306905316524535e+02 2.807718279523737692e+02 1.079256111018183759e+02 2.233050677333321801e+02 1.960571416898615951e+02 2.930642308139058514e+02 1.350490077967585307e+02 2.626074042719769750e+02 2.812196827814445328e+02 2.812753678081913336e+02 1.893738913514469004e+02 1.237248675858835725e+02
|
| 25 |
+
2.024005284879252144e+02 2.663611407988397559e+02 2.687079844301063076e+02 1.583164038086077312e+02 1.451019436850150441e+02 1.100558451420041450e+02 2.083655450975085159e+02 2.034012033819327598e+02 2.745375932717230398e+02 1.454718097055225599e+02 1.519068131933423729e+02 2.522666952972969625e+02 2.409340029943109300e+02 1.697386944425205115e+02 1.092659514648129289e+02 2.785598218078254149e+02 1.404092026094307357e+02 2.152301424167146990e+02 1.170396027347833723e+02 2.495323893679063474e+02 2.070836095469416591e+02 2.187978925167305135e+02 1.478606128149070855e+02 1.189323178954538207e+02 2.012925160284665651e+02 2.080878545398990127e+02 1.510128433840351647e+02 1.657302151838663065e+02 2.177026636795220043e+02 1.221198981216710422e+02
|
| 26 |
+
1.411258561955272341e+02 1.419717097672817374e+02 2.247481951315160984e+02 2.805973971111802712e+02 2.755562061324142178e+02 2.039769327420251557e+02 2.994080883760036045e+02 2.417843309736466040e+02 1.023751441731232319e+02 1.491356884971497152e+02 2.542464200475323821e+02 1.496044144381669128e+02 2.829129207809560285e+02 2.479316882407134699e+02 2.441205876677642550e+02 2.045492313770996020e+02 2.855582203360229414e+02 2.884005586284110336e+02 2.039668453101600676e+02 1.690279206477617890e+02 2.136822090795746760e+02 1.254275901194574772e+02 1.084851042192170922e+02 1.656011685190305229e+02 1.415195951026897774e+02 1.578115814760412263e+02 2.619737257057257693e+02 1.492347147839753347e+02 1.627213988646173561e+02 1.343297485726322691e+02
|
| 27 |
+
2.544675070683062756e+02 1.367461330002975899e+02 2.928364121110963652e+02 2.024865028281971036e+02 2.758937379397792142e+02 1.293527538914390220e+02 1.003170531204512059e+02 1.514803620238746760e+02 2.603616046431354789e+02 1.790387290949859960e+02 1.954717187769221027e+02 1.325226280128280223e+02 1.522166198122710625e+02 1.162911821325583048e+02 2.798489406348742250e+02 2.521718932296424498e+02 2.622327475379161115e+02 1.027798265388270949e+02 2.437256510683693023e+02 1.911771820917219884e+02 2.722604457055863350e+02 2.850557929858495640e+02 1.953760157441756746e+02 2.473572905253965644e+02 1.891404804097296051e+02 1.514672503279451803e+02 2.213565012031598940e+02 2.253356064978207769e+02 2.044629345029305227e+02 2.805872739342098612e+02
|
| 28 |
+
2.859142434488251183e+02 1.016009480575973356e+02 1.779351649172412522e+02 2.205171340775500539e+02 2.104472905774927369e+02 1.755755724600441567e+02 2.751836189782782185e+02 2.820692049982218350e+02 1.337557428916256015e+02 1.569761138230965969e+02 1.991757527032745543e+02 2.615974376894962461e+02 1.944849272958306017e+02 1.868411694165790777e+02 2.994394032068257729e+02 2.802783326794233290e+02 2.693871918204162625e+02 1.750293298802730249e+02 1.468161278725061720e+02 1.272003326865558108e+02 2.233103517167062932e+02 2.103066399402185027e+02 2.720825853079193735e+02 2.728915492341989193e+02 2.160004538807991992e+02 1.325145501710478015e+02 2.549827549782140466e+02 2.921469675413995901e+02 1.846231529604695822e+02 1.391152989663993651e+02
|
| 29 |
+
2.538717579982014456e+02 1.450483481068324352e+02 2.720200816305956550e+02 1.120834821105324011e+02 1.703801876168104741e+02 1.091293661435919233e+02 1.410263490040598526e+02 1.910022197757120352e+02 2.505223413771657022e+02 2.069613533172621374e+02 1.367200764291426935e+02 1.269156762039037574e+02 1.459486945063737267e+02 1.585863332989725905e+02 1.433846106215619329e+02 2.893202513225785424e+02 1.754070497414596730e+02 1.678900237854272746e+02 2.363821059303507752e+02 1.088858921730617908e+02 1.962435837543239927e+02 2.151311182954276831e+02 1.943029551670006754e+02 1.670799798236046172e+02 1.348235227224938910e+02 2.005836112104490212e+02 2.601588534628079969e+02 1.194827586439497935e+02 2.131891535893303740e+02 1.835674362703964277e+02
|
| 30 |
+
2.872207377280434457e+02 1.680389491751975299e+02 2.268072198735419533e+02 1.324343035526375729e+02 2.746241572770433095e+02 2.142161570690199710e+02 1.852290440736100550e+02 1.772431485621305285e+02 1.144750125154023266e+02 2.162070901557998468e+02 1.490690769171257557e+02 2.904041493178549445e+02 2.673617561413327621e+02 2.904362235840736730e+02 1.438791831406123833e+02 2.596893065528289526e+02 2.617155941751458386e+02 2.388486986717779246e+02 2.718819501315180105e+02 1.265484539827731680e+02 2.508989305854047700e+02 1.677208481362706323e+02 1.527665277518251230e+02 2.069026506407369084e+02 2.223100964495413336e+02 2.859845330217733022e+02 1.430291068893224349e+02 1.186508486537613436e+02 2.043257492072551713e+02 2.909823892985461953e+02
|
| 31 |
+
2.385945641230763670e+02 2.011887933217761031e+02 1.622448188725907983e+02 1.738874847453056987e+02 1.669498482708885376e+02 1.853462372214463016e+02 1.514500885098960907e+02 1.569159134451362547e+02 2.521399095730983504e+02 1.246878140446721659e+02 1.758330561641313352e+02 2.722601647479554003e+02 1.679012078705679869e+02 1.710944469563905272e+02 2.012619557548435978e+02 2.130692925302264200e+02 2.489118511754019778e+02 1.553758318484749452e+02 2.531318516516165857e+02 1.895498740333992487e+02 2.010265603399928409e+02 1.805605111948569856e+02 2.471772127430102159e+02 2.822665908577009759e+02 1.256656757093761314e+02 1.218957078832023626e+02 2.851942693987446660e+02 2.434079459678487751e+02 2.183256665756584312e+02 1.881473862468819220e+02
|
| 32 |
+
2.878274557836845133e+02 1.654481949983921254e+02 1.215681808546938214e+02 2.567820905945674781e+02 2.104106688330284101e+02 2.960796083414018085e+02 2.020680111052573693e+02 2.328934707961639106e+02 1.081575190462602336e+02 1.003340046261853189e+02 2.009697278729638299e+02 2.231963192062537757e+02 1.203849639323555323e+02 1.187994179134823156e+02 2.211937485225296030e+02 1.667300587261732119e+02 1.727379541915926211e+02 2.085029285798690353e+02 2.440827389167183981e+02 2.864522928573259151e+02 2.974890568790378893e+02 2.102945085846974393e+02 1.972598274048171447e+02 1.762889209976547136e+02 1.346946323322499666e+02 1.554434255958064170e+02 2.915634104756007901e+02 1.434053307556222876e+02 1.055800565037633163e+02 2.043924431141962259e+02
|
| 33 |
+
1.494596010135965116e+02 1.369114048625681335e+02 1.414146701131132886e+02 1.383970135097982848e+02 1.734304788623498155e+02 1.594301265610334610e+02 1.040146208229407137e+02 2.208381597698417806e+02 2.904998286250861383e+02 1.300157615397056929e+02 2.667076669416877621e+02 1.062418844419948556e+02 2.717657999079561364e+02 1.054097765488278640e+02 2.401074677516734823e+02 1.045408432466875297e+02 1.330046749931937882e+02 2.297648034226271534e+02 1.488059718063634307e+02 1.725671935994615183e+02 1.330818497812682608e+02 2.341687919103425770e+02 2.983144736799429211e+02 2.798846823197050071e+02 2.218705077010061473e+02 2.681931695329894865e+02 2.339384973461015420e+02 2.893058480095726281e+02 1.539801301873031321e+02 2.746688360458649640e+02
|
| 34 |
+
1.330701439354522222e+02 1.727884450558678395e+02 2.309082669627648272e+02 2.027633892073664299e+02 2.725503026364725656e+02 1.999882667367585896e+02 1.904108867169430255e+02 2.952458047945178805e+02 2.903769421220866320e+02 1.593020200554085477e+02 1.236139458806368623e+02 2.670862420061573062e+02 2.910830183895285472e+02 1.860711175093342149e+02 2.161724988935532963e+02 2.564488756979296795e+02 1.231566645138573648e+02 1.554206254375235403e+02 1.148558104746345521e+02 1.512714227454516163e+02 1.953024826710307025e+02 1.296022137194406127e+02 1.500450396815122076e+02 2.611742573447975246e+02 1.601671705158374550e+02 2.391666762859087214e+02 2.566415095930981352e+02 1.923304801412870404e+02 1.194174883996373353e+02 1.970722090829630986e+02
|
| 35 |
+
1.912113734453868688e+02 1.498407015577022605e+02 2.038188614169363007e+02 1.315017316695561647e+02 2.564290419741012101e+02 1.890015309531812022e+02 2.451565642315005960e+02 2.794356592632736920e+02 2.286941218755985972e+02 1.959549984609147941e+02 1.183834182035568716e+02 2.102820643179567242e+02 1.748108698585573393e+02 1.534379248653211221e+02 1.919662859034699522e+02 1.273611408042816464e+02 1.848163823983119585e+02 1.719445827292381637e+02 1.098466009889928898e+02 2.781108902268393877e+02 2.089286134506138524e+02 2.324518337977864348e+02 1.983840049195213169e+02 1.897881971862217370e+02 1.057077761008814605e+02 2.693629461665184408e+02 1.359710117509105487e+02 2.191184409971657487e+02 1.295811391257115304e+02 1.272165218667991553e+02
|
| 36 |
+
1.987244486959793903e+02 1.516360617950651317e+02 2.198509518241761498e+02 2.494181713303175911e+02 2.903223989223247372e+02 2.847249789220907132e+02 1.747037051964282171e+02 1.610307305098726829e+02 1.866621867053561061e+02 1.016530888490581503e+02 2.606194448419089440e+02 1.820037020201941402e+02 2.650669443765450524e+02 1.137210849453726098e+02 1.329244106101075715e+02 1.741312140090854257e+02 2.301425980066611885e+02 1.051708772384664030e+02 1.994040172335078864e+02 1.874773290907829733e+02 2.745616984783777070e+02 2.354781865911449756e+02 1.598287033335407159e+02 2.650689470710170212e+02 1.643692352330562017e+02 2.991199217036622713e+02 2.713535332162406348e+02 2.516280148665988463e+02 1.124367393830256532e+02 1.725070309959049837e+02
|
| 37 |
+
1.637875882282461077e+02 1.407642428016634426e+02 2.759741260511348173e+02 1.982469453863400304e+02 2.966736241669494802e+02 2.756530253528777052e+02 1.426661371226006167e+02 1.585144634205103102e+02 2.836415355000413001e+02 2.468213340046699784e+02 2.898204535963063790e+02 1.711408259966125343e+02 1.900542569026269177e+02 1.112151031999617032e+02 2.679918109779015936e+02 2.737346364036235400e+02 2.597479311885246602e+02 1.719445390286030886e+02 2.361360157374418236e+02 1.123330408578339785e+02 1.214203690485689719e+02 2.552722899309185891e+02 2.436705678248840456e+02 1.596697357728296254e+02 2.533254006866929444e+02 2.066863222258713790e+02 1.194370826184286329e+02 2.943584774485435673e+02 1.636272134478143130e+02 1.191267138602315185e+02
|
| 38 |
+
2.350924626651462006e+02 2.263138093076711357e+02 2.206572605284771385e+02 1.704171521239532296e+02 2.000250897638135257e+02 2.966317084215347109e+02 1.350543763227695138e+02 1.248113195978286285e+02 1.480602782771696297e+02 2.391913401309390679e+02 1.908758915801345779e+02 2.476074601271855045e+02 2.408834383325319095e+02 1.009169451940341560e+02 2.567526834523320645e+02 1.791854948779896688e+02 1.412277552146151152e+02 2.660711025781407670e+02 2.073940326990519054e+02 2.509760072499196610e+02 1.358593750308925223e+02 2.127422683140523532e+02 1.874643773621423293e+02 2.844455725631112273e+02 2.197223292953194118e+02 2.049519862750077266e+02 1.674367936692717365e+02 2.806316262053937294e+02 2.040091003350897836e+02 2.675290975004411962e+02
|
| 39 |
+
1.483513543637005796e+02 2.384008274111940011e+02 2.834409911154408519e+02 1.344593118283445392e+02 2.346883831968173979e+02 1.381882879805813218e+02 1.241165074750676638e+02 2.186327911062819567e+02 2.466602279029802673e+02 1.573094529523951906e+02 1.568918412618390903e+02 2.289205163045023710e+02 1.170165333644822283e+02 1.742406104080407658e+02 2.082974381484526702e+02 1.600869123712819260e+02 2.399160913983472199e+02 2.877189278027444743e+02 2.845252294036096146e+02 2.342337907657317544e+02 1.496264758341107779e+02 2.905797831387872066e+02 2.824703799011629144e+02 1.047015685176013307e+02 1.056531628249932169e+02 2.778559625738202499e+02 1.693549799118289343e+02 1.654193764711911570e+02 1.062077606699500762e+02 1.159643419206647792e+02
|
| 40 |
+
2.694780377267857716e+02 2.229138360502907403e+02 2.407432883969363218e+02 1.240072643521201741e+02 2.128611568148922970e+02 2.114050669978733481e+02 1.042337934877265297e+02 1.044783539591350490e+02 2.706611056394938259e+02 1.972285130309975898e+02 1.959046941044780681e+02 2.915493579522836853e+02 1.131994346897827342e+02 1.197362406389762839e+02 2.877593780027675621e+02 1.089470964294721824e+02 1.996015695685267417e+02 2.185569019121031999e+02 2.102686704320404374e+02 2.955299037924150980e+02 2.987478446256551479e+02 2.517129931888254646e+02 1.552463625479420557e+02 2.295020326441428153e+02 2.886454895961533111e+02 1.869792800456660871e+02 2.703426621835664037e+02 1.873514421416134326e+02 2.714620374401066556e+02 1.623625260081516331e+02
|
| 41 |
+
1.457420078291350194e+02 1.926195242081234369e+02 1.841639049563959247e+02 1.397830290030836125e+02 1.287503203163068406e+02 1.684614546803193775e+02 2.820658047345126533e+02 2.986548244924653090e+02 2.631399932039782925e+02 2.870930868530864473e+02 1.141938207690214426e+02 2.868552010662050407e+02 2.019110175402121286e+02 2.840219745246005232e+02 2.848478851173646262e+02 1.902287203163165259e+02 2.696968940302964484e+02 1.690355482825476656e+02 2.171695948786692725e+02 1.960363641465239652e+02 2.930566891688549731e+02 1.380341365242818483e+02 1.769912313914243214e+02 1.164985277343077996e+02 2.079184380436491324e+02 2.871364788135472850e+02 1.796231479741346391e+02 1.115892945700443875e+02 1.922852518794877028e+02 1.851500906627327083e+02
|
| 42 |
+
2.894943401361737187e+02 1.972990286414578804e+02 2.801948561309920933e+02 1.993490085147259947e+02 2.539099743775018112e+02 2.972486389690005240e+02 1.162404922698449354e+02 1.801898545246462504e+02 1.283416456049016858e+02 2.289248555429664407e+02 2.419505668531598985e+02 2.755101537543703216e+02 2.786083442131507013e+02 2.461931811431258552e+02 2.699066237266536064e+02 1.088542193903703179e+02 2.302113104476973149e+02 2.158136503417114227e+02 2.797451432348925096e+02 2.832754349673875822e+02 2.207567008139471909e+02 2.920947868166995249e+02 1.300092217647513735e+02 2.953259288980694350e+02 2.539624465668687492e+02 1.304833679125420645e+02 1.051395153781939484e+02 1.855592224876973830e+02 2.160289702497469477e+02 1.227895712666205981e+02
|
| 43 |
+
1.029685235386965587e+02 1.410297052380113882e+02 1.832105986621241982e+02 1.016727951098498579e+02 2.130361696974732126e+02 1.817578553203918830e+02 2.644724203174304193e+02 1.713346250427240420e+02 1.297164370175517547e+02 1.072810924841072193e+02 1.083932811014470161e+02 2.860684171745337494e+02 2.893854146138399983e+02 1.677808320623732925e+02 2.343535290724524600e+02 1.209564642240636090e+02 1.329537830609780542e+02 2.924542956964438645e+02 2.733376468658280487e+02 1.397146179999238598e+02 1.103570089598620285e+02 2.231457082965310690e+02 1.056672424832338635e+02 2.887779644840117612e+02 1.127167878193751704e+02 1.387640376146708263e+02 1.791595456124304633e+02 2.709107895779202408e+02 2.238624693992912569e+02 1.773395240564728397e+02
|
| 44 |
+
2.317578772498348769e+02 1.294950944138938667e+02 1.126253428029936572e+02 1.371351849575549693e+02 1.785990678455200964e+02 1.021081186758702444e+02 1.471984209931611360e+02 2.907355141803875540e+02 1.881128962816476644e+02 2.776434621780599628e+02 2.231668573818950279e+02 1.905362514139340817e+02 1.921875823712000226e+02 1.027725913116546792e+02 2.939602582690168902e+02 1.776540079128602656e+02 2.761214484196684111e+02 1.042033722248946646e+02 1.812858538041361385e+02 1.739774673118114663e+02 2.626640185867897799e+02 1.702975408841979288e+02 2.558138050153142729e+02 1.733257751657050392e+02 2.918973111180089859e+02 2.499103812623473857e+02 1.210050998380505973e+02 2.819910650801346605e+02 1.887952629909842699e+02 1.910084514453274380e+02
|
| 45 |
+
2.212539479167726029e+02 2.774434360961662378e+02 2.337566454731646104e+02 2.345785537275947661e+02 2.365459264006348405e+02 1.983982238092833086e+02 2.030822332599765332e+02 1.995891111618029186e+02 2.834365683300363798e+02 1.036872616932399609e+02 2.192093181482490252e+02 2.601252995545215754e+02 2.498786393235831724e+02 2.102914196276636858e+02 1.344974807588668000e+02 2.319076536245909210e+02 2.769341510052834110e+02 2.705990780330756138e+02 1.679097240924248240e+02 2.394521666103182724e+02 2.042111123157340842e+02 1.679545908808316028e+02 1.638112120198904051e+02 2.498667640522866407e+02 1.298749690282424183e+02 2.953546510122243944e+02 2.420377599473625025e+02 1.972281420856064642e+02 1.511153679243939223e+02 1.785899871179086063e+02
|
| 46 |
+
2.568297621323404201e+02 2.469847896802298237e+02 2.766623631158322496e+02 2.476135901735717937e+02 1.788596740963971570e+02 1.849716544556056874e+02 2.568516536462929594e+02 1.692762419184084877e+02 1.468834240718183537e+02 2.716053370235183593e+02 1.674083895790932957e+02 2.340636951853666687e+02 1.637725360284847227e+02 1.316562872243186177e+02 2.850086566701365882e+02 2.066513343106022944e+02 2.990778363456342390e+02 1.780020440519503495e+02 2.906711993591478631e+02 2.149926413975278479e+02 2.151504627144789765e+02 1.458362697904619836e+02 2.339644011324822657e+02 1.740513991402896181e+02 1.804876886135730842e+02 1.706585538790989176e+02 1.113370339871644603e+02 2.032819788543359039e+02 1.225434838619497526e+02 1.558188197132453183e+02
|
| 47 |
+
2.752385657001058803e+02 1.704994416021052643e+02 1.607090409105587696e+02 2.031247490318933444e+02 1.333383797740430339e+02 1.922643047184382112e+02 2.665685682619526915e+02 2.611043497447243453e+02 2.444450591022788615e+02 1.012899678037660181e+02 2.236752860048796947e+02 1.164606756896235993e+02 1.768812782093617955e+02 2.532808672341815850e+02 1.308823477633827395e+02 1.683394957344131626e+02 1.787390150786144716e+02 1.962681762314343530e+02 1.178176219749694980e+02 2.151624908275416885e+02 2.951256579216935734e+02 2.058583926262361388e+02 2.348769662163374790e+02 2.500118096543036472e+02 2.065978549387351109e+02 1.732426267043477139e+02 2.575950640438621804e+02 1.826939497339359946e+02 1.586062531006688801e+02 1.141086110094916819e+02
|
| 48 |
+
2.107478059550890066e+02 1.212326460542207940e+02 2.154852140069355073e+02 2.624147598788578648e+02 1.169795422214265699e+02 1.682202484364929660e+02 2.987700686247625299e+02 2.259973608163532504e+02 1.912690930240648015e+02 1.896338093439390775e+02 2.747727757049322008e+02 2.388804299971102978e+02 2.538821160842531128e+02 1.839990833334872491e+02 2.839611350159472067e+02 2.953225980324958755e+02 1.674336071760058076e+02 1.609172697163818953e+02 2.902596210806400450e+02 1.513824951234124114e+02 1.873458283487339600e+02 1.695960935104061491e+02 2.116215526550050470e+02 1.849422962892989233e+02 1.434256749723924713e+02 1.304784783123307079e+02 2.632948417544853328e+02 1.656472047377057777e+02 2.303125851744007377e+02 1.681993961373014486e+02
|
| 49 |
+
1.104191565760665128e+02 1.750924257030650040e+02 1.242494131306669090e+02 1.541741282893887899e+02 2.585460716706878657e+02 2.286423505464783261e+02 1.890990979891397501e+02 2.707781238779197679e+02 2.619171833457787670e+02 2.695823002806438353e+02 1.941989480397771786e+02 1.389058748786196134e+02 1.283479072532797431e+02 2.347481590897206729e+02 1.518985431591505630e+02 1.757095590143896402e+02 2.225334593093496096e+02 2.231309387578290568e+02 1.039310896134069395e+02 2.614149485334186238e+02 2.212890027388380076e+02 1.425609106790709859e+02 1.376620423520403733e+02 2.403640719649376933e+02 1.152284694789922526e+02 2.108068210397188409e+02 2.526640691383259991e+02 2.323633859683563969e+02 2.720522122905912283e+02 2.498034621012949685e+02
|
| 50 |
+
2.223449436042899947e+02 2.823923482876032267e+02 1.728419664392092727e+02 1.542710015610415724e+02 2.699062389875002737e+02 1.776741825057288793e+02 1.800001384193664080e+02 1.819433000632012636e+02 1.436484983468620840e+02 2.344086094824976954e+02 2.824459866922626361e+02 1.860318500101035681e+02 1.749968777772715498e+02 2.792448396035428004e+02 2.134719239619671498e+02 2.649346822194891047e+02 2.535109715864082602e+02 1.651109960016319178e+02 2.407385671793928736e+02 2.276937454871455770e+02 2.965404491761371446e+02 1.771850291606413634e+02 2.317902380753697855e+02 2.233400563607936817e+02 2.471010629200553694e+02 2.999085009765063319e+02 1.263611681933084725e+02 2.954593528043474180e+02 2.279026703099021915e+02 2.630592311905735414e+02
|
| 51 |
+
1.662671322607742752e+02 1.600442354914371208e+02 2.476541290397616137e+02 1.471310870365195740e+02 2.302232198157895198e+02 2.833854716762933776e+02 1.464787719165046553e+02 1.913553080525503560e+02 1.014594285276723156e+02 2.182963956218923158e+02 1.629807715448000636e+02 2.692152036144454428e+02 2.287521686048013976e+02 2.982465613581407524e+02 1.646080094271899839e+02 1.685350412843276899e+02 2.638506951547767585e+02 2.931520510309920837e+02 1.395453733045734168e+02 2.192750645467382355e+02 1.118562057344099543e+02 2.210439168983162972e+02 1.977199388190010438e+02 2.248771354041466566e+02 2.967583759675493411e+02 1.144799677712354793e+02 2.877369511761256149e+02 2.831237961244747225e+02 2.909105411130262269e+02 2.550977837950437390e+02
|
| 52 |
+
1.519738194711488006e+02 1.042788193386050608e+02 1.298121344332743377e+02 1.827398187867084971e+02 2.371985543371917800e+02 1.647119082252074236e+02 2.792046599520904238e+02 1.737333830141970452e+02 2.019611337599129968e+02 2.402390448779260623e+02 2.107045415433176174e+02 2.447101973248666411e+02 1.584507446746840174e+02 2.877533155913679366e+02 1.209142860803932251e+02 1.903846717728129931e+02 1.485923447895592631e+02 1.040627746119376695e+02 2.329784390325348795e+02 1.136264746597146882e+02 1.019818146651219024e+02 2.395077159260278847e+02 2.571474008697522322e+02 2.507839876514990465e+02 2.649762964978717719e+02 1.398370322453145889e+02 1.116668292809188614e+02 1.262068209877756289e+02 2.561228606182183967e+02 1.019925993853918413e+02
|
| 53 |
+
2.525550526067758881e+02 2.649927164229666232e+02 1.457764901336312846e+02 1.519121804298574148e+02 1.112983565335166247e+02 2.979018464293943680e+02 2.517559946611144142e+02 1.257251989750113239e+02 2.377842966816966737e+02 2.692916709774201536e+02 1.558791612193160745e+02 2.988101508442036334e+02 1.264682305510686575e+02 2.586186621657187743e+02 2.397705732393993969e+02 1.799773948514575750e+02 2.289212202830902072e+02 2.551439950194432242e+02 2.270410183155361210e+02 2.624250216967006395e+02 2.894508375480465361e+02 1.106681053253299183e+02 1.696755343387707171e+02 2.302155275158106917e+02 1.445113211107399138e+02 1.886794441144848236e+02 2.129906512422033131e+02 2.340704769023953986e+02 1.082933010325512981e+02 1.977265970892881626e+02
|
| 54 |
+
2.874406426475449052e+02 1.913451373833616742e+02 2.647704607931181044e+02 1.881279366057496532e+02 2.840067538093052804e+02 2.179159896935567247e+02 1.839859875309309132e+02 1.189702187115672132e+02 2.794517441847542614e+02 2.815599370853284427e+02 1.258259904677427699e+02 1.428483537633051412e+02 2.541426109645265967e+02 1.338781623221585164e+02 2.877181693280556374e+02 2.041742222547631513e+02 2.429167887622087392e+02 1.861891141000048435e+02 2.815058357304060337e+02 2.932279451804108703e+02 1.428092602118218792e+02 1.129541128601477595e+02 1.104970415865426503e+02 1.361068733124779726e+02 1.702082770497633533e+02 1.583852379729134157e+02 1.614070717213254511e+02 1.054529192214523476e+02 1.116913943762218366e+02 1.806474879921846366e+02
|
| 55 |
+
1.904583320230821926e+02 1.477903225290235980e+02 2.926623631581093150e+02 2.267002240281469199e+02 1.643763662729302268e+02 2.199235242233247902e+02 1.853923849032223359e+02 2.941726936508506469e+02 2.665966841434134835e+02 1.199566433868006357e+02 2.951991052054676175e+02 1.594510101065885124e+02 1.458298791153635534e+02 1.532145001211049475e+02 1.411023254500616133e+02 2.140513226665028128e+02 1.678784758049908419e+02 1.708308530430679184e+02 2.099440033407245778e+02 2.664570659333852518e+02 2.959905162222905801e+02 2.829445582187913715e+02 2.588706049990775000e+02 1.722199615074994483e+02 2.869184560072056343e+02 1.681559218785307053e+02 1.503240659973911306e+02 2.588597461006905291e+02 2.678295026364270939e+02 2.154561503934444886e+02
|
| 56 |
+
2.071927904539387839e+02 2.171736003654224305e+02 1.593735315924418785e+02 2.947356579175152547e+02 1.742775794491871011e+02 2.184611101357660914e+02 2.225198306238390842e+02 2.168369296352294668e+02 1.755672175076374231e+02 2.252214925755263835e+02 1.563369877784152209e+02 2.085332604119019209e+02 2.572482649031854862e+02 2.951800051631508950e+02 1.079183556031880329e+02 1.218838648771928774e+02 2.685371616407055626e+02 2.419162624723466877e+02 1.022244855205179022e+02 1.101224552326326602e+02 2.597819405832950679e+02 1.134555412120959517e+02 2.870491931154815575e+02 1.374365654160442318e+02 2.645641258978021142e+02 2.531141673781916666e+02 2.361747183362105886e+02 1.893108861581111171e+02 1.539026912190118139e+02 2.501170032332128415e+02
|
| 57 |
+
2.547888423116186232e+02 1.853670755857669974e+02 1.389074705955763420e+02 2.709929622842061008e+02 1.228800068832790515e+02 2.778321736112652616e+02 1.309641642706778555e+02 1.156980811627219055e+02 1.431313378740429982e+02 1.646591400066212714e+02 1.920182917083556049e+02 2.178001706163468043e+02 2.235489712948179886e+02 1.079088316874027242e+02 2.447091545393394370e+02 2.320303973549428065e+02 2.359105911115680101e+02 2.382951907588607128e+02 1.062067779247245483e+02 2.905379355334102911e+02 2.023335418134440715e+02 2.128348219019524095e+02 2.865957710750057004e+02 1.782427960783044796e+02 2.856139874187100531e+02 1.139905905655008098e+02 2.264676166669663360e+02 2.479179013019825675e+02 1.746165350218777803e+02 2.255842464851874070e+02
|
| 58 |
+
1.883869033800616819e+02 1.965817072065136699e+02 1.890868666652849015e+02 1.898737766004000491e+02 2.779218373710688184e+02 2.134628932560298722e+02 1.100835458783813436e+02 2.768750976313177148e+02 2.547073561014202880e+02 2.728160162818061281e+02 1.733645011505617504e+02 1.625036971255624394e+02 2.977754324167240156e+02 1.632372616873928450e+02 2.174045665187836107e+02 2.606964806055048030e+02 1.625508452643421720e+02 1.715067940576683441e+02 1.218481476549646629e+02 2.842560845538128547e+02 1.928678337146606623e+02 2.708765321293922739e+02 2.077020047066411621e+02 2.923591890868326004e+02 2.230876482822842206e+02 2.689925468225608256e+02 1.036588336737814586e+02 2.052618530546818363e+02 2.648220111560104897e+02 1.868396012623422280e+02
|
| 59 |
+
1.785937212608853315e+02 2.973454718025594161e+02 2.368986004504845084e+02 1.146953890760472348e+02 1.265905165006724644e+02 2.255973396401841455e+02 2.163675674740596264e+02 1.527913853500098185e+02 2.283358642424602465e+02 2.759303134283557597e+02 2.876072117803540777e+02 2.029362495845153944e+02 1.212425121544320490e+02 1.100001317370093830e+02 2.335268996183764330e+02 2.375268130741384027e+02 2.336339660612213436e+02 2.462747325703657282e+02 2.841981652294566061e+02 1.081959034831858446e+02 1.291296469376330833e+02 2.602425849072438950e+02 2.575669438145553727e+02 2.135342654708205714e+02 2.294373105308322067e+02 2.706502840281193016e+02 2.928412927772634475e+02 1.330151104176747765e+02 1.533759962548247131e+02 2.744006234275867655e+02
|
| 60 |
+
2.257735103076358882e+02 2.728385269717355186e+02 2.290872800510813363e+02 2.330934692803050154e+02 1.037274604992595215e+02 2.674079561164307961e+02 1.195755645916240866e+02 1.402804464035359047e+02 2.170516922702277611e+02 2.744725918691634661e+02 2.930458735600458908e+02 1.496408395971007224e+02 1.595562419103408729e+02 2.835538666488008630e+02 1.780163567793609332e+02 2.906408145890961237e+02 1.133853019218590248e+02 1.494630592331960770e+02 1.214592101712915451e+02 2.263015460193574881e+02 2.598100406717117608e+02 1.963383361449393192e+02 2.235083985338561376e+02 2.946475410923074492e+02 1.758055989844200724e+02 2.637780439251395137e+02 2.875400021086666698e+02 1.577781508415756662e+02 2.146553072676672684e+02 1.798181279868336446e+02
|
| 61 |
+
2.620574340171276617e+02 2.153711882285265915e+02 2.245961661539886904e+02 2.054509343172356921e+02 2.926008719008261210e+02 2.432564531143420652e+02 2.303655720936658611e+02 1.615953803481287991e+02 2.918921003884012748e+02 2.760746977013722017e+02 1.909442200188182710e+02 1.596536528765051060e+02 2.491411570718119037e+02 2.924629085319008936e+02 2.587604848561293807e+02 1.524605619386706792e+02 2.737599884275671798e+02 2.090365453766356723e+02 1.610548024559351461e+02 1.018774121963877803e+02 2.410901898572944049e+02 1.875862586601133444e+02 2.588626077539996686e+02 2.579873618626863845e+02 2.838744453525392828e+02 2.580071516854936817e+02 2.114887112935771256e+02 2.675506009048368696e+02 1.260391751775616029e+02 1.858866479221875920e+02
|
| 62 |
+
1.963224789638335892e+02 2.444908535968891954e+02 1.962779352478895589e+02 1.553096436749702889e+02 2.483662294276224429e+02 1.067992874414757978e+02 2.633849667942634483e+02 2.454321751613854588e+02 1.854433418739394028e+02 2.562889653665436072e+02 2.506342746416453622e+02 1.900819942764665598e+02 1.704565979131312474e+02 2.916979173024495822e+02 1.898592592817412310e+02 2.687872145548625440e+02 1.525347862509104004e+02 2.786582104923993484e+02 2.310813531087783872e+02 1.166208530157265386e+02 2.602471623613457723e+02 2.102772607982462034e+02 2.183751071150112466e+02 1.065011561509572999e+02 2.813176394708128782e+02 1.792292558016025623e+02 2.804083600455996361e+02 1.557890480883644102e+02 2.439522159916458861e+02 2.652201783594097719e+02
|
| 63 |
+
1.425266334964659904e+02 2.075049705342416928e+02 1.704914602333145126e+02 1.886474594627911756e+02 1.252313163849750595e+02 2.836097447326676502e+02 1.406399617929505439e+02 2.414245225193989768e+02 2.576349788827002385e+02 1.486724691707949262e+02 1.092388214497626961e+02 1.685935770192617724e+02 2.033388664740227227e+02 1.390809359458484948e+02 1.056188661648174758e+02 2.350581131530574055e+02 1.964295662906907012e+02 2.578831766420791496e+02 1.109952979966328144e+02 2.027546721440710940e+02 2.501377690830167637e+02 2.111868593440530617e+02 2.324728205186171692e+02 2.453971856382445935e+02 1.723822394524685819e+02 2.872924628066301693e+02 1.140766727214026446e+02 2.221345013854892159e+02 1.728173248741775296e+02 2.676400838220500873e+02
|
| 64 |
+
1.711571121866394947e+02 1.085759247733173396e+02 2.001753766691515750e+02 2.760446855018309407e+02 2.056587091496190567e+02 1.121827347031253197e+02 2.274644480946081444e+02 2.571858980756533128e+02 2.945439217283808375e+02 1.913312305877045674e+02 1.500446430731354894e+02 1.650397772114545489e+02 2.581660073502400792e+02 2.094009769144933273e+02 1.731816092302842094e+02 2.727903589313663133e+02 2.606648610353666982e+02 1.460656197586831695e+02 2.016951883706858268e+02 1.247477859691891240e+02 1.732157361502286221e+02 1.195560196858487245e+02 1.253893910664414904e+02 2.455457677441618216e+02 1.778732818035962850e+02 2.490436815297808266e+02 1.487573988963908960e+02 1.937302250034929898e+02 1.502426775501600389e+02 1.110841009912817583e+02
|
| 65 |
+
2.382535443835092508e+02 1.972031918916456732e+02 2.576267295349729807e+02 1.730194312205534288e+02 1.301593684828995094e+02 1.624008376323430127e+02 2.060036399923972681e+02 1.233366573394677630e+02 2.194763391620297739e+02 1.701495187616251314e+02 1.223397596968992218e+02 1.987622577877627350e+02 2.511738650001373117e+02 2.130204435763062634e+02 1.993899817227978133e+02 1.597764561560970265e+02 1.205224890815559604e+02 2.184250491898233690e+02 1.755709834516516139e+02 2.741081010321077542e+02 2.104755291992826187e+02 2.698148014221883386e+02 1.299106544858947814e+02 2.008369880697999292e+02 2.938716155581552130e+02 2.671516623028076083e+02 1.332347035771324215e+02 1.291435420390463378e+02 1.835021202063177554e+02 2.002866194329941720e+02
|
| 66 |
+
2.554906544300547182e+02 2.365682876454178540e+02 2.924004211094360244e+02 1.662852505275750730e+02 1.123350814405425808e+02 1.910015128879867632e+02 1.341551373493250594e+02 1.313122940860927770e+02 2.397311819484906152e+02 1.559268654058377024e+02 1.407120959783594003e+02 2.371419051640040152e+02 2.217591327496910480e+02 1.881187811266301537e+02 1.632462641154496907e+02 2.970940639140721373e+02 2.422917505999918433e+02 1.356966040631749593e+02 1.702398486895437486e+02 2.608644720933497183e+02 2.783751927848827563e+02 2.951746624002826138e+02 1.720706565846523688e+02 1.275268866601749096e+02 1.880990845238362681e+02 1.129502795714700625e+02 2.919985401845127626e+02 2.747497807112307555e+02 2.667734033775608395e+02 1.373740617490475699e+02
|
| 67 |
+
2.115416415080857746e+02 1.431719947715498336e+02 1.718744824503889674e+02 1.075365968452523902e+02 2.220100335193473029e+02 1.965127222891928795e+02 1.062726056237197838e+02 2.631794488147562561e+02 1.658640190278337627e+02 1.169182569761068464e+02 1.645780782039788619e+02 2.940728738870184316e+02 2.979920277570993790e+02 2.125849825405138631e+02 1.533327700316632161e+02 2.655551337415409421e+02 1.329075684859120088e+02 2.686536376777100941e+02 2.299223677315555676e+02 2.123135030200585334e+02 1.474417961566917654e+02 2.899688778344954017e+02 1.439992490259426461e+02 1.606165457016644780e+02 2.854253601360321682e+02 2.837928223954166924e+02 1.868865943198568402e+02 1.809928275876523571e+02 1.583918020284682484e+02 2.384217495701244331e+02
|
| 68 |
+
1.181670050605631417e+02 1.525653020190297582e+02 2.615084872177121724e+02 1.755024420886775829e+02 2.989795566898581001e+02 1.573585789513378188e+02 1.903575226478752711e+02 1.641861715477102166e+02 2.943146494922903003e+02 2.038802368327418719e+02 2.581560000437879694e+02 1.504995935930718076e+02 1.095655891680627008e+02 2.628623226127134558e+02 1.069018430130149255e+02 2.750818506761686422e+02 1.121786007219489818e+02 1.106710601660877415e+02 1.217291564359016149e+02 2.915199334459504144e+02 1.325859381653097557e+02 1.737237090326784141e+02 1.036075961875061751e+02 2.392327113385031510e+02 2.486092083099548233e+02 1.259492139939950306e+02 2.665249241620523435e+02 2.103119814995928039e+02 2.718465347096271216e+02 2.018653364759854298e+02
|
| 69 |
+
2.085808638159350608e+02 2.977621083099649582e+02 1.394173606621695285e+02 2.232898484647512873e+02 1.347812725162832521e+02 1.574683348766579627e+02 1.827258429860655724e+02 2.827887224427595356e+02 2.608349632236463549e+02 2.370910079389979046e+02 2.033290260845359398e+02 1.566531500677691042e+02 2.982287288081304837e+02 2.998057140577807900e+02 1.906108269451214596e+02 2.023344526730545851e+02 1.717672594576409040e+02 2.093320563180507747e+02 2.649028095061802333e+02 2.840422446800275793e+02 2.111868958418739908e+02 1.803076798272542760e+02 2.311954915496957312e+02 1.563425451766251513e+02 2.610066662710300989e+02 1.855286443040786537e+02 1.478912573842241045e+02 2.544380211258828410e+02 2.799416317427427430e+02 2.238937193404353252e+02
|
| 70 |
+
1.269470316997365131e+02 1.895539822645488357e+02 2.443421824114378467e+02 2.632321641240823737e+02 2.164919638664115951e+02 1.042697198382110884e+02 2.896061632271033659e+02 2.068164163046922681e+02 2.059671371408958294e+02 2.352532326493898722e+02 1.046233655847859296e+02 2.755187319279126541e+02 2.344641322699609987e+02 1.434858288567621969e+02 1.255438908126368176e+02 2.548141480364848803e+02 1.466719626681152704e+02 2.020892715394597872e+02 1.195107046056347713e+02 2.012968701954913797e+02 1.996902768982717191e+02 1.560547951636197013e+02 2.162555170020900164e+02 1.483278604161245084e+02 2.615607136845001151e+02 2.424344777210258997e+02 2.524090919470299070e+02 1.726167614603126026e+02 2.199373130240069258e+02 2.318614758097714912e+02
|
| 71 |
+
1.590143031424979370e+02 1.933970326403360502e+02 1.227042846200323112e+02 2.107086401017011781e+02 2.844049872407889552e+02 1.420899421875644464e+02 1.736571760246831673e+02 1.130876049831349661e+02 1.470306210908964317e+02 2.959723384067232246e+02 1.438030965279091049e+02 1.685928342779160403e+02 1.351720793691902713e+02 1.909711091249450590e+02 1.477005416416634205e+02 1.010528808923594681e+02 2.205493627613245167e+02 2.367352422049318079e+02 1.224997665062844305e+02 1.620949451166091251e+02 1.270634404764108467e+02 2.673321646154778932e+02 1.618882934467209225e+02 1.208967331765591524e+02 2.073956586593529607e+02 1.223277950209799059e+02 2.625820210851194361e+02 2.262632377752408672e+02 2.222881433937307349e+02 1.716205611551696961e+02
|
| 72 |
+
2.376094214038359667e+02 2.287867757784330820e+02 2.035778067022395703e+02 2.546588007138803391e+02 1.514832565507949198e+02 1.736683542684334327e+02 1.991020520349750598e+02 1.873563480883249213e+02 1.589186331386689801e+02 1.042563150975229149e+02 2.019924784676414902e+02 1.136537158101241971e+02 1.091264020137841158e+02 1.352770409719844054e+02 2.178414513482917414e+02 1.831380105899948489e+02 1.114225947990316570e+02 1.736029819106907439e+02 1.354612112967272424e+02 1.996055424300992627e+02 2.905125217944571432e+02 2.980326934372309893e+02 1.560898949881966473e+02 1.943286005606112212e+02 2.429797193518882636e+02 2.652714760000731076e+02 2.863852813340179182e+02 1.838252831614893239e+02 1.814799327205894315e+02 2.338290144642930954e+02
|
| 73 |
+
2.526381992552952340e+02 2.089745531365245483e+02 1.869938021147821701e+02 2.864405091884094645e+02 1.736924996547539877e+02 1.479914815134324613e+02 2.132537252074255321e+02 1.830098172980584934e+02 2.476607236946428827e+02 1.066503395377639265e+02 1.405219898965278276e+02 2.743866427972425299e+02 2.269305408710248173e+02 2.791638036143738191e+02 1.824422387811073634e+02 1.852994662516045423e+02 2.777032940597408128e+02 2.109153407914434126e+02 2.214759900082639490e+02 1.857033490029854761e+02 1.302118293337227328e+02 1.889562709124264188e+02 1.844813915245081546e+02 2.875482403705134402e+02 2.022892465111445404e+02 2.230217175841083872e+02 2.843056043891419904e+02 2.350834055358549222e+02 2.080929758762673032e+02 2.770814576487081240e+02
|
| 74 |
+
2.389430507965955428e+02 2.463651891862864147e+02 2.369578462650186452e+02 1.902366989508459199e+02 2.003468797600664004e+02 2.681735461841141728e+02 2.362787745532336601e+02 2.323782975776413480e+02 2.525302892415198812e+02 2.828059530799229151e+02 2.840327053185673662e+02 1.223941816187275435e+02 1.056255174412387134e+02 1.386503050117574105e+02 1.384325506562210535e+02 1.176641636239777426e+02 1.670688688422628161e+02 2.506322552784647826e+02 1.181229702988334083e+02 2.607048520072489737e+02 1.667476448166365515e+02 1.310085831735554223e+02 1.553111545647699927e+02 2.907454039462255651e+02 2.844644695877585718e+02 1.989933906493695019e+02 2.662036190025202131e+02 1.792754658114438371e+02 1.073664330563030944e+02 2.793141822468826376e+02
|
| 75 |
+
2.640306978448612654e+02 2.458161373226257069e+02 1.015510894380497575e+02 1.527048938693112916e+02 2.893334394723561900e+02 2.994916089563248534e+02 1.054055716033572452e+02 2.278819528330843127e+02 1.890909183007994443e+02 2.134436011261824433e+02 2.654189934957544210e+02 1.780852604264427725e+02 2.222277079756825628e+02 2.689688042831336361e+02 2.232046857529678050e+02 1.778434593737022169e+02 1.336418515516146783e+02 2.739064893378349552e+02 2.065065746675076355e+02 1.329712924393647313e+02 2.176938186185978736e+02 1.918043587714230114e+02 2.280421349429639122e+02 1.182282112372680842e+02 1.370131137248831692e+02 1.716251366233928195e+02 2.412427837766657888e+02 2.738208811966829899e+02 1.471415247536169488e+02 1.638288393831292353e+02
|
| 76 |
+
2.669085627842696908e+02 2.477147782526785136e+02 1.718200513884793565e+02 2.299346472745743597e+02 2.016242169414389309e+02 1.631378839470685307e+02 1.859938403107781255e+02 1.609729169019194330e+02 1.536303039404505171e+02 2.234728543554556950e+02 1.953401084257108096e+02 2.920381588589057174e+02 2.034966688752892310e+02 1.019427894404581139e+02 2.980736970140829953e+02 1.738263823108001418e+02 1.531314323312329293e+02 1.400030133312995702e+02 1.802287961283190043e+02 1.719909696301723443e+02 1.974918793689569725e+02 1.666882741246514001e+02 2.879569025675030502e+02 1.334044307903087088e+02 1.016937569869423896e+02 1.660343944328368764e+02 2.214967229035601974e+02 2.539424882366704992e+02 1.211914878013190133e+02 2.835892388637473687e+02
|
| 77 |
+
1.704109091340931741e+02 1.337843054639438378e+02 1.570106251098002588e+02 2.123587857442842335e+02 2.788290802167920219e+02 2.795601449888932848e+02 1.220747715539721696e+02 1.179984498565524405e+02 1.552783750686872963e+02 1.257256444039083192e+02 2.312614004137946893e+02 1.971625968209403084e+02 1.208837070227885135e+02 2.231693789143681386e+02 2.332576722664892941e+02 1.659208209363902711e+02 1.979623049620595907e+02 2.497459328714609512e+02 2.540243570817084446e+02 1.309045902221261599e+02 2.376613837929333499e+02 2.140333351750954023e+02 2.231625169053620539e+02 2.869160136215916737e+02 1.282002159167354023e+02 1.029173927424986488e+02 2.432034421383394545e+02 1.495648010251883306e+02 1.971910657968611247e+02 1.358409247687675361e+02
|
| 78 |
+
1.833826243837603442e+02 2.960483510370855811e+02 2.343723986770386318e+02 1.560358896543934293e+02 2.499669478251469172e+02 1.762005778153444169e+02 1.918050503412152921e+02 2.089352602085182866e+02 2.770127170480132008e+02 1.268157216157417224e+02 2.670673189640755822e+02 1.547628252866769287e+02 2.602514896343354849e+02 1.557532905756793866e+02 2.574076233589491949e+02 2.646855654359934533e+02 1.749681240869035719e+02 2.465698370051858035e+02 1.076897610845538082e+02 2.337637497458482301e+02 1.791847918196868932e+02 1.967068388721293104e+02 2.340964493346380095e+02 2.762770912600988140e+02 1.174465260954359564e+02 2.950490567997024982e+02 1.354710376622284116e+02 2.342233227246520642e+02 1.617966271393036379e+02 2.107879984327653915e+02
|
| 79 |
+
2.493754578342164336e+02 2.275093847135933061e+02 1.466148442335522191e+02 2.261697123059220189e+02 1.213252451599347950e+02 1.628949300801819504e+02 2.100466501082228206e+02 1.508908296808102989e+02 1.488199564735201079e+02 1.727131563468088302e+02 2.306747713688439205e+02 2.570279850661015644e+02 2.309125192178541113e+02 2.422081718543400370e+02 1.769407234272878782e+02 2.688532243604371956e+02 2.276780878660686085e+02 1.065345319601523641e+02 1.535069430280279050e+02 1.717902253122074967e+02 2.876755354986605084e+02 1.683056100689713332e+02 1.120105413679224569e+02 1.755508096146901664e+02 2.095863991316655870e+02 1.523590730880595174e+02 2.944635547123552897e+02 1.444697311944634066e+02 2.165062978405008494e+02 1.410128743297030098e+02
|
| 80 |
+
1.434402193906418006e+02 2.368914090178307106e+02 1.963465933374949941e+02 1.914557752364961516e+02 2.870767419320768568e+02 2.044699144835463187e+02 1.223520556576680036e+02 2.352284247043744472e+02 2.917945011866975165e+02 2.225925999946875322e+02 2.240309397680480288e+02 2.048455962243571093e+02 1.188048963943729035e+02 2.200553599997707579e+02 1.885605934416515765e+02 2.863412817843446874e+02 2.913876692311304737e+02 2.446563674684449552e+02 2.981153955140326843e+02 1.111775924383378253e+02 2.239868361016714857e+02 2.540473271011064469e+02 1.343930974769885438e+02 2.368686732696482409e+02 1.175691554116390591e+02 1.014879352562223715e+02 1.330784448687188046e+02 2.045426156006566885e+02 1.168174380391246245e+02 1.704438548713551995e+02
|
| 81 |
+
2.696784010384477597e+02 2.991318545155386346e+02 2.120364825583467336e+02 1.950895785161033018e+02 1.216112431291165592e+02 2.438998438799096391e+02 1.588292735755803733e+02 2.347670069791354024e+02 1.862846309471772770e+02 2.258642611266068343e+02 1.423367506635381119e+02 2.692888471853933083e+02 2.950212092401994255e+02 2.331327670110776467e+02 1.542291422318579635e+02 2.809064569107727038e+02 2.358857646534314654e+02 2.378124255062788563e+02 2.664164586086786812e+02 1.387157904298663880e+02 2.297158046581682243e+02 2.386372312695162634e+02 1.246509391338716171e+02 2.338956320284196408e+02 1.820257170558419944e+02 1.957425768708682767e+02 1.680974560138464540e+02 1.288235048549348676e+02 1.483029350020115089e+02 1.744880718659300669e+02
|
| 82 |
+
2.512494238114035738e+02 1.112846425403449615e+02 2.472643304237797395e+02 1.241745840646870818e+02 1.808849124644312099e+02 2.524760780760417731e+02 1.836118621524309447e+02 1.408362492891266982e+02 1.099623406752946693e+02 2.383967522197594064e+02 2.436606913384966049e+02 2.770699525768120566e+02 2.597573569531676867e+02 2.935649366424795517e+02 2.702790297508025219e+02 2.563597369995835606e+02 2.279477293752616447e+02 2.477470305460766440e+02 1.962131167814513333e+02 2.859744526791636190e+02 2.703401534622389590e+02 2.763052603711840902e+02 2.934416645125817809e+02 2.193475948646207030e+02 2.822891098008749395e+02 1.085391177109117820e+02 1.782208012387337703e+02 2.335496863699061976e+02 1.715066387390946829e+02 1.948062204233656303e+02
|
| 83 |
+
2.879262290016004613e+02 1.676743911135137068e+02 1.403503828589753937e+02 2.744454339345198832e+02 2.935124358491533485e+02 2.920282649929100671e+02 1.390240222956847447e+02 2.426642861805074745e+02 1.217336684570653489e+02 1.311823750440439085e+02 1.647679902066092836e+02 2.962811279981685288e+02 2.945746172932865647e+02 2.005257587949587332e+02 2.072045953580022228e+02 2.893049469033056766e+02 1.913962360581630833e+02 1.823675529874825543e+02 1.830342103129283373e+02 1.222396004373517400e+02 2.248239872372262482e+02 1.170253438297526429e+02 2.853825568202013301e+02 2.214973458763422514e+02 2.563932510909227176e+02 2.144837192650675206e+02 1.793062298958048473e+02 2.920176466690815005e+02 1.515607839109829627e+02 1.981203765908239802e+02
|
| 84 |
+
1.733053660232129403e+02 1.312183264386245583e+02 1.276233157677672807e+02 2.020942572504836789e+02 2.314817368496994732e+02 2.242589617101967008e+02 2.160504620978007893e+02 2.360595788588375399e+02 2.952977074031120992e+02 2.334652590044975682e+02 1.243453875174208747e+02 1.916144242306085630e+02 1.092365115042800596e+02 1.478765005471206280e+02 2.191946613400726278e+02 2.879274886834762697e+02 2.733443652356662597e+02 1.858481832262083344e+02 2.193747651131673706e+02 2.695165737089945424e+02 2.960753121523491700e+02 1.890691006834304631e+02 2.638343907584013550e+02 1.510492177865631334e+02 1.878288206285384661e+02 2.726561149875388992e+02 1.704246795027074199e+02 1.006381753343381718e+02 2.153734239260733148e+02 2.551451126036402854e+02
|
| 85 |
+
1.591849792872858984e+02 1.304671215023752779e+02 1.427456440770346831e+02 2.882324895344759170e+02 1.680635293254793510e+02 1.205800311663507642e+02 2.861305963205076637e+02 1.219224106654408928e+02 2.467003871618023538e+02 2.830287806498602095e+02 1.445950870572595193e+02 2.496562286252286640e+02 1.464987579205844099e+02 2.848280464142704318e+02 2.785616857190397013e+02 1.837468579783306950e+02 1.246964377230690673e+02 1.251791080124520050e+02 1.496399061799681363e+02 1.375936265087168522e+02 2.547928467777094852e+02 2.554856419260690927e+02 1.285559318166884850e+02 2.092144446410586909e+02 2.868951534942014518e+02 1.178319347908447270e+02 1.347784205269015274e+02 2.851299399919766984e+02 1.754694686670390809e+02 1.016886128619324694e+02
|
| 86 |
+
2.606618423405234353e+02 2.125366732076933545e+02 2.822772640751277322e+02 1.096405633955119185e+02 2.437561663288932721e+02 2.129146561548243994e+02 1.148823764090175530e+02 1.516868774610028368e+02 2.090025176018670265e+02 1.817684320186263562e+02 1.584667226055155709e+02 1.501973711988126468e+02 2.530199923706828713e+02 1.847948752811591930e+02 1.778871618489498303e+02 1.664551902511519188e+02 1.100020157933824265e+02 1.352000835393275509e+02 1.710981737682794801e+02 1.530513645967782566e+02 2.588476693974693035e+02 1.775587245068043956e+02 2.006331886716666588e+02 1.389709403689849694e+02 2.489553638298030194e+02 1.673604491791948021e+02 1.991154502489720812e+02 2.423848982654565418e+02 2.882603768001737308e+02 1.620650086718309240e+02
|
| 87 |
+
2.723642490909132903e+02 1.680927290528325670e+02 1.005734627393615455e+02 1.598916606218045047e+02 1.672547346703738071e+02 2.361420151042074451e+02 2.741857058408131707e+02 2.533004150866734392e+02 2.036092771261417340e+02 1.091915011443997230e+02 1.145604210422382323e+02 1.209982156413156247e+02 2.749595368914399387e+02 2.177794513808643160e+02 2.054163746311436967e+02 2.185860861470465579e+02 1.504022045473846845e+02 1.713704456854883347e+02 2.175221629008602804e+02 1.230663148243889253e+02 2.419648244223723168e+02 1.383010418990747326e+02 2.040260833828849059e+02 2.966316994044250919e+02 1.630596872908637351e+02 2.562534082821714492e+02 2.549425872735235998e+02 1.983522705781282127e+02 1.524860865223137694e+02 2.736848821358530586e+02
|
| 88 |
+
1.277021385004174192e+02 2.448445434866889343e+02 1.296687360965440803e+02 1.874271582575348702e+02 1.145742775945452792e+02 1.884744688522491742e+02 1.336298647132909423e+02 1.523816963142488419e+02 2.658270705367647224e+02 1.781637174983711134e+02 1.154610011723892171e+02 2.005342781476718415e+02 1.303166615041172918e+02 2.397284110571510496e+02 1.612912854182502542e+02 2.821645080329541315e+02 2.544831471501324813e+02 2.622237400581972224e+02 1.417212269902922230e+02 2.054005404298748658e+02 1.092142219674599062e+02 1.652051184306486107e+02 2.825679563619778492e+02 2.056286073102957630e+02 1.772062144904277545e+02 1.163520479257007310e+02 1.006186351926139366e+02 1.734025793931427586e+02 1.446958902579306709e+02 2.025820689614877779e+02
|
| 89 |
+
1.798382687901162740e+02 1.604629760861514001e+02 2.668981169240885265e+02 2.763242846779806996e+02 1.318105471716862098e+02 2.191362245125996537e+02 2.770758446308884686e+02 2.308910816293108326e+02 2.956895796828827656e+02 1.566426856848869988e+02 2.326210561246332418e+02 1.206555816723871715e+02 2.603144096756907970e+02 1.172571782204154829e+02 2.219493974369055991e+02 2.385109304229506790e+02 2.599678734377965839e+02 2.850516346518521686e+02 1.472948582444382168e+02 2.234296740595885922e+02 1.427895312415343199e+02 2.848238578369252423e+02 2.260232767550441508e+02 1.544648385858973541e+02 1.163971462755376791e+02 1.762731012775239492e+02 1.089523563056807660e+02 1.663966154222005116e+02 1.342495772836978745e+02 2.922401077696804350e+02
|
| 90 |
+
2.806557294060240224e+02 1.077657131130299604e+02 1.622983596366119059e+02 1.723469481204717795e+02 2.678046848873893850e+02 1.442059922525422451e+02 2.629931208031973711e+02 2.741083495447689415e+02 1.194142462414748707e+02 1.688961325073638022e+02 2.967954354880449728e+02 1.822107331135221671e+02 1.292333403080546645e+02 1.856814508383810391e+02 2.103923137448445573e+02 2.517859299913771451e+02 2.551152596962431574e+02 2.077883190793959898e+02 2.986930461834413677e+02 1.196764061335889551e+02 2.378823960447958257e+02 1.692017967083341432e+02 1.471250494556689432e+02 2.608355254883699672e+02 1.757172426071724942e+02 2.629426236813185369e+02 1.040244734248400533e+02 1.533558690719498827e+02 2.011860465194789072e+02 1.720545334339216765e+02
|
| 91 |
+
2.966488050331527688e+02 1.809989340563203086e+02 1.871527370563514978e+02 2.315558973515319394e+02 2.657682292004950000e+02 2.237816732699509998e+02 2.282045922056215090e+02 1.846236325909775928e+02 1.644827554373339353e+02 2.760250360653360531e+02 2.492622345937652995e+02 1.483432536002697191e+02 1.527550390024584601e+02 1.573429964258168070e+02 2.090721206423400247e+02 2.535819867756219708e+02 2.420536340362719159e+02 1.691914404667937788e+02 2.388696721384086459e+02 2.593840245957078423e+02 1.331872961625781500e+02 1.116342264469163581e+02 1.680964276125217793e+02 1.555020753508222526e+02 2.422052215908822177e+02 2.626184375196450560e+02 2.674230788003709449e+02 1.948146659156083729e+02 2.663681889818526543e+02 2.795342087705012659e+02
|
| 92 |
+
1.674728956867265310e+02 2.635505920196726493e+02 1.395353777027027604e+02 1.883233466008314565e+02 1.249441512057495913e+02 2.512189370435067417e+02 2.719913755602378842e+02 1.237326636617429614e+02 2.939951219495833357e+02 1.686366002602222807e+02 1.800181056076297068e+02 2.288525977776352818e+02 2.717306800175948638e+02 1.565292507387619594e+02 1.445460932655216766e+02 2.092313282690445249e+02 2.370375511382032698e+02 2.880525812713749474e+02 1.172567175017127141e+02 1.112412797274302250e+02 2.246954385922853135e+02 2.812359340959551446e+02 1.004168603505609241e+02 1.005387863078678805e+02 1.815971195408835683e+02 2.811251817522295937e+02 2.605765849402707772e+02 2.298114360271968621e+02 2.557293814584297706e+02 2.542416589790913122e+02
|
| 93 |
+
2.943583269632734414e+02 1.442274778682184717e+02 2.700917391987959491e+02 2.527420049761408904e+02 1.527279900348522688e+02 1.841979337126335281e+02 2.902442440856567600e+02 2.889101481258517765e+02 1.828125218264408716e+02 1.133179379993730862e+02 1.484787634874768116e+02 2.676352293304336740e+02 1.452118425579454311e+02 2.636966617786087568e+02 1.313546620759107100e+02 1.834019443937838787e+02 2.892465421328221282e+02 2.575015388377624959e+02 1.970702343003932242e+02 2.507528167727347181e+02 1.724897096143170074e+02 2.664268628760375464e+02 1.365257050051324370e+02 1.198011035974838308e+02 1.176831988053894520e+02 1.070946883963453899e+02 1.964638491125322446e+02 2.570844982939356100e+02 1.593905150913052466e+02 1.202569936867807598e+02
|
| 94 |
+
2.734271498156417692e+02 2.352133531486530842e+02 2.590835237087205769e+02 2.260994493040042528e+02 1.805421354394846105e+02 2.728408805160995598e+02 2.367263522625478913e+02 2.580210451062748689e+02 1.204524877415260562e+02 2.946465680607327613e+02 1.547220269335912803e+02 1.186203172746691337e+02 1.923878728892914864e+02 1.094127410697402354e+02 2.222837240826847278e+02 1.529333599077602628e+02 1.861450256630199647e+02 2.125583079944122176e+02 1.527591657960447264e+02 2.694001797345342766e+02 1.986063989766776388e+02 2.192493126389772442e+02 2.986827335637019587e+02 2.790660387254000625e+02 2.781487003899754313e+02 2.564198676846006606e+02 2.597551240338123648e+02 2.358970425952163907e+02 1.951628676328612357e+02 1.078208269500064347e+02
|
| 95 |
+
1.190762776130697205e+02 2.951075493308472346e+02 1.091043363430719069e+02 2.824365312299846664e+02 2.445811468414383398e+02 2.538090805786315514e+02 1.230092364266577363e+02 2.633887649939744051e+02 1.865216093980499181e+02 1.540388898662323243e+02 2.047343894245035756e+02 1.431412534309083640e+02 2.857794001060171922e+02 1.492366175285521592e+02 1.380934567887849198e+02 1.331831467466375898e+02 1.149412013934811796e+02 2.205070844660474734e+02 2.939252657951740844e+02 2.049464694042562769e+02 2.047902832862141054e+02 1.810793422252176015e+02 2.005356992447976836e+02 1.381400138775680375e+02 2.582445444487385657e+02 1.698212931623984616e+02 2.252085951830697468e+02 1.808378144669676999e+02 1.307311344108444473e+02 1.050024101356033697e+02
|
| 96 |
+
1.722314120162143354e+02 2.530014253763471856e+02 1.298340795948372772e+02 2.948664870226410812e+02 2.383106068289312702e+02 1.822969205106659558e+02 2.285226769051377005e+02 2.759417691711663565e+02 2.120970517474504220e+02 2.831046044310812704e+02 2.320579821788242612e+02 1.286125039667014960e+02 1.609837368065715282e+02 2.931112965353385107e+02 1.441758663366052531e+02 2.810263276191118962e+02 1.239857273771131077e+02 2.399447548605567988e+02 1.460208836055017514e+02 1.205325462037979491e+02 2.112513935912650993e+02 1.036793750016967692e+02 1.113202625217208777e+02 1.646612561683649574e+02 1.018350908838390581e+02 1.263835026124204859e+02 2.766683711501553944e+02 1.682407929561517506e+02 2.677103056024840271e+02 2.147294480454548307e+02
|
| 97 |
+
2.763536852866382105e+02 1.511976958084401872e+02 1.026794659371155944e+02 1.805990415690671398e+02 2.442493962549426385e+02 1.881796213041043018e+02 1.028768312506858535e+02 2.787706953534510603e+02 2.589640601731795755e+02 1.730107396932538677e+02 2.218419822849910190e+02 2.651646152747807719e+02 1.476149140151474342e+02 1.986450675254654072e+02 1.050693447352362853e+02 1.819666738706916931e+02 2.873544952103893593e+02 1.472060704631180954e+02 1.297023844405691761e+02 2.824778443572924971e+02 2.918073394139615289e+02 2.128134400148996974e+02 2.223096450508596149e+02 2.761940547406351811e+02 1.348708672340777639e+02 1.857009592938832441e+02 1.062906640064134649e+02 2.104442283262811202e+02 2.812954268214299418e+02 2.739038950945439979e+02
|
| 98 |
+
1.837264129055918147e+02 2.399207190527903322e+02 2.843910623120511900e+02 1.773207161532972975e+02 2.056581469496123873e+02 1.558029517788254168e+02 1.458438122541016924e+02 1.893030782939712253e+02 1.139027557376393673e+02 2.228775749423569437e+02 1.367670384452707140e+02 2.854480456674787092e+02 2.424985140340279202e+02 2.940521113211518696e+02 1.330693282221190259e+02 1.212599008475133076e+02 2.754747741586869552e+02 1.062856492128348549e+02 1.212724485003486166e+02 2.100514698158626743e+02 2.547262582240854272e+02 1.999488755181088777e+02 2.578561029518564283e+02 2.784200494851090752e+02 2.728829168298310606e+02 2.071711407548560544e+02 1.708729380756020362e+02 2.726254883308487251e+02 1.104364015278258364e+02 1.175773277008901090e+02
|
| 99 |
+
2.554381337818412305e+02 1.634513906120204183e+02 2.309962436793083214e+02 2.460443770945291249e+02 1.618890365991254896e+02 1.046310291743186980e+02 2.772116654811295575e+02 2.098555252827713957e+02 2.309383801112169863e+02 2.845300950466865402e+02 1.268119123926061320e+02 1.697885006171669602e+02 1.901887742560337529e+02 2.605757830463372215e+02 2.755463791239279772e+02 1.771647294768940810e+02 2.403902735905423356e+02 1.774352552408031443e+02 1.796883744424403631e+02 2.736192366006921475e+02 2.118505050785533967e+02 1.873353967662169453e+02 1.802980863638028950e+02 1.869858546159753132e+02 1.200946851663063342e+02 2.350811068219035178e+02 2.018941614745772313e+02 1.010158706413519525e+02 1.661546933057649937e+02 2.570882207683835077e+02
|
| 100 |
+
2.856134023048114159e+02 1.356279054667102741e+02 1.225310201562991494e+02 1.529777144242077327e+02 2.936506440162480658e+02 2.589580133771784176e+02 1.864782805190425279e+02 1.931182124516369640e+02 2.913608028278327993e+02 1.555662042949096531e+02 1.173676742008071301e+02 2.242990267171766732e+02 2.651338851871976203e+02 1.128980005738893482e+02 1.283582653966309408e+02 2.071495534530326097e+02 1.241509031508031740e+02 2.393403040292282640e+02 2.829812266966206380e+02 2.294799861563923287e+02 2.129576840814710295e+02 2.165539860914115877e+02 1.357366103660294243e+02 2.396252028023287153e+02 1.395106368224716107e+02 1.700689743264745744e+02 1.253435651632085950e+02 1.508112259783626428e+02 2.310267786371028933e+02 2.311667616985857876e+02
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-int-data.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-67 65 82 64 51 1 -12 2 -84 -52 12 82 -45 -84 -41 31 -49 36 -70 40 -74 -99 32 64 -6 43 -53 -43 43 96
|
| 2 |
+
-58 20 25 99 -25 78 -6 59 -23 30 36 25 -8 83 -43 -7 -8 42 -90 96 46 88 31 12 68 -21 -6 7 78 -19
|
| 3 |
+
-66 -51 0 13 42 -43 -30 -29 20 10 -24 -5 -42 38 -56 6 1 -80 -65 -91 89 64 -21 49 -84 41 6 -78 71 -2
|
| 4 |
+
-50 -84 -50 -66 46 -88 -10 -28 -25 6 -7 10 -35 86 41 -17 72 -67 13 -67 -76 -84 -15 35 67 40 90 38 -1 -47
|
| 5 |
+
-51 27 -48 26 -73 -46 -68 -56 -38 -4 49 -64 57 -86 -80 70 50 34 84 97 -76 3 -54 -89 -7 -53 15 36 -28 85
|
| 6 |
+
2 -59 4 30 70 -42 -26 -1 27 -90 -18 95 -10 -36 43 24 86 -8 -100 92 80 -40 17 -93 -81 54 -8 84 -53 38
|
| 7 |
+
-80 0 -71 -41 -33 9 -61 0 26 80 64 67 74 68 -72 78 -72 -52 -19 37 -33 -24 -11 -71 -53 -16 25 56 -74 0
|
| 8 |
+
71 -23 49 -36 -43 -70 82 69 -100 -27 50 20 30 84 -33 90 49 39 -52 -51 -86 -76 -72 -88 12 91 -96 -61 -87 -47
|
| 9 |
+
21 39 1 78 68 -80 -54 71 17 -94 34 -20 14 -5 -24 55 -84 -50 -90 -24 -79 -81 53 -50 22 -13 -92 78 -22 -50
|
| 10 |
+
-47 -73 77 -93 -20 51 -37 -14 -37 -18 -8 -14 -71 29 -27 -5 54 77 -7 -2 15 -23 98 -34 -65 -78 -77 -90 -5 -35
|
| 11 |
+
92 -33 71 24 43 -19 50 -40 -48 -33 -51 -14 23 40 -78 -14 -76 1 52 69 93 5 -13 30 -60 -20 -54 49 -52 93
|
| 12 |
+
32 -86 21 -41 -86 -38 97 -35 -37 -89 -15 -18 -46 -37 8 63 -63 -61 57 50 43 -27 -45 98 -56 -81 16 -38 -25 -28
|
| 13 |
+
-18 19 -52 -86 92 -72 23 35 20 57 69 -22 52 -66 -74 -29 -1 -10 -97 22 -97 -93 -70 87 85 -31 42 -29 -10 -36
|
| 14 |
+
78 80 -93 68 41 84 -37 -62 38 -9 99 -60 90 47 -33 -40 -59 97 -28 9 35 -6 -60 -83 -39 -97 -25 -78 95 40
|
| 15 |
+
79 -35 -45 -46 69 10 29 -88 98 -44 66 11 45 -58 -11 -25 51 -44 54 30 59 98 35 -28 93 86 99 19 -27 -83
|
| 16 |
+
80 77 -72 57 -35 -27 86 -67 11 77 -28 -89 -30 -31 -72 64 -95 -75 92 -32 -96 -14 6 -83 -66 -58 71 -17 58 -53
|
| 17 |
+
-1 17 -72 82 -57 -48 -7 -44 -80 85 -99 -9 27 -11 24 13 86 18 67 -9 12 77 98 49 49 12 -82 45 31 -68
|
| 18 |
+
-13 -75 -26 17 91 12 -95 -62 -54 -60 22 50 86 58 -11 -11 -21 31 16 -15 67 90 1 80 -57 -98 35 -54 51 91
|
| 19 |
+
28 -75 -31 49 0 73 75 -66 50 -77 -20 82 -40 -90 -28 32 -44 89 -75 -33 -11 -19 -55 79 18 2 -39 -49 78 -72
|
| 20 |
+
14 56 78 69 -40 -20 -39 71 99 -89 60 -82 -1 -77 -42 94 -41 35 72 11 -13 89 -52 -41 -93 43 -39 -61 68 -4
|
| 21 |
+
88 18 -90 -75 -49 46 -28 -48 -69 -64 77 -8 91 -65 62 -27 -19 34 10 78 82 49 -34 63 78 -88 -17 -37 -85 91
|
| 22 |
+
4 36 -77 -75 -12 70 42 8 7 -31 -69 -74 -65 18 85 -92 91 16 -15 24 -74 -56 71 -70 -90 20 13 73 -68 -65
|
| 23 |
+
92 22 -31 -73 -59 -78 -20 -11 -61 36 -40 34 -96 -12 51 -45 -12 12 -3 -42 -71 68 -8 -91 50 -73 -96 -46 -38 -4
|
| 24 |
+
-87 44 -58 -83 70 -81 32 29 -79 45 -64 -52 57 73 -80 69 7 -22 31 -71 -34 -33 47 79 -17 6 -77 -89 3 50
|
| 25 |
+
85 2 73 -88 -99 -13 -76 1 -90 51 30 -52 75 -2 -8 10 -83 -40 -5 -79 82 19 79 94 49 4 66 -76 6 -48
|
| 26 |
+
29 -34 66 -93 45 -1 -98 92 -92 29 -10 64 -23 -81 -73 -62 -18 37 -29 -50 -52 90 -28 24 -4 -67 -33 25 -78 93
|
| 27 |
+
57 -46 36 -16 34 -59 -96 -86 64 2 28 42 -32 6 -17 37 38 -40 -92 55 -22 -42 11 -77 12 81 -89 -39 -30 -39
|
| 28 |
+
-72 -68 -41 -5 93 55 24 -6 84 77 30 33 -51 -62 6 -5 -83 60 -1 -64 7 -7 -92 31 5 -21 -34 -14 21 -33
|
| 29 |
+
26 -75 -36 -54 -21 -38 -49 -20 82 73 -84 -5 -69 84 -87 12 7 -67 -40 -50 -35 -65 80 -83 -2 1 34 -16 91 82
|
| 30 |
+
61 -21 1 -64 -56 -61 74 16 0 38 51 34 -35 37 -28 -52 -14 61 14 58 50 27 -43 -27 14 56 -16 -78 50 -89
|
| 31 |
+
45 -47 -61 68 -41 -70 14 -51 49 -84 64 -65 88 -39 -88 28 -55 -18 81 -2 -1 -45 65 -6 62 16 71 71 -1 47
|
| 32 |
+
47 60 22 -42 -5 -74 12 66 89 -82 -85 65 74 0 -18 56 -39 84 -65 -42 -33 -60 23 33 -8 -72 3 -64 -3 -25
|
| 33 |
+
-70 11 -19 -12 -1 -50 -89 -61 78 28 55 92 -17 86 -17 -45 -31 68 -24 -99 -59 27 79 -2 21 -80 54 9 14 -70
|
| 34 |
+
-38 52 -99 50 -46 -63 -74 -41 -43 -62 -81 38 -99 17 -94 -6 44 -20 -13 -30 71 -43 43 -28 -8 57 -93 98 4 42
|
| 35 |
+
-17 -27 -60 -22 86 -49 39 -83 72 -16 82 74 73 -29 16 -59 81 -60 -96 51 -62 -55 -79 -31 -15 -67 -18 -83 -61 -86
|
| 36 |
+
28 37 -44 7 -17 -10 -65 8 -78 -17 -46 -5 -35 -86 13 -16 27 24 60 -12 -48 -45 16 -33 70 -45 -63 -60 21 70
|
| 37 |
+
-75 -89 -93 -93 62 -44 -39 46 31 57 72 30 -65 29 66 -53 2 -2 71 -90 -73 -40 -63 32 68 30 25 98 38 92
|
| 38 |
+
88 3 5 73 -2 -61 -94 79 99 94 71 -83 -40 80 -79 -14 -34 -99 -52 27 23 13 13 -35 -74 13 43 -19 2 -62
|
| 39 |
+
92 -47 -27 9 -68 -86 -57 43 9 -81 -9 69 52 -28 80 -13 -6 -44 -81 -89 -10 30 -64 86 -76 -11 -100 15 12 -62
|
| 40 |
+
76 -42 39 70 74 79 84 -52 18 -58 78 53 89 58 -32 20 -51 35 12 37 -70 -21 5 97 67 -25 -25 -10 2 30
|
| 41 |
+
-84 26 -60 -34 11 -27 47 85 -89 29 54 -53 66 -9 12 4 92 70 2 -12 -55 72 -62 -79 -8 68 -19 12 -8 -100
|
| 42 |
+
78 -97 -76 86 -47 42 99 -3 9 49 -84 86 26 43 -26 90 23 -66 -37 -35 25 -12 -42 -12 96 -15 48 87 -95 -12
|
| 43 |
+
-60 57 -30 -4 -84 24 -82 -5 34 56 76 81 -64 23 32 34 -41 -48 -6 77 -42 64 87 92 82 59 9 -71 -56 -45
|
| 44 |
+
-74 -90 -27 93 33 15 -35 -73 78 23 17 -28 9 63 9 35 15 32 0 -4 -32 54 -76 14 -14 -8 16 -43 -81 57
|
| 45 |
+
-2 22 85 -33 -48 74 64 -59 -27 17 -65 27 -50 -81 41 -69 -26 -29 -83 48 -81 51 58 -62 -63 -55 -63 39 32 -34
|
| 46 |
+
98 -99 13 25 -10 43 -62 50 82 -90 -51 40 -71 82 27 -73 19 -62 37 10 -21 45 -94 -45 -41 -3 44 86 -2 27
|
| 47 |
+
-80 -89 -57 87 -42 19 32 -49 37 -4 -30 54 46 -3 -92 89 60 37 -86 38 61 93 45 -45 -86 54 21 45 50 -53
|
| 48 |
+
7 -68 71 -6 41 -72 67 45 15 46 85 59 82 19 65 75 -62 -35 47 -51 23 41 -54 27 -99 14 9 69 60 62
|
| 49 |
+
99 -51 83 -47 -19 -57 -22 51 -52 52 92 80 69 1 -31 0 -19 -54 73 -5 3 82 -86 -84 -95 -83 -92 -52 -90 -79
|
| 50 |
+
43 -75 62 99 66 -43 -38 -21 23 35 -63 -61 -46 5 3 -90 -28 55 87 89 -29 -46 23 -61 -5 10 -70 -63 50 -14
|
| 51 |
+
39 38 10 66 -24 -45 55 -33 31 29 44 31 73 44 6 69 -21 -58 -3 93 -51 86 -16 -88 88 -30 75 78 -20 -12
|
| 52 |
+
-11 11 -19 40 82 6 10 22 90 -78 -88 -49 72 69 -62 42 -23 22 -38 -98 0 -3 -43 20 9 18 -67 -7 22 21
|
| 53 |
+
99 80 -55 74 43 -31 60 -26 -29 -6 75 60 92 -42 85 18 1 1 -74 -44 -12 72 -57 -98 99 62 45 -40 -39 -75
|
| 54 |
+
50 30 -18 -29 -80 -59 -96 46 -99 -76 -13 -75 -93 -95 -45 62 -37 53 -96 57 -40 3 14 -45 -84 58 75 16 37 -6
|
| 55 |
+
1 -47 87 -99 -22 -22 -20 71 -91 13 35 -80 75 65 -87 16 -37 99 -60 49 52 18 55 -11 18 24 -65 -80 8 -79
|
| 56 |
+
-8 -87 86 -9 -64 -76 59 -52 -89 18 13 70 44 93 99 62 39 49 83 28 72 -71 -13 -71 -22 44 -87 73 -68 80
|
| 57 |
+
41 -26 44 -63 -26 -83 -44 63 -51 -48 52 -8 55 73 -45 84 40 45 32 -34 -78 -46 -79 57 -40 11 34 -75 -20 91
|
| 58 |
+
94 9 -35 -5 3 59 -63 2 -7 -72 -34 -70 78 99 -29 37 11 91 61 29 85 -15 59 79 47 41 19 -18 -92 47
|
| 59 |
+
-59 -89 57 -72 -79 88 -85 18 -35 -96 -57 33 83 70 -55 -16 -21 72 -53 89 -44 -86 9 -44 -26 78 2 -93 -75 6
|
| 60 |
+
55 73 89 80 -69 -93 -39 -88 62 49 91 -68 87 -26 40 16 -49 -53 -57 23 -97 39 -78 44 -15 1 60 -87 43 -42
|
| 61 |
+
-2 -23 -74 -80 -59 52 -58 68 64 97 -86 -41 -88 35 49 3 -40 90 34 -2 3 13 -95 8 -1 6 75 92 19 -31
|
| 62 |
+
57 76 65 3 37 -72 -43 57 64 -23 41 87 26 76 -18 -32 28 47 11 47 -33 -12 4 81 -92 -47 -81 43 -2 5
|
| 63 |
+
68 74 66 -89 -95 -40 -78 -58 -54 -20 2 20 94 -35 58 -20 41 77 0 95 39 14 36 -40 -85 -60 -63 82 0 58
|
| 64 |
+
-61 -99 61 10 -2 -31 -70 37 -77 -10 85 95 -28 70 -81 -78 -68 -33 -77 77 -6 42 -100 -68 -59 -86 -42 -74 35 -32
|
| 65 |
+
64 -1 -1 -64 51 11 -65 47 -87 -8 5 58 22 -80 68 -25 24 59 -25 -75 95 -22 -73 27 86 -39 -98 -1 -17 -32
|
| 66 |
+
94 -50 -53 -62 -53 46 50 38 -95 -77 40 -38 -23 -14 -68 -20 -47 23 -8 -12 -92 -69 -97 30 94 -45 47 -81 82 -60
|
| 67 |
+
28 67 -48 4 74 27 -30 12 -32 35 91 -83 30 -55 -7 79 97 11 93 -45 -79 31 78 65 84 -23 -26 17 -61 43
|
| 68 |
+
44 60 -88 72 31 98 55 -4 66 -14 10 -81 -40 66 -15 21 69 -98 34 3 75 18 98 -6 47 -39 31 -19 30 -51
|
| 69 |
+
-6 18 -93 31 51 -20 -16 -33 -38 -19 71 4 -53 23 97 1 -28 -72 -44 -48 45 33 -76 86 64 49 -45 -34 -9 -76
|
| 70 |
+
-19 8 28 -27 -51 -58 -36 63 -92 -95 70 41 -38 -49 -95 -100 43 97 -60 -5 -56 45 -13 -3 20 -10 -21 -85 -5 63
|
| 71 |
+
-74 -74 -74 -39 -57 -12 51 11 -11 -22 -26 -54 71 24 -37 77 -90 77 75 86 -53 3 69 -99 -82 -59 30 81 -21 -86
|
| 72 |
+
67 63 87 -15 60 -82 87 51 -39 -49 -16 74 51 17 6 47 98 89 -20 -98 97 -61 18 34 37 -36 37 -96 90 44
|
| 73 |
+
53 -8 37 -76 -61 70 -77 -11 98 -80 12 -80 6 -89 8 -59 -69 -100 -52 -30 95 -58 61 29 52 -64 -51 10 16 -58
|
| 74 |
+
54 -10 49 62 76 -25 80 36 13 5 59 -65 14 41 26 -78 23 -45 -51 -85 91 -43 -61 -37 94 27 -11 49 98 48
|
| 75 |
+
53 -51 27 34 28 -53 18 17 31 -31 59 71 -34 25 54 -84 -34 -24 76 38 -36 15 -1 56 2 -12 0 26 -38 -62
|
| 76 |
+
4 -94 -63 -21 -95 -42 -12 86 14 -86 -1 80 -48 62 -47 -52 3 91 -86 11 79 32 -24 -33 -54 19 -17 28 -33 -97
|
| 77 |
+
-18 41 84 1 -83 48 -99 -64 26 -52 3 -64 68 -98 93 -79 -97 11 88 74 41 -31 -42 -35 -66 18 97 -30 19 -93
|
| 78 |
+
-19 42 61 -91 -20 59 -11 -64 -60 85 -6 -71 33 -52 46 51 -86 -77 74 -4 74 -81 1 -39 -30 12 -12 20 66 60
|
| 79 |
+
86 1 -67 -91 -92 -22 91 -90 -45 26 53 -6 99 46 -29 -40 -99 57 -45 -47 -3 -86 90 -78 -33 73 90 -51 -75 2
|
| 80 |
+
88 -34 -2 30 -18 35 -23 90 99 -49 90 -79 94 -38 48 67 -35 -58 81 -24 18 -54 83 65 -58 -12 13 89 -59 57
|
| 81 |
+
92 -99 94 -73 97 -78 -93 98 -78 95 -21 -17 -11 -92 69 -60 86 9 -36 -18 -33 -39 -65 74 -65 37 -49 87 -28 -81
|
| 82 |
+
-95 2 -18 20 93 54 86 -63 -5 -89 17 -9 75 -66 -64 -82 -46 -48 82 5 -89 19 -32 -45 53 -47 21 -9 40 34
|
| 83 |
+
86 87 55 -41 49 -10 -6 -7 -99 23 90 -50 -9 -81 77 65 29 -21 22 -82 19 48 -24 -72 75 -66 -69 -17 72 6
|
| 84 |
+
13 37 96 31 -65 -54 -91 -27 84 52 -9 -28 85 96 14 63 -34 -29 -85 78 -75 -44 -30 -5 4 72 -45 6 13 71
|
| 85 |
+
96 -69 67 59 69 46 80 42 81 30 89 -45 -10 -44 25 31 89 16 -36 86 31 92 1 5 -2 92 -11 77 20 40
|
| 86 |
+
-48 98 -100 30 54 9 84 -88 5 48 93 56 -94 -89 81 33 44 -30 -95 -98 29 -33 13 -26 -59 -80 -68 -40 12 11
|
| 87 |
+
82 -63 -30 -67 54 -68 50 -63 -91 -68 -45 -66 -58 16 -25 9 -50 -59 -55 4 -2 0 -63 67 30 -21 -8 55 21 -68
|
| 88 |
+
9 -8 56 -6 84 81 -63 -35 81 56 -50 -54 96 -51 86 0 66 -4 -18 65 -26 -57 8 78 -54 17 18 86 21 68
|
| 89 |
+
9 38 33 16 3 86 -57 28 -6 -44 -42 -2 3 -71 -86 23 34 -29 33 -30 67 63 -11 76 -65 92 30 -66 61 1
|
| 90 |
+
-72 -85 -1 64 -79 -78 -1 15 -35 -32 80 33 -36 -82 24 -65 -23 29 38 -31 87 55 -18 -52 -77 -22 -11 54 62 -48
|
| 91 |
+
65 -77 50 16 41 -94 -21 16 85 24 60 86 -78 -13 69 46 55 5 -27 -18 -6 -1 59 -62 -58 -99 -49 -84 89 18
|
| 92 |
+
-21 -15 -55 60 78 98 67 94 58 -5 -36 42 36 73 13 72 -78 -68 41 -37 -33 -46 -80 40 13 -44 -71 -8 15 -77
|
| 93 |
+
16 -93 -42 -10 14 57 -54 -3 -44 -21 30 -93 71 25 -60 -94 93 5 -94 -84 -72 1 -50 -34 23 -15 15 18 72 -29
|
| 94 |
+
-22 -82 -30 -87 -88 -25 46 32 -30 -55 -79 -85 71 -89 -57 -88 21 53 -100 -64 -92 -97 56 -51 -17 -34 -31 6 -68 84
|
| 95 |
+
-53 -51 90 -38 -61 57 -63 67 22 22 70 44 43 97 20 -62 -74 72 83 -32 35 -66 -29 5 -88 55 -94 94 -19 55
|
| 96 |
+
57 51 29 -42 -21 63 -57 7 -48 -87 -60 -55 -77 -53 -1 -85 64 60 53 71 41 59 -61 -73 -12 86 90 10 -60 -38
|
| 97 |
+
2 -9 14 67 -2 70 11 -78 26 -55 -86 -25 99 66 63 64 46 59 66 -37 -78 -70 63 1 -20 2 46 50 34 19
|
| 98 |
+
-87 -40 75 -11 -88 -80 -95 -20 -92 -28 83 24 88 -39 83 -36 -61 56 99 -73 -59 -85 -49 -10 91 12 -79 -18 -15 6
|
| 99 |
+
35 -74 -4 -15 40 -87 81 -22 -12 -46 14 9 98 -35 -2 -12 57 -74 -52 71 70 -70 -61 -47 89 44 33 -100 54 42
|
| 100 |
+
-4 -34 80 -12 -15 -9 -8 -29 89 -55 -33 89 16 -33 -73 -82 98 27 88 59 48 20 -67 -21 -86 11 -50 46 64 -8
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/random-uint-data.txt
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
52 34 59 34 64 20 89 69 26 93 95 32 17 93 77 49 51 60 51 27 60 10 61 2 16 30 41 68 65 0
|
| 2 |
+
43 74 11 37 32 61 72 29 47 21 7 47 68 58 22 33 29 37 14 45 71 1 67 79 69 9 6 6 95 78
|
| 3 |
+
86 20 68 67 43 5 77 70 96 37 79 71 35 30 22 4 56 28 33 50 97 17 85 52 21 5 57 19 35 97
|
| 4 |
+
15 21 99 4 54 39 15 29 68 21 50 76 64 51 79 0 24 5 65 95 90 51 99 82 9 80 61 32 2 38
|
| 5 |
+
46 97 53 96 51 84 18 42 30 52 82 77 72 59 1 67 72 16 14 63 70 94 20 27 38 70 86 95 41 75
|
| 6 |
+
2 35 45 63 92 76 81 60 62 72 90 46 47 33 1 30 54 22 50 85 63 61 22 79 45 53 45 33 8 28
|
| 7 |
+
43 41 14 79 2 77 95 16 74 19 17 78 47 12 68 55 3 2 77 10 35 86 52 33 47 26 98 42 48 86
|
| 8 |
+
18 32 85 4 91 10 69 68 15 42 58 77 88 64 91 43 56 30 92 11 52 23 43 92 65 50 68 8 80 81
|
| 9 |
+
20 57 38 44 62 10 80 25 32 11 70 32 13 50 41 55 44 0 28 83 5 1 34 94 55 52 56 24 76 21
|
| 10 |
+
36 43 59 28 10 59 4 41 64 98 54 66 44 3 37 41 67 10 85 23 58 35 58 34 35 79 46 18 1 51
|
| 11 |
+
72 63 85 51 23 91 3 56 35 72 38 26 91 0 68 98 27 10 12 71 30 1 14 47 47 88 17 68 78 46
|
| 12 |
+
53 47 1 89 95 53 11 45 46 6 91 20 57 35 58 79 60 3 21 45 4 18 59 96 36 12 13 83 52 46
|
| 13 |
+
33 91 82 24 97 28 50 43 65 22 14 44 32 57 33 10 34 77 58 6 27 90 26 77 62 81 87 96 0 32
|
| 14 |
+
96 44 59 3 47 18 0 91 83 68 48 26 67 82 39 18 88 47 80 0 57 40 30 7 57 74 49 37 57 65
|
| 15 |
+
18 44 0 46 47 30 65 79 53 8 26 42 80 76 30 61 82 93 78 25 89 49 55 15 86 63 35 74 41 11
|
| 16 |
+
18 14 40 90 91 79 80 36 33 72 25 56 73 28 65 27 62 17 60 84 23 70 32 26 77 97 47 94 72 1
|
| 17 |
+
82 36 68 10 83 83 40 42 51 55 82 6 37 69 93 82 64 13 54 30 45 36 87 59 1 80 39 93 11 61
|
| 18 |
+
78 34 53 39 64 52 52 22 33 69 71 82 57 37 78 52 62 31 87 68 70 5 85 94 41 75 38 45 84 22
|
| 19 |
+
36 23 51 15 61 76 88 85 36 96 21 60 34 61 72 60 69 81 5 17 16 82 30 61 39 96 40 70 42 71
|
| 20 |
+
45 30 60 50 78 90 36 40 11 85 42 14 61 3 66 53 68 14 41 30 97 74 79 91 64 8 1 53 52 33
|
| 21 |
+
55 24 35 4 49 51 44 70 93 78 25 65 1 29 96 12 93 94 13 65 4 47 84 10 90 12 36 48 21 36
|
| 22 |
+
17 74 61 54 21 83 35 97 47 90 57 11 16 39 95 78 23 40 23 55 17 51 20 73 98 93 50 32 58 4
|
| 23 |
+
84 76 78 33 50 29 11 20 5 93 63 22 91 92 44 85 62 25 63 92 36 26 57 33 8 74 69 64 78 91
|
| 24 |
+
58 34 91 71 37 84 28 90 28 37 97 7 26 44 59 18 58 64 31 83 16 17 50 36 65 81 19 63 66 64
|
| 25 |
+
20 71 1 35 87 5 47 27 6 95 86 75 74 9 94 93 26 5 61 3 97 88 0 57 21 64 46 24 86 12
|
| 26 |
+
23 53 31 39 37 77 29 51 85 10 41 91 67 82 50 91 53 72 75 81 50 63 52 92 83 49 92 50 26 9
|
| 27 |
+
38 43 13 87 11 45 28 16 27 61 70 52 77 9 57 42 73 22 32 95 23 91 93 63 16 44 26 9 93 83
|
| 28 |
+
77 68 21 96 44 45 9 2 14 2 67 90 55 82 67 21 18 64 31 16 2 27 86 42 34 72 22 98 91 33
|
| 29 |
+
89 66 87 76 0 32 81 39 55 76 23 56 51 53 75 79 30 86 1 66 64 14 46 84 92 19 95 47 77 97
|
| 30 |
+
88 79 61 26 66 92 54 22 15 25 26 0 76 27 17 59 48 4 42 61 65 91 0 62 55 79 29 88 10 11
|
| 31 |
+
24 89 91 39 56 36 16 86 41 31 14 35 7 71 77 74 33 11 49 7 96 83 31 63 90 49 96 22 58 86
|
| 32 |
+
45 7 93 44 50 54 83 80 3 36 11 38 14 17 10 84 96 94 26 34 26 75 72 0 41 89 96 47 39 88
|
| 33 |
+
0 95 2 22 68 38 0 3 51 6 13 10 14 49 75 69 25 39 63 67 12 80 37 77 10 90 60 35 84 37
|
| 34 |
+
98 56 99 75 49 66 3 33 65 86 1 79 91 23 69 98 91 73 95 45 64 26 99 75 49 77 71 55 42 18
|
| 35 |
+
80 39 26 94 85 42 91 27 14 57 36 34 10 44 38 77 23 39 54 25 32 5 17 9 66 3 67 94 20 11
|
| 36 |
+
88 80 30 77 72 67 16 75 84 87 60 89 21 94 24 11 63 8 79 89 37 18 6 82 76 70 81 95 67 95
|
| 37 |
+
92 36 55 55 43 18 76 94 30 74 95 38 45 95 54 87 22 57 4 65 15 90 90 38 73 24 67 24 36 25
|
| 38 |
+
98 30 34 68 11 48 42 38 80 23 12 91 77 22 65 2 88 31 70 12 46 63 17 63 27 76 21 71 70 7
|
| 39 |
+
76 29 56 12 41 66 22 96 8 6 7 13 27 10 77 90 2 76 30 24 81 88 19 16 93 13 30 24 98 96
|
| 40 |
+
45 94 89 41 52 14 71 88 80 74 7 85 44 69 65 88 4 15 84 97 86 5 53 15 39 34 9 10 45 20
|
| 41 |
+
95 47 45 96 71 10 36 10 90 49 7 68 14 46 97 89 82 58 69 34 93 77 90 9 27 91 29 27 22 17
|
| 42 |
+
80 6 29 26 34 59 10 55 32 53 18 72 39 40 29 35 52 64 2 64 38 83 16 46 53 20 19 8 10 67
|
| 43 |
+
47 44 79 32 58 82 26 69 0 26 4 73 95 98 61 96 20 38 3 92 6 5 25 24 42 49 15 92 80 16
|
| 44 |
+
74 37 86 84 47 15 56 36 43 59 72 72 74 73 49 54 26 5 40 80 78 48 4 65 31 70 14 91 88 72
|
| 45 |
+
91 45 73 62 83 40 49 3 27 79 80 90 3 3 58 44 7 66 77 42 37 25 20 91 47 63 71 7 72 22
|
| 46 |
+
51 3 36 90 45 84 18 55 75 78 42 62 86 63 65 67 46 75 1 79 2 85 85 60 36 92 34 89 66 99
|
| 47 |
+
36 99 0 63 89 65 54 58 52 28 98 27 67 1 45 71 35 52 55 55 44 23 46 89 83 37 8 2 92 75
|
| 48 |
+
51 13 71 2 9 95 23 60 24 98 86 43 32 16 75 70 92 78 26 84 29 14 35 55 61 89 73 59 76 44
|
| 49 |
+
59 57 28 92 33 50 70 94 89 67 70 38 53 16 35 70 35 92 39 78 88 80 71 1 93 21 87 64 49 84
|
| 50 |
+
29 6 17 45 38 65 41 48 81 69 34 12 2 14 41 71 16 92 69 27 61 74 58 20 75 19 39 66 57 82
|
| 51 |
+
12 8 14 85 97 31 58 31 20 76 6 42 29 95 60 94 15 84 86 69 73 52 73 57 12 66 89 65 60 84
|
| 52 |
+
20 74 96 34 83 41 8 37 22 36 30 25 20 8 58 73 9 75 76 73 84 38 16 24 95 95 68 66 43 19
|
| 53 |
+
33 15 25 80 48 69 63 39 16 45 6 77 14 46 38 15 64 85 49 5 59 28 9 4 23 68 59 26 1 75
|
| 54 |
+
35 45 3 6 34 59 55 51 81 59 59 93 18 41 8 44 88 7 86 4 88 90 24 54 73 62 89 13 44 92
|
| 55 |
+
72 60 68 83 39 32 30 15 98 92 69 94 51 48 9 0 4 1 30 92 40 1 61 82 66 4 39 10 93 87
|
| 56 |
+
12 20 34 72 33 31 67 71 67 47 98 76 53 29 17 17 13 31 43 76 25 37 8 39 9 5 96 41 87 66
|
| 57 |
+
96 30 2 57 57 10 14 17 86 76 35 94 42 54 18 24 19 34 12 42 18 11 83 65 86 38 45 17 60 70
|
| 58 |
+
19 62 71 99 35 60 96 30 44 80 78 15 14 5 32 43 10 26 81 72 41 98 30 87 75 8 53 33 25 95
|
| 59 |
+
22 0 38 57 88 7 47 83 49 41 52 1 14 93 41 3 18 42 15 57 28 74 97 2 18 48 64 25 77 69
|
| 60 |
+
36 95 65 81 44 41 6 74 62 16 72 81 15 72 31 5 22 17 19 6 7 15 82 10 31 93 11 45 41 11
|
| 61 |
+
22 76 14 62 34 65 82 5 57 51 51 5 1 6 17 43 28 31 90 99 48 14 96 49 95 40 87 85 40 51
|
| 62 |
+
95 13 99 46 52 80 4 18 95 94 0 46 10 80 3 34 60 15 86 10 28 59 6 35 14 93 18 8 3 65
|
| 63 |
+
57 37 6 31 45 85 42 34 47 92 48 40 7 17 5 74 67 62 0 74 58 21 23 3 5 24 50 54 99 19
|
| 64 |
+
24 14 10 4 36 33 88 51 40 66 40 56 65 23 43 13 82 62 27 88 89 91 36 37 19 11 50 39 96 68
|
| 65 |
+
82 7 39 80 52 90 57 17 61 15 51 71 82 15 21 44 4 46 75 50 78 18 63 75 98 45 6 16 57 25
|
| 66 |
+
0 26 56 74 62 84 71 42 25 86 68 10 73 0 71 6 15 99 1 51 45 42 5 49 3 35 84 29 15 36
|
| 67 |
+
60 78 76 3 95 73 36 57 35 44 50 42 85 57 18 69 37 42 75 79 15 12 74 72 51 36 79 3 58 71
|
| 68 |
+
69 24 16 96 17 25 21 94 71 78 74 39 7 96 3 12 13 16 7 99 65 72 12 28 75 44 55 8 75 67
|
| 69 |
+
3 13 92 9 92 83 69 91 65 92 29 63 46 1 4 62 29 85 47 93 81 3 15 23 63 50 17 9 13 13
|
| 70 |
+
9 18 46 53 0 86 10 41 87 89 24 25 70 73 8 23 27 76 66 46 58 39 28 1 99 64 59 13 7 68
|
| 71 |
+
72 57 90 50 47 57 34 27 94 39 23 31 74 77 45 74 18 49 96 8 95 50 20 81 73 55 72 2 32 15
|
| 72 |
+
87 77 74 5 99 86 5 65 97 39 17 74 48 87 20 66 28 2 18 58 49 22 79 23 36 30 64 20 71 32
|
| 73 |
+
35 43 66 96 63 77 18 90 47 86 94 19 88 79 23 12 38 4 56 42 36 2 77 1 3 17 64 52 31 24
|
| 74 |
+
80 2 4 39 61 60 74 83 28 28 61 10 71 82 44 29 55 30 1 58 81 79 34 41 85 82 84 55 22 12
|
| 75 |
+
76 77 58 92 90 0 54 28 77 68 58 12 1 81 37 28 19 60 71 59 25 83 8 49 52 11 28 65 59 70
|
| 76 |
+
14 1 92 90 5 48 28 78 1 42 54 43 60 83 72 19 28 33 12 52 18 15 56 95 39 33 37 70 53 23
|
| 77 |
+
53 76 26 31 18 81 83 79 25 1 82 43 50 24 63 49 5 23 66 37 80 41 63 77 2 28 15 21 32 93
|
| 78 |
+
80 41 81 7 37 95 19 42 57 30 12 25 29 34 41 45 87 8 20 95 63 16 99 55 16 61 16 36 81 25
|
| 79 |
+
32 30 2 81 23 25 88 30 37 76 52 77 79 58 21 58 10 0 13 32 72 80 3 75 75 25 21 9 79 18
|
| 80 |
+
26 13 36 63 43 2 50 41 65 18 88 44 82 75 73 24 1 30 54 68 15 18 22 50 41 99 27 96 51 53
|
| 81 |
+
22 4 76 11 85 88 28 75 1 2 92 66 63 3 58 43 53 5 1 24 99 90 87 87 41 1 85 37 98 92
|
| 82 |
+
16 39 13 88 60 55 35 11 34 23 23 85 79 41 79 87 65 78 47 83 88 78 35 84 30 61 37 58 25 55
|
| 83 |
+
27 33 15 76 82 79 73 92 93 78 18 38 22 96 63 92 41 9 50 96 14 55 8 60 15 61 97 56 43 22
|
| 84 |
+
42 34 94 11 35 70 50 49 36 34 59 14 87 84 88 83 4 69 29 99 35 24 2 18 97 97 74 88 91 49
|
| 85 |
+
33 25 71 12 60 2 48 22 81 33 27 95 54 25 53 14 20 43 26 96 98 37 64 27 72 33 78 45 22 61
|
| 86 |
+
61 21 91 38 92 47 26 90 78 96 58 41 21 72 81 61 55 9 55 60 28 25 25 74 73 81 64 16 49 39
|
| 87 |
+
90 89 12 93 91 23 82 36 63 58 73 81 49 32 60 39 4 84 73 16 18 26 58 85 46 28 82 91 72 7
|
| 88 |
+
79 41 28 76 33 70 47 6 18 64 40 54 45 61 28 63 87 83 38 9 65 68 62 45 80 63 89 29 20 40
|
| 89 |
+
20 59 58 23 61 79 35 19 78 2 26 48 90 34 69 31 31 42 92 33 18 74 28 47 45 52 36 89 19 40
|
| 90 |
+
58 13 72 24 31 26 73 72 84 29 85 99 20 32 54 92 8 80 86 58 23 80 59 21 76 75 90 76 92 57
|
| 91 |
+
74 53 80 51 8 88 84 63 82 99 97 77 38 9 51 61 37 20 68 47 65 21 53 82 85 96 62 65 35 4
|
| 92 |
+
71 82 14 18 88 79 38 76 66 27 10 10 62 54 80 21 6 57 83 33 52 10 97 37 6 38 12 51 0 84
|
| 93 |
+
95 30 75 92 84 30 55 57 32 44 53 24 77 81 34 84 69 85 91 33 50 72 62 79 62 12 59 75 99 81
|
| 94 |
+
38 42 47 1 11 34 27 77 70 85 89 84 79 15 14 54 78 93 72 68 63 39 98 72 55 32 93 0 13 21
|
| 95 |
+
3 15 10 15 3 31 84 89 53 5 60 41 66 77 45 12 68 68 50 68 99 64 46 54 30 56 2 90 99 78
|
| 96 |
+
66 10 27 89 42 16 9 98 16 2 68 51 0 22 73 60 69 96 37 69 30 36 20 21 51 26 65 13 74 86
|
| 97 |
+
94 58 34 97 77 88 90 75 47 30 6 36 89 66 48 9 20 6 52 45 0 37 99 46 11 53 53 72 94 40
|
| 98 |
+
5 71 50 96 89 71 80 43 27 95 49 9 74 28 62 65 64 97 2 55 58 11 69 0 31 22 73 20 66 11
|
| 99 |
+
63 39 84 62 64 5 56 92 26 86 19 20 56 85 42 48 56 51 54 29 26 95 72 38 70 61 16 54 57 19
|
| 100 |
+
76 97 40 99 73 68 98 92 97 62 73 1 29 72 18 70 90 4 98 95 70 36 65 45 86 36 88 38 64 54
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/data/selfdual-4d-polytope.txt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# The facets of a self-dual 4-dim regular polytope
|
| 2 |
+
# with 24 octahedron facets. Taken from cddlib.
|
| 3 |
+
# Format b + Ax >= 0
|
| 4 |
+
1 1 1 1 1
|
| 5 |
+
1 1 1 1 -1
|
| 6 |
+
1 1 1 -1 1
|
| 7 |
+
1 1 1 -1 -1
|
| 8 |
+
1 1 -1 1 1
|
| 9 |
+
1 1 -1 1 -1
|
| 10 |
+
1 1 -1 -1 1
|
| 11 |
+
1 1 -1 -1 -1
|
| 12 |
+
1 -1 1 1 1
|
| 13 |
+
1 -1 1 1 -1
|
| 14 |
+
1 -1 1 -1 1
|
| 15 |
+
1 -1 1 -1 -1
|
| 16 |
+
1 -1 -1 1 1
|
| 17 |
+
1 -1 -1 1 -1
|
| 18 |
+
1 -1 -1 -1 1
|
| 19 |
+
1 -1 -1 -1 -1
|
| 20 |
+
1 2 0 0 0
|
| 21 |
+
1 0 2 0 0
|
| 22 |
+
1 0 0 2 0
|
| 23 |
+
1 0 0 0 2
|
| 24 |
+
1 -2 0 0 0
|
| 25 |
+
1 0 -2 0 0
|
| 26 |
+
1 0 0 -2 0
|
| 27 |
+
1 0 0 0 -2
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test__plotutils.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pytest
|
| 2 |
+
import numpy as np
|
| 3 |
+
from numpy.testing import assert_, assert_array_equal, assert_allclose
|
| 4 |
+
|
| 5 |
+
try:
|
| 6 |
+
import matplotlib
|
| 7 |
+
matplotlib.rcParams['backend'] = 'Agg'
|
| 8 |
+
import matplotlib.pyplot as plt
|
| 9 |
+
has_matplotlib = True
|
| 10 |
+
except Exception:
|
| 11 |
+
has_matplotlib = False
|
| 12 |
+
|
| 13 |
+
from scipy.spatial import \
|
| 14 |
+
delaunay_plot_2d, voronoi_plot_2d, convex_hull_plot_2d, \
|
| 15 |
+
Delaunay, Voronoi, ConvexHull
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@pytest.mark.skipif(not has_matplotlib, reason="Matplotlib not available")
|
| 19 |
+
class TestPlotting:
|
| 20 |
+
points = [(0,0), (0,1), (1,0), (1,1)]
|
| 21 |
+
|
| 22 |
+
def test_delaunay(self):
|
| 23 |
+
# Smoke test
|
| 24 |
+
fig = plt.figure()
|
| 25 |
+
obj = Delaunay(self.points)
|
| 26 |
+
s_before = obj.simplices.copy()
|
| 27 |
+
r = delaunay_plot_2d(obj, ax=fig.gca())
|
| 28 |
+
assert_array_equal(obj.simplices, s_before) # shouldn't modify
|
| 29 |
+
assert_(r is fig)
|
| 30 |
+
delaunay_plot_2d(obj, ax=fig.gca())
|
| 31 |
+
|
| 32 |
+
def test_voronoi(self):
|
| 33 |
+
# Smoke test
|
| 34 |
+
fig = plt.figure()
|
| 35 |
+
obj = Voronoi(self.points)
|
| 36 |
+
r = voronoi_plot_2d(obj, ax=fig.gca())
|
| 37 |
+
assert_(r is fig)
|
| 38 |
+
voronoi_plot_2d(obj)
|
| 39 |
+
voronoi_plot_2d(obj, show_vertices=False)
|
| 40 |
+
|
| 41 |
+
def test_convex_hull(self):
|
| 42 |
+
# Smoke test
|
| 43 |
+
fig = plt.figure()
|
| 44 |
+
tri = ConvexHull(self.points)
|
| 45 |
+
r = convex_hull_plot_2d(tri, ax=fig.gca())
|
| 46 |
+
assert_(r is fig)
|
| 47 |
+
convex_hull_plot_2d(tri)
|
| 48 |
+
|
| 49 |
+
def test_gh_19653(self):
|
| 50 |
+
# aspect ratio sensitivity of voronoi_plot_2d
|
| 51 |
+
# infinite Voronoi edges
|
| 52 |
+
points = np.array([[245.059986986012, 10.971011721360075],
|
| 53 |
+
[320.49044143557785, 10.970258360366753],
|
| 54 |
+
[239.79023081978914, 13.108487516946218],
|
| 55 |
+
[263.38325791238833, 12.93241352743668],
|
| 56 |
+
[219.53334398353175, 13.346107628161008]])
|
| 57 |
+
vor = Voronoi(points)
|
| 58 |
+
fig = voronoi_plot_2d(vor)
|
| 59 |
+
ax = fig.gca()
|
| 60 |
+
infinite_segments = ax.collections[1].get_segments()
|
| 61 |
+
expected_segments = np.array([[[282.77256, -254.76904],
|
| 62 |
+
[282.729714, -4544.744698]],
|
| 63 |
+
[[282.77256014, -254.76904029],
|
| 64 |
+
[430.08561382, 4032.67658742]],
|
| 65 |
+
[[229.26733285, -20.39957514],
|
| 66 |
+
[-168.17167404, -4291.92545966]],
|
| 67 |
+
[[289.93433364, 5151.40412217],
|
| 68 |
+
[330.40553385, 9441.18887532]]])
|
| 69 |
+
assert_allclose(infinite_segments, expected_segments)
|
| 70 |
+
|
| 71 |
+
def test_gh_19653_smaller_aspect(self):
|
| 72 |
+
# reasonable behavior for less extreme aspect
|
| 73 |
+
# ratio
|
| 74 |
+
points = np.array([[24.059986986012, 10.971011721360075],
|
| 75 |
+
[32.49044143557785, 10.970258360366753],
|
| 76 |
+
[23.79023081978914, 13.108487516946218],
|
| 77 |
+
[26.38325791238833, 12.93241352743668],
|
| 78 |
+
[21.53334398353175, 13.346107628161008]])
|
| 79 |
+
vor = Voronoi(points)
|
| 80 |
+
fig = voronoi_plot_2d(vor)
|
| 81 |
+
ax = fig.gca()
|
| 82 |
+
infinite_segments = ax.collections[1].get_segments()
|
| 83 |
+
expected_segments = np.array([[[28.274979, 8.335027],
|
| 84 |
+
[28.270463, -42.19763338]],
|
| 85 |
+
[[28.27497869, 8.33502697],
|
| 86 |
+
[43.73223829, 56.44555501]],
|
| 87 |
+
[[22.51805823, 11.8621754],
|
| 88 |
+
[-12.09266506, -24.95694485]],
|
| 89 |
+
[[29.53092448, 78.46952378],
|
| 90 |
+
[33.82572726, 128.81934455]]])
|
| 91 |
+
assert_allclose(infinite_segments, expected_segments)
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test__procrustes.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from numpy.testing import assert_allclose, assert_equal, assert_almost_equal
|
| 3 |
+
from pytest import raises as assert_raises
|
| 4 |
+
|
| 5 |
+
from scipy.spatial import procrustes
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class TestProcrustes:
|
| 9 |
+
def setup_method(self):
|
| 10 |
+
"""creates inputs"""
|
| 11 |
+
# an L
|
| 12 |
+
self.data1 = np.array([[1, 3], [1, 2], [1, 1], [2, 1]], 'd')
|
| 13 |
+
|
| 14 |
+
# a larger, shifted, mirrored L
|
| 15 |
+
self.data2 = np.array([[4, -2], [4, -4], [4, -6], [2, -6]], 'd')
|
| 16 |
+
|
| 17 |
+
# an L shifted up 1, right 1, and with point 4 shifted an extra .5
|
| 18 |
+
# to the right
|
| 19 |
+
# pointwise distance disparity with data1: 3*(2) + (1 + 1.5^2)
|
| 20 |
+
self.data3 = np.array([[2, 4], [2, 3], [2, 2], [3, 2.5]], 'd')
|
| 21 |
+
|
| 22 |
+
# data4, data5 are standardized (trace(A*A') = 1).
|
| 23 |
+
# procrustes should return an identical copy if they are used
|
| 24 |
+
# as the first matrix argument.
|
| 25 |
+
shiftangle = np.pi / 8
|
| 26 |
+
self.data4 = np.array([[1, 0], [0, 1], [-1, 0],
|
| 27 |
+
[0, -1]], 'd') / np.sqrt(4)
|
| 28 |
+
self.data5 = np.array([[np.cos(shiftangle), np.sin(shiftangle)],
|
| 29 |
+
[np.cos(np.pi / 2 - shiftangle),
|
| 30 |
+
np.sin(np.pi / 2 - shiftangle)],
|
| 31 |
+
[-np.cos(shiftangle),
|
| 32 |
+
-np.sin(shiftangle)],
|
| 33 |
+
[-np.cos(np.pi / 2 - shiftangle),
|
| 34 |
+
-np.sin(np.pi / 2 - shiftangle)]],
|
| 35 |
+
'd') / np.sqrt(4)
|
| 36 |
+
|
| 37 |
+
def test_procrustes(self):
|
| 38 |
+
# tests procrustes' ability to match two matrices.
|
| 39 |
+
#
|
| 40 |
+
# the second matrix is a rotated, shifted, scaled, and mirrored version
|
| 41 |
+
# of the first, in two dimensions only
|
| 42 |
+
#
|
| 43 |
+
# can shift, mirror, and scale an 'L'?
|
| 44 |
+
a, b, disparity = procrustes(self.data1, self.data2)
|
| 45 |
+
assert_allclose(b, a)
|
| 46 |
+
assert_almost_equal(disparity, 0.)
|
| 47 |
+
|
| 48 |
+
# if first mtx is standardized, leaves first mtx unchanged?
|
| 49 |
+
m4, m5, disp45 = procrustes(self.data4, self.data5)
|
| 50 |
+
assert_equal(m4, self.data4)
|
| 51 |
+
|
| 52 |
+
# at worst, data3 is an 'L' with one point off by .5
|
| 53 |
+
m1, m3, disp13 = procrustes(self.data1, self.data3)
|
| 54 |
+
#assert_(disp13 < 0.5 ** 2)
|
| 55 |
+
|
| 56 |
+
def test_procrustes2(self):
|
| 57 |
+
# procrustes disparity should not depend on order of matrices
|
| 58 |
+
m1, m3, disp13 = procrustes(self.data1, self.data3)
|
| 59 |
+
m3_2, m1_2, disp31 = procrustes(self.data3, self.data1)
|
| 60 |
+
assert_almost_equal(disp13, disp31)
|
| 61 |
+
|
| 62 |
+
# try with 3d, 8 pts per
|
| 63 |
+
rand1 = np.array([[2.61955202, 0.30522265, 0.55515826],
|
| 64 |
+
[0.41124708, -0.03966978, -0.31854548],
|
| 65 |
+
[0.91910318, 1.39451809, -0.15295084],
|
| 66 |
+
[2.00452023, 0.50150048, 0.29485268],
|
| 67 |
+
[0.09453595, 0.67528885, 0.03283872],
|
| 68 |
+
[0.07015232, 2.18892599, -1.67266852],
|
| 69 |
+
[0.65029688, 1.60551637, 0.80013549],
|
| 70 |
+
[-0.6607528, 0.53644208, 0.17033891]])
|
| 71 |
+
|
| 72 |
+
rand3 = np.array([[0.0809969, 0.09731461, -0.173442],
|
| 73 |
+
[-1.84888465, -0.92589646, -1.29335743],
|
| 74 |
+
[0.67031855, -1.35957463, 0.41938621],
|
| 75 |
+
[0.73967209, -0.20230757, 0.52418027],
|
| 76 |
+
[0.17752796, 0.09065607, 0.29827466],
|
| 77 |
+
[0.47999368, -0.88455717, -0.57547934],
|
| 78 |
+
[-0.11486344, -0.12608506, -0.3395779],
|
| 79 |
+
[-0.86106154, -0.28687488, 0.9644429]])
|
| 80 |
+
res1, res3, disp13 = procrustes(rand1, rand3)
|
| 81 |
+
res3_2, res1_2, disp31 = procrustes(rand3, rand1)
|
| 82 |
+
assert_almost_equal(disp13, disp31)
|
| 83 |
+
|
| 84 |
+
def test_procrustes_shape_mismatch(self):
|
| 85 |
+
assert_raises(ValueError, procrustes,
|
| 86 |
+
np.array([[1, 2], [3, 4]]),
|
| 87 |
+
np.array([[5, 6, 7], [8, 9, 10]]))
|
| 88 |
+
|
| 89 |
+
def test_procrustes_empty_rows_or_cols(self):
|
| 90 |
+
empty = np.array([[]])
|
| 91 |
+
assert_raises(ValueError, procrustes, empty, empty)
|
| 92 |
+
|
| 93 |
+
def test_procrustes_no_variation(self):
|
| 94 |
+
assert_raises(ValueError, procrustes,
|
| 95 |
+
np.array([[42, 42], [42, 42]]),
|
| 96 |
+
np.array([[45, 45], [45, 45]]))
|
| 97 |
+
|
| 98 |
+
def test_procrustes_bad_number_of_dimensions(self):
|
| 99 |
+
# fewer dimensions in one dataset
|
| 100 |
+
assert_raises(ValueError, procrustes,
|
| 101 |
+
np.array([1, 1, 2, 3, 5, 8]),
|
| 102 |
+
np.array([[1, 2], [3, 4]]))
|
| 103 |
+
|
| 104 |
+
# fewer dimensions in both datasets
|
| 105 |
+
assert_raises(ValueError, procrustes,
|
| 106 |
+
np.array([1, 1, 2, 3, 5, 8]),
|
| 107 |
+
np.array([1, 1, 2, 3, 5, 8]))
|
| 108 |
+
|
| 109 |
+
# zero dimensions
|
| 110 |
+
assert_raises(ValueError, procrustes, np.array(7), np.array(11))
|
| 111 |
+
|
| 112 |
+
# extra dimensions
|
| 113 |
+
assert_raises(ValueError, procrustes,
|
| 114 |
+
np.array([[[11], [7]]]),
|
| 115 |
+
np.array([[[5, 13]]]))
|
| 116 |
+
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_distance.py
ADDED
|
@@ -0,0 +1,2287 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Author: Damian Eads
|
| 3 |
+
# Date: April 17, 2008
|
| 4 |
+
#
|
| 5 |
+
# Copyright (C) 2008 Damian Eads
|
| 6 |
+
#
|
| 7 |
+
# Redistribution and use in source and binary forms, with or without
|
| 8 |
+
# modification, are permitted provided that the following conditions
|
| 9 |
+
# are met:
|
| 10 |
+
#
|
| 11 |
+
# 1. Redistributions of source code must retain the above copyright
|
| 12 |
+
# notice, this list of conditions and the following disclaimer.
|
| 13 |
+
#
|
| 14 |
+
# 2. Redistributions in binary form must reproduce the above
|
| 15 |
+
# copyright notice, this list of conditions and the following
|
| 16 |
+
# disclaimer in the documentation and/or other materials provided
|
| 17 |
+
# with the distribution.
|
| 18 |
+
#
|
| 19 |
+
# 3. The name of the author may not be used to endorse or promote
|
| 20 |
+
# products derived from this software without specific prior
|
| 21 |
+
# written permission.
|
| 22 |
+
#
|
| 23 |
+
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
| 24 |
+
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
| 25 |
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
| 26 |
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
| 27 |
+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 28 |
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
| 29 |
+
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
| 30 |
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
| 31 |
+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 32 |
+
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 33 |
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 34 |
+
|
| 35 |
+
from functools import wraps, partial
|
| 36 |
+
import os.path
|
| 37 |
+
import sys
|
| 38 |
+
import sysconfig
|
| 39 |
+
import warnings
|
| 40 |
+
import weakref
|
| 41 |
+
|
| 42 |
+
import numpy as np
|
| 43 |
+
from numpy.linalg import norm
|
| 44 |
+
from numpy.testing import (verbose, assert_,
|
| 45 |
+
assert_array_equal, assert_equal,
|
| 46 |
+
assert_almost_equal, assert_allclose,
|
| 47 |
+
break_cycles, IS_PYPY)
|
| 48 |
+
import pytest
|
| 49 |
+
|
| 50 |
+
import scipy.spatial.distance
|
| 51 |
+
|
| 52 |
+
from scipy.spatial.distance import (
|
| 53 |
+
squareform, pdist, cdist, num_obs_y, num_obs_dm, is_valid_dm, is_valid_y,
|
| 54 |
+
_validate_vector, _METRICS_NAMES)
|
| 55 |
+
|
| 56 |
+
# these were missing: chebyshev cityblock
|
| 57 |
+
# jensenshannon and seuclidean are referenced by string name.
|
| 58 |
+
from scipy.spatial.distance import (braycurtis, canberra, chebyshev, cityblock,
|
| 59 |
+
correlation, cosine, dice, euclidean,
|
| 60 |
+
hamming, jaccard, jensenshannon, mahalanobis,
|
| 61 |
+
minkowski, rogerstanimoto,
|
| 62 |
+
russellrao, seuclidean, # noqa: F401
|
| 63 |
+
sokalsneath, sqeuclidean, yule)
|
| 64 |
+
from scipy._lib._util import np_long, np_ulong
|
| 65 |
+
from scipy.conftest import skip_xp_invalid_arg
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@pytest.fixture(params=_METRICS_NAMES, scope="session")
|
| 69 |
+
def metric(request):
|
| 70 |
+
"""
|
| 71 |
+
Fixture for all metrics in scipy.spatial.distance
|
| 72 |
+
"""
|
| 73 |
+
return request.param
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
_filenames = [
|
| 77 |
+
"cdist-X1.txt",
|
| 78 |
+
"cdist-X2.txt",
|
| 79 |
+
"iris.txt",
|
| 80 |
+
"pdist-boolean-inp.txt",
|
| 81 |
+
"pdist-chebyshev-ml-iris.txt",
|
| 82 |
+
"pdist-chebyshev-ml.txt",
|
| 83 |
+
"pdist-cityblock-ml-iris.txt",
|
| 84 |
+
"pdist-cityblock-ml.txt",
|
| 85 |
+
"pdist-correlation-ml-iris.txt",
|
| 86 |
+
"pdist-correlation-ml.txt",
|
| 87 |
+
"pdist-cosine-ml-iris.txt",
|
| 88 |
+
"pdist-cosine-ml.txt",
|
| 89 |
+
"pdist-double-inp.txt",
|
| 90 |
+
"pdist-euclidean-ml-iris.txt",
|
| 91 |
+
"pdist-euclidean-ml.txt",
|
| 92 |
+
"pdist-hamming-ml.txt",
|
| 93 |
+
"pdist-jaccard-ml.txt",
|
| 94 |
+
"pdist-jensenshannon-ml-iris.txt",
|
| 95 |
+
"pdist-jensenshannon-ml.txt",
|
| 96 |
+
"pdist-minkowski-3.2-ml-iris.txt",
|
| 97 |
+
"pdist-minkowski-3.2-ml.txt",
|
| 98 |
+
"pdist-minkowski-5.8-ml-iris.txt",
|
| 99 |
+
"pdist-seuclidean-ml-iris.txt",
|
| 100 |
+
"pdist-seuclidean-ml.txt",
|
| 101 |
+
"pdist-spearman-ml.txt",
|
| 102 |
+
"random-bool-data.txt",
|
| 103 |
+
"random-double-data.txt",
|
| 104 |
+
"random-int-data.txt",
|
| 105 |
+
"random-uint-data.txt",
|
| 106 |
+
]
|
| 107 |
+
|
| 108 |
+
_tdist = np.array([[0, 662, 877, 255, 412, 996],
|
| 109 |
+
[662, 0, 295, 468, 268, 400],
|
| 110 |
+
[877, 295, 0, 754, 564, 138],
|
| 111 |
+
[255, 468, 754, 0, 219, 869],
|
| 112 |
+
[412, 268, 564, 219, 0, 669],
|
| 113 |
+
[996, 400, 138, 869, 669, 0]], dtype='double')
|
| 114 |
+
|
| 115 |
+
_ytdist = squareform(_tdist)
|
| 116 |
+
|
| 117 |
+
# A hashmap of expected output arrays for the tests. These arrays
|
| 118 |
+
# come from a list of text files, which are read prior to testing.
|
| 119 |
+
# Each test loads inputs and outputs from this dictionary.
|
| 120 |
+
eo = {}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def load_testing_files():
|
| 124 |
+
for fn in _filenames:
|
| 125 |
+
name = fn.replace(".txt", "").replace("-ml", "")
|
| 126 |
+
fqfn = os.path.join(os.path.dirname(__file__), 'data', fn)
|
| 127 |
+
fp = open(fqfn)
|
| 128 |
+
eo[name] = np.loadtxt(fp)
|
| 129 |
+
fp.close()
|
| 130 |
+
eo['pdist-boolean-inp'] = np.bool_(eo['pdist-boolean-inp'])
|
| 131 |
+
eo['random-bool-data'] = np.bool_(eo['random-bool-data'])
|
| 132 |
+
eo['random-float32-data'] = np.float32(eo['random-double-data'])
|
| 133 |
+
eo['random-int-data'] = np_long(eo['random-int-data'])
|
| 134 |
+
eo['random-uint-data'] = np_ulong(eo['random-uint-data'])
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
load_testing_files()
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def _is_32bit():
|
| 141 |
+
return np.intp(0).itemsize < 8
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def _chk_asarrays(arrays, axis=None):
|
| 145 |
+
arrays = [np.asanyarray(a) for a in arrays]
|
| 146 |
+
if axis is None:
|
| 147 |
+
# np < 1.10 ravel removes subclass from arrays
|
| 148 |
+
arrays = [np.ravel(a) if a.ndim != 1 else a
|
| 149 |
+
for a in arrays]
|
| 150 |
+
axis = 0
|
| 151 |
+
arrays = tuple(np.atleast_1d(a) for a in arrays)
|
| 152 |
+
if axis < 0:
|
| 153 |
+
if not all(a.ndim == arrays[0].ndim for a in arrays):
|
| 154 |
+
raise ValueError("array ndim must be the same for neg axis")
|
| 155 |
+
axis = range(arrays[0].ndim)[axis]
|
| 156 |
+
return arrays + (axis,)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _chk_weights(arrays, weights=None, axis=None,
|
| 160 |
+
force_weights=False, simplify_weights=True,
|
| 161 |
+
pos_only=False, neg_check=False,
|
| 162 |
+
nan_screen=False, mask_screen=False,
|
| 163 |
+
ddof=None):
|
| 164 |
+
chked = _chk_asarrays(arrays, axis=axis)
|
| 165 |
+
arrays, axis = chked[:-1], chked[-1]
|
| 166 |
+
|
| 167 |
+
simplify_weights = simplify_weights and not force_weights
|
| 168 |
+
if not force_weights and mask_screen:
|
| 169 |
+
force_weights = any(np.ma.getmask(a) is not np.ma.nomask for a in arrays)
|
| 170 |
+
|
| 171 |
+
if nan_screen:
|
| 172 |
+
has_nans = [np.isnan(np.sum(a)) for a in arrays]
|
| 173 |
+
if any(has_nans):
|
| 174 |
+
mask_screen = True
|
| 175 |
+
force_weights = True
|
| 176 |
+
arrays = tuple(np.ma.masked_invalid(a) if has_nan else a
|
| 177 |
+
for a, has_nan in zip(arrays, has_nans))
|
| 178 |
+
|
| 179 |
+
if weights is not None:
|
| 180 |
+
weights = np.asanyarray(weights)
|
| 181 |
+
elif force_weights:
|
| 182 |
+
weights = np.ones(arrays[0].shape[axis])
|
| 183 |
+
else:
|
| 184 |
+
return arrays + (weights, axis)
|
| 185 |
+
|
| 186 |
+
if ddof:
|
| 187 |
+
weights = _freq_weights(weights)
|
| 188 |
+
|
| 189 |
+
if mask_screen:
|
| 190 |
+
weights = _weight_masked(arrays, weights, axis)
|
| 191 |
+
|
| 192 |
+
if not all(weights.shape == (a.shape[axis],) for a in arrays):
|
| 193 |
+
raise ValueError("weights shape must match arrays along axis")
|
| 194 |
+
if neg_check and (weights < 0).any():
|
| 195 |
+
raise ValueError("weights cannot be negative")
|
| 196 |
+
|
| 197 |
+
if pos_only:
|
| 198 |
+
pos_weights = np.nonzero(weights > 0)[0]
|
| 199 |
+
if pos_weights.size < weights.size:
|
| 200 |
+
arrays = tuple(np.take(a, pos_weights, axis=axis) for a in arrays)
|
| 201 |
+
weights = weights[pos_weights]
|
| 202 |
+
if simplify_weights and (weights == 1).all():
|
| 203 |
+
weights = None
|
| 204 |
+
return arrays + (weights, axis)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
def _freq_weights(weights):
|
| 208 |
+
if weights is None:
|
| 209 |
+
return weights
|
| 210 |
+
int_weights = weights.astype(int)
|
| 211 |
+
if (weights != int_weights).any():
|
| 212 |
+
raise ValueError(f"frequency (integer count-type) weights required {weights}")
|
| 213 |
+
return int_weights
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def _weight_masked(arrays, weights, axis):
|
| 217 |
+
if axis is None:
|
| 218 |
+
axis = 0
|
| 219 |
+
weights = np.asanyarray(weights)
|
| 220 |
+
for a in arrays:
|
| 221 |
+
axis_mask = np.ma.getmask(a)
|
| 222 |
+
if axis_mask is np.ma.nomask:
|
| 223 |
+
continue
|
| 224 |
+
if a.ndim > 1:
|
| 225 |
+
not_axes = tuple(i for i in range(a.ndim) if i != axis)
|
| 226 |
+
axis_mask = axis_mask.any(axis=not_axes)
|
| 227 |
+
weights *= 1 - axis_mask.astype(int)
|
| 228 |
+
return weights
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def _rand_split(arrays, weights, axis, split_per, seed=None):
|
| 232 |
+
# Coerce `arrays` to float64 if integer, to avoid nan-to-integer issues
|
| 233 |
+
arrays = [arr.astype(np.float64) if np.issubdtype(arr.dtype, np.integer)
|
| 234 |
+
else arr for arr in arrays]
|
| 235 |
+
|
| 236 |
+
# inverse operation for stats.collapse_weights
|
| 237 |
+
weights = np.array(weights, dtype=np.float64) # modified inplace; need a copy
|
| 238 |
+
seeded_rand = np.random.RandomState(seed)
|
| 239 |
+
|
| 240 |
+
def mytake(a, ix, axis):
|
| 241 |
+
record = np.asanyarray(np.take(a, ix, axis=axis))
|
| 242 |
+
return record.reshape([a.shape[i] if i != axis else 1
|
| 243 |
+
for i in range(a.ndim)])
|
| 244 |
+
|
| 245 |
+
n_obs = arrays[0].shape[axis]
|
| 246 |
+
assert all(a.shape[axis] == n_obs for a in arrays), \
|
| 247 |
+
"data must be aligned on sample axis"
|
| 248 |
+
for i in range(int(split_per) * n_obs):
|
| 249 |
+
split_ix = seeded_rand.randint(n_obs + i)
|
| 250 |
+
prev_w = weights[split_ix]
|
| 251 |
+
q = seeded_rand.rand()
|
| 252 |
+
weights[split_ix] = q * prev_w
|
| 253 |
+
weights = np.append(weights, (1. - q) * prev_w)
|
| 254 |
+
arrays = [np.append(a, mytake(a, split_ix, axis=axis),
|
| 255 |
+
axis=axis) for a in arrays]
|
| 256 |
+
return arrays, weights
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
assert_allclose_forgiving = partial(assert_allclose, atol=1e-5)
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def _rough_check(a, b, compare_assert=assert_allclose_forgiving,
|
| 263 |
+
key=lambda x: x, w=None):
|
| 264 |
+
check_a = key(a)
|
| 265 |
+
check_b = key(b)
|
| 266 |
+
try:
|
| 267 |
+
if np.array(check_a != check_b).any(): # try strict equality for string types
|
| 268 |
+
compare_assert(check_a, check_b)
|
| 269 |
+
except AttributeError: # masked array
|
| 270 |
+
compare_assert(check_a, check_b)
|
| 271 |
+
except (TypeError, ValueError): # nested data structure
|
| 272 |
+
for a_i, b_i in zip(check_a, check_b):
|
| 273 |
+
_rough_check(a_i, b_i, compare_assert=compare_assert)
|
| 274 |
+
|
| 275 |
+
# diff from test_stats:
|
| 276 |
+
# n_args=2, weight_arg='w', default_axis=None
|
| 277 |
+
# ma_safe = False, nan_safe = False
|
| 278 |
+
def _weight_checked(fn, n_args=2, default_axis=None, key=lambda x: x, weight_arg='w',
|
| 279 |
+
squeeze=True, silent=False,
|
| 280 |
+
ones_test=True, const_test=True, dup_test=True,
|
| 281 |
+
split_test=True, dud_test=True, ma_safe=False, ma_very_safe=False,
|
| 282 |
+
nan_safe=False, split_per=1.0, seed=0,
|
| 283 |
+
compare_assert=assert_allclose_forgiving):
|
| 284 |
+
"""runs fn on its arguments 2 or 3 ways, checks that the results are the same,
|
| 285 |
+
then returns the same thing it would have returned before"""
|
| 286 |
+
@wraps(fn)
|
| 287 |
+
def wrapped(*args, **kwargs):
|
| 288 |
+
result = fn(*args, **kwargs)
|
| 289 |
+
|
| 290 |
+
arrays = args[:n_args]
|
| 291 |
+
rest = args[n_args:]
|
| 292 |
+
weights = kwargs.get(weight_arg, None)
|
| 293 |
+
axis = kwargs.get('axis', default_axis)
|
| 294 |
+
|
| 295 |
+
chked = _chk_weights(arrays, weights=weights, axis=axis,
|
| 296 |
+
force_weights=True, mask_screen=True)
|
| 297 |
+
arrays, weights, axis = chked[:-2], chked[-2], chked[-1]
|
| 298 |
+
if squeeze:
|
| 299 |
+
arrays = [np.atleast_1d(a.squeeze()) for a in arrays]
|
| 300 |
+
|
| 301 |
+
try:
|
| 302 |
+
# WEIGHTS CHECK 1: EQUAL WEIGHTED OBSERVATIONS
|
| 303 |
+
args = tuple(arrays) + rest
|
| 304 |
+
if ones_test:
|
| 305 |
+
kwargs[weight_arg] = weights
|
| 306 |
+
_rough_check(result, fn(*args, **kwargs), key=key)
|
| 307 |
+
if const_test:
|
| 308 |
+
kwargs[weight_arg] = weights * 101.0
|
| 309 |
+
_rough_check(result, fn(*args, **kwargs), key=key)
|
| 310 |
+
kwargs[weight_arg] = weights * 0.101
|
| 311 |
+
try:
|
| 312 |
+
_rough_check(result, fn(*args, **kwargs), key=key)
|
| 313 |
+
except Exception as e:
|
| 314 |
+
raise type(e)((e, arrays, weights)) from e
|
| 315 |
+
|
| 316 |
+
# WEIGHTS CHECK 2: ADDL 0-WEIGHTED OBS
|
| 317 |
+
if dud_test:
|
| 318 |
+
# add randomly resampled rows, weighted at 0
|
| 319 |
+
dud_arrays, dud_weights = _rand_split(arrays, weights, axis,
|
| 320 |
+
split_per=split_per, seed=seed)
|
| 321 |
+
dud_weights[:weights.size] = weights # not exactly 1 because of masked arrays # noqa: E501
|
| 322 |
+
dud_weights[weights.size:] = 0
|
| 323 |
+
dud_args = tuple(dud_arrays) + rest
|
| 324 |
+
kwargs[weight_arg] = dud_weights
|
| 325 |
+
_rough_check(result, fn(*dud_args, **kwargs), key=key)
|
| 326 |
+
# increase the value of those 0-weighted rows
|
| 327 |
+
for a in dud_arrays:
|
| 328 |
+
indexer = [slice(None)] * a.ndim
|
| 329 |
+
indexer[axis] = slice(weights.size, None)
|
| 330 |
+
indexer = tuple(indexer)
|
| 331 |
+
a[indexer] = a[indexer] * 101
|
| 332 |
+
dud_args = tuple(dud_arrays) + rest
|
| 333 |
+
_rough_check(result, fn(*dud_args, **kwargs), key=key)
|
| 334 |
+
# set those 0-weighted rows to NaNs
|
| 335 |
+
for a in dud_arrays:
|
| 336 |
+
indexer = [slice(None)] * a.ndim
|
| 337 |
+
indexer[axis] = slice(weights.size, None)
|
| 338 |
+
indexer = tuple(indexer)
|
| 339 |
+
a[indexer] = a[indexer] * np.nan
|
| 340 |
+
if kwargs.get("nan_policy", None) == "omit" and nan_safe:
|
| 341 |
+
dud_args = tuple(dud_arrays) + rest
|
| 342 |
+
_rough_check(result, fn(*dud_args, **kwargs), key=key)
|
| 343 |
+
# mask out those nan values
|
| 344 |
+
if ma_safe:
|
| 345 |
+
dud_arrays = [np.ma.masked_invalid(a) for a in dud_arrays]
|
| 346 |
+
dud_args = tuple(dud_arrays) + rest
|
| 347 |
+
_rough_check(result, fn(*dud_args, **kwargs), key=key)
|
| 348 |
+
if ma_very_safe:
|
| 349 |
+
kwargs[weight_arg] = None
|
| 350 |
+
_rough_check(result, fn(*dud_args, **kwargs), key=key)
|
| 351 |
+
del dud_arrays, dud_args, dud_weights
|
| 352 |
+
|
| 353 |
+
# WEIGHTS CHECK 3: DUPLICATE DATA (DUMB SPLITTING)
|
| 354 |
+
if dup_test:
|
| 355 |
+
dup_arrays = [np.append(a, a, axis=axis) for a in arrays]
|
| 356 |
+
dup_weights = np.append(weights, weights) / 2.0
|
| 357 |
+
dup_args = tuple(dup_arrays) + rest
|
| 358 |
+
kwargs[weight_arg] = dup_weights
|
| 359 |
+
_rough_check(result, fn(*dup_args, **kwargs), key=key)
|
| 360 |
+
del dup_args, dup_arrays, dup_weights
|
| 361 |
+
|
| 362 |
+
# WEIGHT CHECK 3: RANDOM SPLITTING
|
| 363 |
+
if split_test and split_per > 0:
|
| 364 |
+
split = _rand_split(arrays, weights, axis,
|
| 365 |
+
split_per=split_per, seed=seed)
|
| 366 |
+
split_arrays, split_weights = split
|
| 367 |
+
split_args = tuple(split_arrays) + rest
|
| 368 |
+
kwargs[weight_arg] = split_weights
|
| 369 |
+
_rough_check(result, fn(*split_args, **kwargs), key=key)
|
| 370 |
+
except NotImplementedError as e:
|
| 371 |
+
# when some combination of arguments makes weighting impossible,
|
| 372 |
+
# this is the desired response
|
| 373 |
+
if not silent:
|
| 374 |
+
warnings.warn(f"{fn.__name__} NotImplemented weights: {e}",
|
| 375 |
+
stacklevel=3)
|
| 376 |
+
return result
|
| 377 |
+
return wrapped
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
wcdist = _weight_checked(cdist, default_axis=1, squeeze=False)
|
| 381 |
+
wcdist_no_const = _weight_checked(cdist, default_axis=1,
|
| 382 |
+
squeeze=False, const_test=False)
|
| 383 |
+
wpdist = _weight_checked(pdist, default_axis=1, squeeze=False, n_args=1)
|
| 384 |
+
wpdist_no_const = _weight_checked(pdist, default_axis=1, squeeze=False,
|
| 385 |
+
const_test=False, n_args=1)
|
| 386 |
+
wrogerstanimoto = _weight_checked(rogerstanimoto)
|
| 387 |
+
wmatching = whamming = _weight_checked(hamming, dud_test=False)
|
| 388 |
+
wyule = _weight_checked(yule)
|
| 389 |
+
wdice = _weight_checked(dice)
|
| 390 |
+
wcityblock = _weight_checked(cityblock)
|
| 391 |
+
wchebyshev = _weight_checked(chebyshev)
|
| 392 |
+
wcosine = _weight_checked(cosine)
|
| 393 |
+
wcorrelation = _weight_checked(correlation)
|
| 394 |
+
wjaccard = _weight_checked(jaccard)
|
| 395 |
+
weuclidean = _weight_checked(euclidean, const_test=False)
|
| 396 |
+
wsqeuclidean = _weight_checked(sqeuclidean, const_test=False)
|
| 397 |
+
wbraycurtis = _weight_checked(braycurtis)
|
| 398 |
+
wcanberra = _weight_checked(canberra, const_test=False)
|
| 399 |
+
wsokalsneath = _weight_checked(sokalsneath)
|
| 400 |
+
wrussellrao = _weight_checked(russellrao)
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
class TestCdist:
|
| 404 |
+
|
| 405 |
+
def setup_method(self):
|
| 406 |
+
self.rnd_eo_names = ['random-float32-data', 'random-int-data',
|
| 407 |
+
'random-uint-data', 'random-double-data',
|
| 408 |
+
'random-bool-data']
|
| 409 |
+
self.valid_upcasts = {'bool': [np_ulong, np_long, np.float32, np.float64],
|
| 410 |
+
'uint': [np_long, np.float32, np.float64],
|
| 411 |
+
'int': [np.float32, np.float64],
|
| 412 |
+
'float32': [np.float64]}
|
| 413 |
+
|
| 414 |
+
def test_cdist_extra_args(self, metric):
|
| 415 |
+
# Tests that args and kwargs are correctly handled
|
| 416 |
+
|
| 417 |
+
X1 = [[1., 2., 3.], [1.2, 2.3, 3.4], [2.2, 2.3, 4.4]]
|
| 418 |
+
X2 = [[7., 5., 8.], [7.5, 5.8, 8.4], [5.5, 5.8, 4.4]]
|
| 419 |
+
kwargs = {"N0tV4l1D_p4raM": 3.14, "w": np.arange(3)}
|
| 420 |
+
args = [3.14] * 200
|
| 421 |
+
|
| 422 |
+
with pytest.raises(TypeError):
|
| 423 |
+
cdist(X1, X2, metric=metric, **kwargs)
|
| 424 |
+
with pytest.raises(TypeError):
|
| 425 |
+
cdist(X1, X2, metric=eval(metric), **kwargs)
|
| 426 |
+
with pytest.raises(TypeError):
|
| 427 |
+
cdist(X1, X2, metric="test_" + metric, **kwargs)
|
| 428 |
+
with pytest.raises(TypeError):
|
| 429 |
+
cdist(X1, X2, metric=metric, *args)
|
| 430 |
+
with pytest.raises(TypeError):
|
| 431 |
+
cdist(X1, X2, metric=eval(metric), *args)
|
| 432 |
+
with pytest.raises(TypeError):
|
| 433 |
+
cdist(X1, X2, metric="test_" + metric, *args)
|
| 434 |
+
|
| 435 |
+
def test_cdist_extra_args_custom(self):
|
| 436 |
+
# Tests that args and kwargs are correctly handled
|
| 437 |
+
# also for custom metric
|
| 438 |
+
def _my_metric(x, y, arg, kwarg=1, kwarg2=2):
|
| 439 |
+
return arg + kwarg + kwarg2
|
| 440 |
+
|
| 441 |
+
X1 = [[1., 2., 3.], [1.2, 2.3, 3.4], [2.2, 2.3, 4.4]]
|
| 442 |
+
X2 = [[7., 5., 8.], [7.5, 5.8, 8.4], [5.5, 5.8, 4.4]]
|
| 443 |
+
kwargs = {"N0tV4l1D_p4raM": 3.14, "w": np.arange(3)}
|
| 444 |
+
args = [3.14] * 200
|
| 445 |
+
|
| 446 |
+
with pytest.raises(TypeError):
|
| 447 |
+
cdist(X1, X2, _my_metric)
|
| 448 |
+
with pytest.raises(TypeError):
|
| 449 |
+
cdist(X1, X2, _my_metric, *args)
|
| 450 |
+
with pytest.raises(TypeError):
|
| 451 |
+
cdist(X1, X2, _my_metric, **kwargs)
|
| 452 |
+
with pytest.raises(TypeError):
|
| 453 |
+
cdist(X1, X2, _my_metric, kwarg=2.2, kwarg2=3.3)
|
| 454 |
+
with pytest.raises(TypeError):
|
| 455 |
+
cdist(X1, X2, _my_metric, 1, 2, kwarg=2.2)
|
| 456 |
+
with pytest.raises(TypeError):
|
| 457 |
+
cdist(X1, X2, _my_metric, 1, 2, kwarg=2.2)
|
| 458 |
+
with pytest.raises(TypeError):
|
| 459 |
+
cdist(X1, X2, _my_metric, 1.1, 2.2, 3.3)
|
| 460 |
+
with pytest.raises(TypeError):
|
| 461 |
+
cdist(X1, X2, _my_metric, 1.1, 2.2)
|
| 462 |
+
with pytest.raises(TypeError):
|
| 463 |
+
cdist(X1, X2, _my_metric, 1.1)
|
| 464 |
+
with pytest.raises(TypeError):
|
| 465 |
+
cdist(X1, X2, _my_metric, 1.1, kwarg=2.2, kwarg2=3.3)
|
| 466 |
+
|
| 467 |
+
# this should work
|
| 468 |
+
assert_allclose(cdist(X1, X2, metric=_my_metric,
|
| 469 |
+
arg=1.1, kwarg2=3.3), 5.4)
|
| 470 |
+
|
| 471 |
+
def test_cdist_euclidean_random_unicode(self):
|
| 472 |
+
eps = 1e-15
|
| 473 |
+
X1 = eo['cdist-X1']
|
| 474 |
+
X2 = eo['cdist-X2']
|
| 475 |
+
Y1 = wcdist_no_const(X1, X2, 'euclidean')
|
| 476 |
+
Y2 = wcdist_no_const(X1, X2, 'test_euclidean')
|
| 477 |
+
assert_allclose(Y1, Y2, rtol=eps, verbose=verbose > 2)
|
| 478 |
+
|
| 479 |
+
@pytest.mark.parametrize("p", [0.1, 0.25, 1.0, 1.23,
|
| 480 |
+
2.0, 3.8, 4.6, np.inf])
|
| 481 |
+
def test_cdist_minkowski_random(self, p):
|
| 482 |
+
eps = 1e-13
|
| 483 |
+
X1 = eo['cdist-X1']
|
| 484 |
+
X2 = eo['cdist-X2']
|
| 485 |
+
Y1 = wcdist_no_const(X1, X2, 'minkowski', p=p)
|
| 486 |
+
Y2 = wcdist_no_const(X1, X2, 'test_minkowski', p=p)
|
| 487 |
+
assert_allclose(Y1, Y2, atol=0, rtol=eps, verbose=verbose > 2)
|
| 488 |
+
|
| 489 |
+
def test_cdist_cosine_random(self):
|
| 490 |
+
eps = 1e-14
|
| 491 |
+
X1 = eo['cdist-X1']
|
| 492 |
+
X2 = eo['cdist-X2']
|
| 493 |
+
Y1 = wcdist(X1, X2, 'cosine')
|
| 494 |
+
|
| 495 |
+
# Naive implementation
|
| 496 |
+
def norms(X):
|
| 497 |
+
return np.linalg.norm(X, axis=1).reshape(-1, 1)
|
| 498 |
+
|
| 499 |
+
Y2 = 1 - np.dot((X1 / norms(X1)), (X2 / norms(X2)).T)
|
| 500 |
+
|
| 501 |
+
assert_allclose(Y1, Y2, rtol=eps, verbose=verbose > 2)
|
| 502 |
+
|
| 503 |
+
def test_cdist_mahalanobis(self):
|
| 504 |
+
# 1-dimensional observations
|
| 505 |
+
x1 = np.array([[2], [3]])
|
| 506 |
+
x2 = np.array([[2], [5]])
|
| 507 |
+
dist = cdist(x1, x2, metric='mahalanobis')
|
| 508 |
+
assert_allclose(dist, [[0.0, np.sqrt(4.5)], [np.sqrt(0.5), np.sqrt(2)]])
|
| 509 |
+
|
| 510 |
+
# 2-dimensional observations
|
| 511 |
+
x1 = np.array([[0, 0], [-1, 0]])
|
| 512 |
+
x2 = np.array([[0, 2], [1, 0], [0, -2]])
|
| 513 |
+
dist = cdist(x1, x2, metric='mahalanobis')
|
| 514 |
+
rt2 = np.sqrt(2)
|
| 515 |
+
assert_allclose(dist, [[rt2, rt2, rt2], [2, 2 * rt2, 2]])
|
| 516 |
+
|
| 517 |
+
# Too few observations
|
| 518 |
+
with pytest.raises(ValueError):
|
| 519 |
+
cdist([[0, 1]], [[2, 3]], metric='mahalanobis')
|
| 520 |
+
|
| 521 |
+
def test_cdist_custom_notdouble(self):
|
| 522 |
+
class myclass:
|
| 523 |
+
pass
|
| 524 |
+
|
| 525 |
+
def _my_metric(x, y):
|
| 526 |
+
if not isinstance(x[0], myclass) or not isinstance(y[0], myclass):
|
| 527 |
+
raise ValueError("Type has been changed")
|
| 528 |
+
return 1.123
|
| 529 |
+
data = np.array([[myclass()]], dtype=object)
|
| 530 |
+
cdist_y = cdist(data, data, metric=_my_metric)
|
| 531 |
+
right_y = 1.123
|
| 532 |
+
assert_equal(cdist_y, right_y, verbose=verbose > 2)
|
| 533 |
+
|
| 534 |
+
def _check_calling_conventions(self, X1, X2, metric, eps=1e-07, **kwargs):
|
| 535 |
+
# helper function for test_cdist_calling_conventions
|
| 536 |
+
try:
|
| 537 |
+
y1 = cdist(X1, X2, metric=metric, **kwargs)
|
| 538 |
+
y2 = cdist(X1, X2, metric=eval(metric), **kwargs)
|
| 539 |
+
y3 = cdist(X1, X2, metric="test_" + metric, **kwargs)
|
| 540 |
+
except Exception as e:
|
| 541 |
+
e_cls = e.__class__
|
| 542 |
+
if verbose > 2:
|
| 543 |
+
print(e_cls.__name__)
|
| 544 |
+
print(e)
|
| 545 |
+
with pytest.raises(e_cls):
|
| 546 |
+
cdist(X1, X2, metric=metric, **kwargs)
|
| 547 |
+
with pytest.raises(e_cls):
|
| 548 |
+
cdist(X1, X2, metric=eval(metric), **kwargs)
|
| 549 |
+
with pytest.raises(e_cls):
|
| 550 |
+
cdist(X1, X2, metric="test_" + metric, **kwargs)
|
| 551 |
+
else:
|
| 552 |
+
assert_allclose(y1, y2, rtol=eps, verbose=verbose > 2)
|
| 553 |
+
assert_allclose(y1, y3, rtol=eps, verbose=verbose > 2)
|
| 554 |
+
|
| 555 |
+
def test_cdist_calling_conventions(self, metric):
|
| 556 |
+
# Ensures that specifying the metric with a str or scipy function
|
| 557 |
+
# gives the same behaviour (i.e. same result or same exception).
|
| 558 |
+
# NOTE: The correctness should be checked within each metric tests.
|
| 559 |
+
for eo_name in self.rnd_eo_names:
|
| 560 |
+
# subsampling input data to speed-up tests
|
| 561 |
+
# NOTE: num samples needs to be > than dimensions for mahalanobis
|
| 562 |
+
X1 = eo[eo_name][::5, ::-2]
|
| 563 |
+
X2 = eo[eo_name][1::5, ::2]
|
| 564 |
+
if verbose > 2:
|
| 565 |
+
print("testing: ", metric, " with: ", eo_name)
|
| 566 |
+
if (metric in {'dice', 'yule', 'rogerstanimoto', 'russellrao',
|
| 567 |
+
'sokalsneath'}
|
| 568 |
+
and 'bool' not in eo_name):
|
| 569 |
+
# python version permits non-bools e.g. for fuzzy logic
|
| 570 |
+
continue
|
| 571 |
+
self._check_calling_conventions(X1, X2, metric)
|
| 572 |
+
|
| 573 |
+
# Testing built-in metrics with extra args
|
| 574 |
+
if metric == "seuclidean":
|
| 575 |
+
X12 = np.vstack([X1, X2]).astype(np.float64)
|
| 576 |
+
V = np.var(X12, axis=0, ddof=1)
|
| 577 |
+
self._check_calling_conventions(X1, X2, metric, V=V)
|
| 578 |
+
elif metric == "mahalanobis":
|
| 579 |
+
X12 = np.vstack([X1, X2]).astype(np.float64)
|
| 580 |
+
V = np.atleast_2d(np.cov(X12.T))
|
| 581 |
+
VI = np.array(np.linalg.inv(V).T)
|
| 582 |
+
self._check_calling_conventions(X1, X2, metric, VI=VI)
|
| 583 |
+
|
| 584 |
+
def test_cdist_dtype_equivalence(self, metric):
|
| 585 |
+
# Tests that the result is not affected by type up-casting
|
| 586 |
+
eps = 1e-07
|
| 587 |
+
tests = [(eo['random-bool-data'], self.valid_upcasts['bool']),
|
| 588 |
+
(eo['random-uint-data'], self.valid_upcasts['uint']),
|
| 589 |
+
(eo['random-int-data'], self.valid_upcasts['int']),
|
| 590 |
+
(eo['random-float32-data'], self.valid_upcasts['float32'])]
|
| 591 |
+
for test in tests:
|
| 592 |
+
X1 = test[0][::5, ::-2]
|
| 593 |
+
X2 = test[0][1::5, ::2]
|
| 594 |
+
try:
|
| 595 |
+
y1 = cdist(X1, X2, metric=metric)
|
| 596 |
+
except Exception as e:
|
| 597 |
+
e_cls = e.__class__
|
| 598 |
+
if verbose > 2:
|
| 599 |
+
print(e_cls.__name__)
|
| 600 |
+
print(e)
|
| 601 |
+
for new_type in test[1]:
|
| 602 |
+
X1new = new_type(X1)
|
| 603 |
+
X2new = new_type(X2)
|
| 604 |
+
with pytest.raises(e_cls):
|
| 605 |
+
cdist(X1new, X2new, metric=metric)
|
| 606 |
+
else:
|
| 607 |
+
for new_type in test[1]:
|
| 608 |
+
y2 = cdist(new_type(X1), new_type(X2), metric=metric)
|
| 609 |
+
assert_allclose(y1, y2, rtol=eps, verbose=verbose > 2)
|
| 610 |
+
|
| 611 |
+
@pytest.mark.skipif(sysconfig.get_platform() == 'win-arm64', reason="numpy#29442")
|
| 612 |
+
def test_cdist_out(self, metric):
|
| 613 |
+
# Test that out parameter works properly
|
| 614 |
+
eps = 1e-15
|
| 615 |
+
X1 = eo['cdist-X1']
|
| 616 |
+
X2 = eo['cdist-X2']
|
| 617 |
+
out_r, out_c = X1.shape[0], X2.shape[0]
|
| 618 |
+
|
| 619 |
+
kwargs = dict()
|
| 620 |
+
if metric == 'minkowski':
|
| 621 |
+
kwargs['p'] = 1.23
|
| 622 |
+
out1 = np.empty((out_r, out_c), dtype=np.float64)
|
| 623 |
+
Y1 = cdist(X1, X2, metric, **kwargs)
|
| 624 |
+
Y2 = cdist(X1, X2, metric, out=out1, **kwargs)
|
| 625 |
+
|
| 626 |
+
# test that output is numerically equivalent
|
| 627 |
+
assert_allclose(Y1, Y2, rtol=eps, verbose=verbose > 2)
|
| 628 |
+
|
| 629 |
+
# test that Y_test1 and out1 are the same object
|
| 630 |
+
assert_(Y2 is out1)
|
| 631 |
+
|
| 632 |
+
# test for incorrect shape
|
| 633 |
+
out2 = np.empty((out_r-1, out_c+1), dtype=np.float64)
|
| 634 |
+
with pytest.raises(ValueError):
|
| 635 |
+
cdist(X1, X2, metric, out=out2, **kwargs)
|
| 636 |
+
|
| 637 |
+
# test for C-contiguous order
|
| 638 |
+
out3 = np.empty(
|
| 639 |
+
(2 * out_r, 2 * out_c), dtype=np.float64)[::2, ::2]
|
| 640 |
+
out4 = np.empty((out_r, out_c), dtype=np.float64, order='F')
|
| 641 |
+
with pytest.raises(ValueError):
|
| 642 |
+
cdist(X1, X2, metric, out=out3, **kwargs)
|
| 643 |
+
with pytest.raises(ValueError):
|
| 644 |
+
cdist(X1, X2, metric, out=out4, **kwargs)
|
| 645 |
+
|
| 646 |
+
# test for incorrect dtype
|
| 647 |
+
out5 = np.empty((out_r, out_c), dtype=np.int64)
|
| 648 |
+
with pytest.raises(ValueError):
|
| 649 |
+
cdist(X1, X2, metric, out=out5, **kwargs)
|
| 650 |
+
|
| 651 |
+
def test_striding(self, metric):
|
| 652 |
+
# test that striding is handled correct with calls to
|
| 653 |
+
# _copy_array_if_base_present
|
| 654 |
+
eps = 1e-15
|
| 655 |
+
X1 = eo['cdist-X1'][::2, ::2]
|
| 656 |
+
X2 = eo['cdist-X2'][::2, ::2]
|
| 657 |
+
X1_copy = X1.copy()
|
| 658 |
+
X2_copy = X2.copy()
|
| 659 |
+
|
| 660 |
+
# confirm equivalence
|
| 661 |
+
assert_equal(X1, X1_copy)
|
| 662 |
+
assert_equal(X2, X2_copy)
|
| 663 |
+
# confirm contiguity
|
| 664 |
+
assert_(not X1.flags.c_contiguous)
|
| 665 |
+
assert_(not X2.flags.c_contiguous)
|
| 666 |
+
assert_(X1_copy.flags.c_contiguous)
|
| 667 |
+
assert_(X2_copy.flags.c_contiguous)
|
| 668 |
+
|
| 669 |
+
kwargs = dict()
|
| 670 |
+
if metric == 'minkowski':
|
| 671 |
+
kwargs['p'] = 1.23
|
| 672 |
+
Y1 = cdist(X1, X2, metric, **kwargs)
|
| 673 |
+
Y2 = cdist(X1_copy, X2_copy, metric, **kwargs)
|
| 674 |
+
# test that output is numerically equivalent
|
| 675 |
+
assert_allclose(Y1, Y2, rtol=eps, verbose=verbose > 2)
|
| 676 |
+
|
| 677 |
+
def test_cdist_refcount(self, metric):
|
| 678 |
+
x1 = np.random.rand(10, 10)
|
| 679 |
+
x2 = np.random.rand(10, 10)
|
| 680 |
+
|
| 681 |
+
kwargs = dict()
|
| 682 |
+
if metric == 'minkowski':
|
| 683 |
+
kwargs['p'] = 1.23
|
| 684 |
+
|
| 685 |
+
out = cdist(x1, x2, metric=metric, **kwargs)
|
| 686 |
+
|
| 687 |
+
# Check reference counts aren't messed up. If we only hold weak
|
| 688 |
+
# references, the arrays should be deallocated.
|
| 689 |
+
weak_refs = [weakref.ref(v) for v in (x1, x2, out)]
|
| 690 |
+
del x1, x2, out
|
| 691 |
+
|
| 692 |
+
if IS_PYPY:
|
| 693 |
+
break_cycles()
|
| 694 |
+
assert all(weak_ref() is None for weak_ref in weak_refs)
|
| 695 |
+
|
| 696 |
+
|
| 697 |
+
class TestPdist:
|
| 698 |
+
|
| 699 |
+
def setup_method(self):
|
| 700 |
+
self.rnd_eo_names = ['random-float32-data', 'random-int-data',
|
| 701 |
+
'random-uint-data', 'random-double-data',
|
| 702 |
+
'random-bool-data']
|
| 703 |
+
self.valid_upcasts = {'bool': [np_ulong, np_long, np.float32, np.float64],
|
| 704 |
+
'uint': [np_long, np.float32, np.float64],
|
| 705 |
+
'int': [np.float32, np.float64],
|
| 706 |
+
'float32': [np.float64]}
|
| 707 |
+
|
| 708 |
+
def test_pdist_extra_args(self, metric):
|
| 709 |
+
# Tests that args and kwargs are correctly handled
|
| 710 |
+
X1 = [[1., 2.], [1.2, 2.3], [2.2, 2.3]]
|
| 711 |
+
kwargs = {"N0tV4l1D_p4raM": 3.14, "w": np.arange(2)}
|
| 712 |
+
args = [3.14] * 200
|
| 713 |
+
|
| 714 |
+
with pytest.raises(TypeError):
|
| 715 |
+
pdist(X1, metric=metric, **kwargs)
|
| 716 |
+
with pytest.raises(TypeError):
|
| 717 |
+
pdist(X1, metric=eval(metric), **kwargs)
|
| 718 |
+
with pytest.raises(TypeError):
|
| 719 |
+
pdist(X1, metric="test_" + metric, **kwargs)
|
| 720 |
+
with pytest.raises(TypeError):
|
| 721 |
+
pdist(X1, metric=metric, *args)
|
| 722 |
+
with pytest.raises(TypeError):
|
| 723 |
+
pdist(X1, metric=eval(metric), *args)
|
| 724 |
+
with pytest.raises(TypeError):
|
| 725 |
+
pdist(X1, metric="test_" + metric, *args)
|
| 726 |
+
|
| 727 |
+
def test_pdist_extra_args_custom(self):
|
| 728 |
+
# Tests that args and kwargs are correctly handled
|
| 729 |
+
# also for custom metric
|
| 730 |
+
def _my_metric(x, y, arg, kwarg=1, kwarg2=2):
|
| 731 |
+
return arg + kwarg + kwarg2
|
| 732 |
+
|
| 733 |
+
X1 = [[1., 2.], [1.2, 2.3], [2.2, 2.3]]
|
| 734 |
+
kwargs = {"N0tV4l1D_p4raM": 3.14, "w": np.arange(2)}
|
| 735 |
+
args = [3.14] * 200
|
| 736 |
+
|
| 737 |
+
with pytest.raises(TypeError):
|
| 738 |
+
pdist(X1, _my_metric)
|
| 739 |
+
with pytest.raises(TypeError):
|
| 740 |
+
pdist(X1, _my_metric, *args)
|
| 741 |
+
with pytest.raises(TypeError):
|
| 742 |
+
pdist(X1, _my_metric, **kwargs)
|
| 743 |
+
with pytest.raises(TypeError):
|
| 744 |
+
pdist(X1, _my_metric, kwarg=2.2, kwarg2=3.3)
|
| 745 |
+
with pytest.raises(TypeError):
|
| 746 |
+
pdist(X1, _my_metric, 1, 2, kwarg=2.2)
|
| 747 |
+
with pytest.raises(TypeError):
|
| 748 |
+
pdist(X1, _my_metric, 1, 2, kwarg=2.2)
|
| 749 |
+
with pytest.raises(TypeError):
|
| 750 |
+
pdist(X1, _my_metric, 1.1, 2.2, 3.3)
|
| 751 |
+
with pytest.raises(TypeError):
|
| 752 |
+
pdist(X1, _my_metric, 1.1, 2.2)
|
| 753 |
+
with pytest.raises(TypeError):
|
| 754 |
+
pdist(X1, _my_metric, 1.1)
|
| 755 |
+
with pytest.raises(TypeError):
|
| 756 |
+
pdist(X1, _my_metric, 1.1, kwarg=2.2, kwarg2=3.3)
|
| 757 |
+
|
| 758 |
+
# these should work
|
| 759 |
+
assert_allclose(pdist(X1, metric=_my_metric,
|
| 760 |
+
arg=1.1, kwarg2=3.3), 5.4)
|
| 761 |
+
|
| 762 |
+
def test_pdist_euclidean_random(self):
|
| 763 |
+
eps = 1e-07
|
| 764 |
+
X = eo['pdist-double-inp']
|
| 765 |
+
Y_right = eo['pdist-euclidean']
|
| 766 |
+
Y_test1 = wpdist_no_const(X, 'euclidean')
|
| 767 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 768 |
+
|
| 769 |
+
def test_pdist_euclidean_random_u(self):
|
| 770 |
+
eps = 1e-07
|
| 771 |
+
X = eo['pdist-double-inp']
|
| 772 |
+
Y_right = eo['pdist-euclidean']
|
| 773 |
+
Y_test1 = wpdist_no_const(X, 'euclidean')
|
| 774 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 775 |
+
|
| 776 |
+
def test_pdist_euclidean_random_float32(self):
|
| 777 |
+
eps = 1e-07
|
| 778 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 779 |
+
Y_right = eo['pdist-euclidean']
|
| 780 |
+
Y_test1 = wpdist_no_const(X, 'euclidean')
|
| 781 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 782 |
+
|
| 783 |
+
def test_pdist_euclidean_random_nonC(self):
|
| 784 |
+
eps = 1e-07
|
| 785 |
+
X = eo['pdist-double-inp']
|
| 786 |
+
Y_right = eo['pdist-euclidean']
|
| 787 |
+
Y_test2 = wpdist_no_const(X, 'test_euclidean')
|
| 788 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 789 |
+
|
| 790 |
+
@pytest.mark.slow
|
| 791 |
+
def test_pdist_euclidean_iris_double(self):
|
| 792 |
+
eps = 1e-7
|
| 793 |
+
X = eo['iris']
|
| 794 |
+
Y_right = eo['pdist-euclidean-iris']
|
| 795 |
+
Y_test1 = wpdist_no_const(X, 'euclidean')
|
| 796 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 797 |
+
|
| 798 |
+
@pytest.mark.slow
|
| 799 |
+
def test_pdist_euclidean_iris_float32(self):
|
| 800 |
+
eps = 1e-5
|
| 801 |
+
X = np.float32(eo['iris'])
|
| 802 |
+
Y_right = eo['pdist-euclidean-iris']
|
| 803 |
+
Y_test1 = wpdist_no_const(X, 'euclidean')
|
| 804 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 805 |
+
|
| 806 |
+
@pytest.mark.slow
|
| 807 |
+
def test_pdist_euclidean_iris_nonC(self):
|
| 808 |
+
# Test pdist(X, 'test_euclidean') [the non-C implementation] on the
|
| 809 |
+
# Iris data set.
|
| 810 |
+
eps = 1e-7
|
| 811 |
+
X = eo['iris']
|
| 812 |
+
Y_right = eo['pdist-euclidean-iris']
|
| 813 |
+
Y_test2 = wpdist_no_const(X, 'test_euclidean')
|
| 814 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 815 |
+
|
| 816 |
+
def test_pdist_seuclidean_random(self):
|
| 817 |
+
eps = 1e-7
|
| 818 |
+
X = eo['pdist-double-inp']
|
| 819 |
+
Y_right = eo['pdist-seuclidean']
|
| 820 |
+
Y_test1 = pdist(X, 'seuclidean')
|
| 821 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 822 |
+
|
| 823 |
+
def test_pdist_seuclidean_random_float32(self):
|
| 824 |
+
eps = 1e-7
|
| 825 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 826 |
+
Y_right = eo['pdist-seuclidean']
|
| 827 |
+
Y_test1 = pdist(X, 'seuclidean')
|
| 828 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 829 |
+
|
| 830 |
+
# Check no error is raise when V has float32 dtype (#11171).
|
| 831 |
+
V = np.var(X, axis=0, ddof=1)
|
| 832 |
+
Y_test2 = pdist(X, 'seuclidean', V=V)
|
| 833 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 834 |
+
|
| 835 |
+
def test_pdist_seuclidean_random_nonC(self):
|
| 836 |
+
# Test pdist(X, 'test_sqeuclidean') [the non-C implementation]
|
| 837 |
+
eps = 1e-07
|
| 838 |
+
X = eo['pdist-double-inp']
|
| 839 |
+
Y_right = eo['pdist-seuclidean']
|
| 840 |
+
Y_test2 = pdist(X, 'test_seuclidean')
|
| 841 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 842 |
+
|
| 843 |
+
def test_pdist_seuclidean_iris(self):
|
| 844 |
+
eps = 1e-7
|
| 845 |
+
X = eo['iris']
|
| 846 |
+
Y_right = eo['pdist-seuclidean-iris']
|
| 847 |
+
Y_test1 = pdist(X, 'seuclidean')
|
| 848 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 849 |
+
|
| 850 |
+
def test_pdist_seuclidean_iris_float32(self):
|
| 851 |
+
# Tests pdist(X, 'seuclidean') on the Iris data set (float32).
|
| 852 |
+
eps = 1e-5
|
| 853 |
+
X = np.float32(eo['iris'])
|
| 854 |
+
Y_right = eo['pdist-seuclidean-iris']
|
| 855 |
+
Y_test1 = pdist(X, 'seuclidean')
|
| 856 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 857 |
+
|
| 858 |
+
def test_pdist_seuclidean_iris_nonC(self):
|
| 859 |
+
# Test pdist(X, 'test_seuclidean') [the non-C implementation] on the
|
| 860 |
+
# Iris data set.
|
| 861 |
+
eps = 1e-7
|
| 862 |
+
X = eo['iris']
|
| 863 |
+
Y_right = eo['pdist-seuclidean-iris']
|
| 864 |
+
Y_test2 = pdist(X, 'test_seuclidean')
|
| 865 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 866 |
+
|
| 867 |
+
def test_pdist_cosine_random(self):
|
| 868 |
+
eps = 1e-7
|
| 869 |
+
X = eo['pdist-double-inp']
|
| 870 |
+
Y_right = eo['pdist-cosine']
|
| 871 |
+
Y_test1 = wpdist(X, 'cosine')
|
| 872 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 873 |
+
|
| 874 |
+
def test_pdist_cosine_random_float32(self):
|
| 875 |
+
eps = 1e-7
|
| 876 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 877 |
+
Y_right = eo['pdist-cosine']
|
| 878 |
+
Y_test1 = wpdist(X, 'cosine')
|
| 879 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 880 |
+
|
| 881 |
+
def test_pdist_cosine_random_nonC(self):
|
| 882 |
+
# Test pdist(X, 'test_cosine') [the non-C implementation]
|
| 883 |
+
eps = 1e-7
|
| 884 |
+
X = eo['pdist-double-inp']
|
| 885 |
+
Y_right = eo['pdist-cosine']
|
| 886 |
+
Y_test2 = wpdist(X, 'test_cosine')
|
| 887 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 888 |
+
|
| 889 |
+
@pytest.mark.slow
|
| 890 |
+
def test_pdist_cosine_iris(self):
|
| 891 |
+
eps = 1e-05
|
| 892 |
+
X = eo['iris']
|
| 893 |
+
Y_right = eo['pdist-cosine-iris']
|
| 894 |
+
Y_test1 = wpdist(X, 'cosine')
|
| 895 |
+
assert_allclose(Y_test1, Y_right, atol=eps)
|
| 896 |
+
|
| 897 |
+
@pytest.mark.slow
|
| 898 |
+
def test_pdist_cosine_iris_float32(self):
|
| 899 |
+
eps = 1e-05
|
| 900 |
+
X = np.float32(eo['iris'])
|
| 901 |
+
Y_right = eo['pdist-cosine-iris']
|
| 902 |
+
Y_test1 = wpdist(X, 'cosine')
|
| 903 |
+
assert_allclose(Y_test1, Y_right, atol=eps, verbose=verbose > 2)
|
| 904 |
+
|
| 905 |
+
@pytest.mark.slow
|
| 906 |
+
def test_pdist_cosine_iris_nonC(self):
|
| 907 |
+
eps = 1e-05
|
| 908 |
+
X = eo['iris']
|
| 909 |
+
Y_right = eo['pdist-cosine-iris']
|
| 910 |
+
Y_test2 = wpdist(X, 'test_cosine')
|
| 911 |
+
assert_allclose(Y_test2, Y_right, atol=eps)
|
| 912 |
+
|
| 913 |
+
def test_pdist_cosine_bounds(self):
|
| 914 |
+
# Test adapted from @joernhees's example at gh-5208: case where
|
| 915 |
+
# cosine distance used to be negative. XXX: very sensitive to the
|
| 916 |
+
# specific norm computation.
|
| 917 |
+
x = np.abs(np.random.RandomState(1337).rand(91))
|
| 918 |
+
X = np.vstack([x, x])
|
| 919 |
+
assert_(wpdist(X, 'cosine')[0] >= 0,
|
| 920 |
+
msg='cosine distance should be non-negative')
|
| 921 |
+
|
| 922 |
+
def test_pdist_cityblock_random(self):
|
| 923 |
+
eps = 1e-7
|
| 924 |
+
X = eo['pdist-double-inp']
|
| 925 |
+
Y_right = eo['pdist-cityblock']
|
| 926 |
+
Y_test1 = wpdist_no_const(X, 'cityblock')
|
| 927 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 928 |
+
|
| 929 |
+
def test_pdist_cityblock_random_float32(self):
|
| 930 |
+
eps = 1e-7
|
| 931 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 932 |
+
Y_right = eo['pdist-cityblock']
|
| 933 |
+
Y_test1 = wpdist_no_const(X, 'cityblock')
|
| 934 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 935 |
+
|
| 936 |
+
def test_pdist_cityblock_random_nonC(self):
|
| 937 |
+
eps = 1e-7
|
| 938 |
+
X = eo['pdist-double-inp']
|
| 939 |
+
Y_right = eo['pdist-cityblock']
|
| 940 |
+
Y_test2 = wpdist_no_const(X, 'test_cityblock')
|
| 941 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 942 |
+
|
| 943 |
+
@pytest.mark.slow
|
| 944 |
+
def test_pdist_cityblock_iris(self):
|
| 945 |
+
eps = 1e-14
|
| 946 |
+
X = eo['iris']
|
| 947 |
+
Y_right = eo['pdist-cityblock-iris']
|
| 948 |
+
Y_test1 = wpdist_no_const(X, 'cityblock')
|
| 949 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 950 |
+
|
| 951 |
+
@pytest.mark.slow
|
| 952 |
+
def test_pdist_cityblock_iris_float32(self):
|
| 953 |
+
eps = 1e-5
|
| 954 |
+
X = np.float32(eo['iris'])
|
| 955 |
+
Y_right = eo['pdist-cityblock-iris']
|
| 956 |
+
Y_test1 = wpdist_no_const(X, 'cityblock')
|
| 957 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 958 |
+
|
| 959 |
+
@pytest.mark.slow
|
| 960 |
+
def test_pdist_cityblock_iris_nonC(self):
|
| 961 |
+
# Test pdist(X, 'test_cityblock') [the non-C implementation] on the
|
| 962 |
+
# Iris data set.
|
| 963 |
+
eps = 1e-14
|
| 964 |
+
X = eo['iris']
|
| 965 |
+
Y_right = eo['pdist-cityblock-iris']
|
| 966 |
+
Y_test2 = wpdist_no_const(X, 'test_cityblock')
|
| 967 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 968 |
+
|
| 969 |
+
def test_pdist_correlation_random(self):
|
| 970 |
+
eps = 1e-7
|
| 971 |
+
X = eo['pdist-double-inp']
|
| 972 |
+
Y_right = eo['pdist-correlation']
|
| 973 |
+
Y_test1 = wpdist(X, 'correlation')
|
| 974 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 975 |
+
|
| 976 |
+
def test_pdist_correlation_random_float32(self):
|
| 977 |
+
eps = 1e-7
|
| 978 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 979 |
+
Y_right = eo['pdist-correlation']
|
| 980 |
+
Y_test1 = wpdist(X, 'correlation')
|
| 981 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 982 |
+
|
| 983 |
+
def test_pdist_correlation_random_nonC(self):
|
| 984 |
+
eps = 1e-7
|
| 985 |
+
X = eo['pdist-double-inp']
|
| 986 |
+
Y_right = eo['pdist-correlation']
|
| 987 |
+
Y_test2 = wpdist(X, 'test_correlation')
|
| 988 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 989 |
+
|
| 990 |
+
@pytest.mark.slow
|
| 991 |
+
def test_pdist_correlation_iris(self):
|
| 992 |
+
eps = 1e-7
|
| 993 |
+
X = eo['iris']
|
| 994 |
+
Y_right = eo['pdist-correlation-iris']
|
| 995 |
+
Y_test1 = wpdist(X, 'correlation')
|
| 996 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 997 |
+
|
| 998 |
+
@pytest.mark.slow
|
| 999 |
+
def test_pdist_correlation_iris_float32(self):
|
| 1000 |
+
eps = 1e-7
|
| 1001 |
+
X = eo['iris']
|
| 1002 |
+
Y_right = np.float32(eo['pdist-correlation-iris'])
|
| 1003 |
+
Y_test1 = wpdist(X, 'correlation')
|
| 1004 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 1005 |
+
|
| 1006 |
+
@pytest.mark.slow
|
| 1007 |
+
def test_pdist_correlation_iris_nonC(self):
|
| 1008 |
+
if sys.maxsize > 2**32:
|
| 1009 |
+
eps = 1e-7
|
| 1010 |
+
else:
|
| 1011 |
+
pytest.skip("see gh-16456")
|
| 1012 |
+
X = eo['iris']
|
| 1013 |
+
Y_right = eo['pdist-correlation-iris']
|
| 1014 |
+
Y_test2 = wpdist(X, 'test_correlation')
|
| 1015 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1016 |
+
|
| 1017 |
+
@pytest.mark.parametrize("p", [0.1, 0.25, 1.0, 2.0, 3.2, np.inf])
|
| 1018 |
+
def test_pdist_minkowski_random_p(self, p):
|
| 1019 |
+
eps = 1e-13
|
| 1020 |
+
X = eo['pdist-double-inp']
|
| 1021 |
+
Y1 = wpdist_no_const(X, 'minkowski', p=p)
|
| 1022 |
+
Y2 = wpdist_no_const(X, 'test_minkowski', p=p)
|
| 1023 |
+
assert_allclose(Y1, Y2, atol=0, rtol=eps)
|
| 1024 |
+
|
| 1025 |
+
def test_pdist_minkowski_random(self):
|
| 1026 |
+
eps = 1e-7
|
| 1027 |
+
X = eo['pdist-double-inp']
|
| 1028 |
+
Y_right = eo['pdist-minkowski-3.2']
|
| 1029 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=3.2)
|
| 1030 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1031 |
+
|
| 1032 |
+
def test_pdist_minkowski_random_float32(self):
|
| 1033 |
+
eps = 1e-7
|
| 1034 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 1035 |
+
Y_right = eo['pdist-minkowski-3.2']
|
| 1036 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=3.2)
|
| 1037 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1038 |
+
|
| 1039 |
+
def test_pdist_minkowski_random_nonC(self):
|
| 1040 |
+
eps = 1e-7
|
| 1041 |
+
X = eo['pdist-double-inp']
|
| 1042 |
+
Y_right = eo['pdist-minkowski-3.2']
|
| 1043 |
+
Y_test2 = wpdist_no_const(X, 'test_minkowski', p=3.2)
|
| 1044 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1045 |
+
|
| 1046 |
+
@pytest.mark.slow
|
| 1047 |
+
def test_pdist_minkowski_3_2_iris(self):
|
| 1048 |
+
eps = 1e-7
|
| 1049 |
+
X = eo['iris']
|
| 1050 |
+
Y_right = eo['pdist-minkowski-3.2-iris']
|
| 1051 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=3.2)
|
| 1052 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1053 |
+
|
| 1054 |
+
@pytest.mark.slow
|
| 1055 |
+
def test_pdist_minkowski_3_2_iris_float32(self):
|
| 1056 |
+
eps = 1e-5
|
| 1057 |
+
X = np.float32(eo['iris'])
|
| 1058 |
+
Y_right = eo['pdist-minkowski-3.2-iris']
|
| 1059 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=3.2)
|
| 1060 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1061 |
+
|
| 1062 |
+
@pytest.mark.slow
|
| 1063 |
+
def test_pdist_minkowski_3_2_iris_nonC(self):
|
| 1064 |
+
eps = 1e-7
|
| 1065 |
+
X = eo['iris']
|
| 1066 |
+
Y_right = eo['pdist-minkowski-3.2-iris']
|
| 1067 |
+
Y_test2 = wpdist_no_const(X, 'test_minkowski', p=3.2)
|
| 1068 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1069 |
+
|
| 1070 |
+
@pytest.mark.slow
|
| 1071 |
+
def test_pdist_minkowski_5_8_iris(self):
|
| 1072 |
+
eps = 1e-7
|
| 1073 |
+
X = eo['iris']
|
| 1074 |
+
Y_right = eo['pdist-minkowski-5.8-iris']
|
| 1075 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=5.8)
|
| 1076 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1077 |
+
|
| 1078 |
+
@pytest.mark.slow
|
| 1079 |
+
def test_pdist_minkowski_5_8_iris_float32(self):
|
| 1080 |
+
eps = 1e-5
|
| 1081 |
+
X = np.float32(eo['iris'])
|
| 1082 |
+
Y_right = eo['pdist-minkowski-5.8-iris']
|
| 1083 |
+
Y_test1 = wpdist_no_const(X, 'minkowski', p=5.8)
|
| 1084 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 1085 |
+
|
| 1086 |
+
@pytest.mark.slow
|
| 1087 |
+
def test_pdist_minkowski_5_8_iris_nonC(self):
|
| 1088 |
+
eps = 1e-7
|
| 1089 |
+
X = eo['iris']
|
| 1090 |
+
Y_right = eo['pdist-minkowski-5.8-iris']
|
| 1091 |
+
Y_test2 = wpdist_no_const(X, 'test_minkowski', p=5.8)
|
| 1092 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1093 |
+
|
| 1094 |
+
def test_pdist_mahalanobis(self):
|
| 1095 |
+
# 1-dimensional observations
|
| 1096 |
+
x = np.array([2.0, 2.0, 3.0, 5.0]).reshape(-1, 1)
|
| 1097 |
+
dist = pdist(x, metric='mahalanobis')
|
| 1098 |
+
assert_allclose(dist, [0.0, np.sqrt(0.5), np.sqrt(4.5),
|
| 1099 |
+
np.sqrt(0.5), np.sqrt(4.5), np.sqrt(2.0)])
|
| 1100 |
+
|
| 1101 |
+
# 2-dimensional observations
|
| 1102 |
+
x = np.array([[0, 0], [-1, 0], [0, 2], [1, 0], [0, -2]])
|
| 1103 |
+
dist = pdist(x, metric='mahalanobis')
|
| 1104 |
+
rt2 = np.sqrt(2)
|
| 1105 |
+
assert_allclose(dist, [rt2, rt2, rt2, rt2, 2, 2 * rt2, 2, 2, 2 * rt2, 2])
|
| 1106 |
+
|
| 1107 |
+
# Too few observations
|
| 1108 |
+
with pytest.raises(ValueError):
|
| 1109 |
+
wpdist([[0, 1], [2, 3]], metric='mahalanobis')
|
| 1110 |
+
|
| 1111 |
+
def test_pdist_hamming_random(self):
|
| 1112 |
+
eps = 1e-15
|
| 1113 |
+
X = eo['pdist-boolean-inp']
|
| 1114 |
+
Y_right = eo['pdist-hamming']
|
| 1115 |
+
Y_test1 = wpdist(X, 'hamming')
|
| 1116 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1117 |
+
|
| 1118 |
+
def test_pdist_hamming_random_float32(self):
|
| 1119 |
+
eps = 1e-15
|
| 1120 |
+
X = np.float32(eo['pdist-boolean-inp'])
|
| 1121 |
+
Y_right = eo['pdist-hamming']
|
| 1122 |
+
Y_test1 = wpdist(X, 'hamming')
|
| 1123 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1124 |
+
|
| 1125 |
+
def test_pdist_hamming_random_nonC(self):
|
| 1126 |
+
eps = 1e-15
|
| 1127 |
+
X = eo['pdist-boolean-inp']
|
| 1128 |
+
Y_right = eo['pdist-hamming']
|
| 1129 |
+
Y_test2 = wpdist(X, 'test_hamming')
|
| 1130 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1131 |
+
|
| 1132 |
+
def test_pdist_dhamming_random(self):
|
| 1133 |
+
eps = 1e-15
|
| 1134 |
+
X = np.float64(eo['pdist-boolean-inp'])
|
| 1135 |
+
Y_right = eo['pdist-hamming']
|
| 1136 |
+
Y_test1 = wpdist(X, 'hamming')
|
| 1137 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1138 |
+
|
| 1139 |
+
def test_pdist_dhamming_random_float32(self):
|
| 1140 |
+
eps = 1e-15
|
| 1141 |
+
X = np.float32(eo['pdist-boolean-inp'])
|
| 1142 |
+
Y_right = eo['pdist-hamming']
|
| 1143 |
+
Y_test1 = wpdist(X, 'hamming')
|
| 1144 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1145 |
+
|
| 1146 |
+
def test_pdist_dhamming_random_nonC(self):
|
| 1147 |
+
eps = 1e-15
|
| 1148 |
+
X = np.float64(eo['pdist-boolean-inp'])
|
| 1149 |
+
Y_right = eo['pdist-hamming']
|
| 1150 |
+
Y_test2 = wpdist(X, 'test_hamming')
|
| 1151 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1152 |
+
|
| 1153 |
+
def test_pdist_jensenshannon_random(self):
|
| 1154 |
+
eps = 1e-11
|
| 1155 |
+
X = eo['pdist-double-inp']
|
| 1156 |
+
Y_right = eo['pdist-jensenshannon']
|
| 1157 |
+
Y_test1 = pdist(X, 'jensenshannon')
|
| 1158 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1159 |
+
|
| 1160 |
+
def test_pdist_jensenshannon_random_float32(self):
|
| 1161 |
+
eps = 1e-8
|
| 1162 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 1163 |
+
Y_right = eo['pdist-jensenshannon']
|
| 1164 |
+
Y_test1 = pdist(X, 'jensenshannon')
|
| 1165 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 1166 |
+
|
| 1167 |
+
def test_pdist_jensenshannon_random_nonC(self):
|
| 1168 |
+
eps = 1e-11
|
| 1169 |
+
X = eo['pdist-double-inp']
|
| 1170 |
+
Y_right = eo['pdist-jensenshannon']
|
| 1171 |
+
Y_test2 = pdist(X, 'test_jensenshannon')
|
| 1172 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1173 |
+
|
| 1174 |
+
def test_pdist_jensenshannon_iris(self):
|
| 1175 |
+
if _is_32bit():
|
| 1176 |
+
# Test failing on 32-bit Linux on Azure otherwise, see gh-12810
|
| 1177 |
+
eps = 2.5e-10
|
| 1178 |
+
else:
|
| 1179 |
+
eps = 1e-12
|
| 1180 |
+
|
| 1181 |
+
X = eo['iris']
|
| 1182 |
+
Y_right = eo['pdist-jensenshannon-iris']
|
| 1183 |
+
Y_test1 = pdist(X, 'jensenshannon')
|
| 1184 |
+
assert_allclose(Y_test1, Y_right, atol=eps)
|
| 1185 |
+
|
| 1186 |
+
def test_pdist_jensenshannon_iris_float32(self):
|
| 1187 |
+
eps = 1e-06
|
| 1188 |
+
X = np.float32(eo['iris'])
|
| 1189 |
+
Y_right = eo['pdist-jensenshannon-iris']
|
| 1190 |
+
Y_test1 = pdist(X, 'jensenshannon')
|
| 1191 |
+
assert_allclose(Y_test1, Y_right, atol=eps, verbose=verbose > 2)
|
| 1192 |
+
|
| 1193 |
+
def test_pdist_jensenshannon_iris_nonC(self):
|
| 1194 |
+
eps = 5e-5
|
| 1195 |
+
X = eo['iris']
|
| 1196 |
+
Y_right = eo['pdist-jensenshannon-iris']
|
| 1197 |
+
Y_test2 = pdist(X, 'test_jensenshannon')
|
| 1198 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 1199 |
+
|
| 1200 |
+
def test_pdist_matching_mtica1(self):
|
| 1201 |
+
# Test matching(*,*) with mtica example #1 (nums).
|
| 1202 |
+
m = wmatching(np.array([1, 0, 1, 1, 0]),
|
| 1203 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1204 |
+
m2 = wmatching(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1205 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1206 |
+
assert_allclose(m, 0.6, rtol=0, atol=1e-10)
|
| 1207 |
+
assert_allclose(m2, 0.6, rtol=0, atol=1e-10)
|
| 1208 |
+
|
| 1209 |
+
def test_pdist_matching_mtica2(self):
|
| 1210 |
+
# Test matching(*,*) with mtica example #2.
|
| 1211 |
+
m = wmatching(np.array([1, 0, 1]),
|
| 1212 |
+
np.array([1, 1, 0]))
|
| 1213 |
+
m2 = wmatching(np.array([1, 0, 1], dtype=bool),
|
| 1214 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1215 |
+
assert_allclose(m, 2 / 3, rtol=0, atol=1e-10)
|
| 1216 |
+
assert_allclose(m2, 2 / 3, rtol=0, atol=1e-10)
|
| 1217 |
+
|
| 1218 |
+
def test_pdist_yule_mtica1(self):
|
| 1219 |
+
m = wyule(np.array([1, 0, 1, 1, 0]),
|
| 1220 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1221 |
+
m2 = wyule(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1222 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1223 |
+
if verbose > 2:
|
| 1224 |
+
print(m)
|
| 1225 |
+
assert_allclose(m, 2, rtol=0, atol=1e-10)
|
| 1226 |
+
assert_allclose(m2, 2, rtol=0, atol=1e-10)
|
| 1227 |
+
|
| 1228 |
+
def test_pdist_yule_mtica2(self):
|
| 1229 |
+
m = wyule(np.array([1, 0, 1]),
|
| 1230 |
+
np.array([1, 1, 0]))
|
| 1231 |
+
m2 = wyule(np.array([1, 0, 1], dtype=bool),
|
| 1232 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1233 |
+
if verbose > 2:
|
| 1234 |
+
print(m)
|
| 1235 |
+
assert_allclose(m, 2, rtol=0, atol=1e-10)
|
| 1236 |
+
assert_allclose(m2, 2, rtol=0, atol=1e-10)
|
| 1237 |
+
|
| 1238 |
+
def test_pdist_dice_mtica1(self):
|
| 1239 |
+
m = wdice(np.array([1, 0, 1, 1, 0]),
|
| 1240 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1241 |
+
m2 = wdice(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1242 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1243 |
+
if verbose > 2:
|
| 1244 |
+
print(m)
|
| 1245 |
+
assert_allclose(m, 3 / 7, rtol=0, atol=1e-10)
|
| 1246 |
+
assert_allclose(m2, 3 / 7, rtol=0, atol=1e-10)
|
| 1247 |
+
|
| 1248 |
+
def test_pdist_dice_mtica2(self):
|
| 1249 |
+
m = wdice(np.array([1, 0, 1]),
|
| 1250 |
+
np.array([1, 1, 0]))
|
| 1251 |
+
m2 = wdice(np.array([1, 0, 1], dtype=bool),
|
| 1252 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1253 |
+
if verbose > 2:
|
| 1254 |
+
print(m)
|
| 1255 |
+
assert_allclose(m, 0.5, rtol=0, atol=1e-10)
|
| 1256 |
+
assert_allclose(m2, 0.5, rtol=0, atol=1e-10)
|
| 1257 |
+
|
| 1258 |
+
def test_pdist_sokalsneath_mtica1(self):
|
| 1259 |
+
m = sokalsneath(np.array([1, 0, 1, 1, 0]),
|
| 1260 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1261 |
+
m2 = sokalsneath(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1262 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1263 |
+
if verbose > 2:
|
| 1264 |
+
print(m)
|
| 1265 |
+
assert_allclose(m, 3 / 4, rtol=0, atol=1e-10)
|
| 1266 |
+
assert_allclose(m2, 3 / 4, rtol=0, atol=1e-10)
|
| 1267 |
+
|
| 1268 |
+
def test_pdist_sokalsneath_mtica2(self):
|
| 1269 |
+
m = wsokalsneath(np.array([1, 0, 1]),
|
| 1270 |
+
np.array([1, 1, 0]))
|
| 1271 |
+
m2 = wsokalsneath(np.array([1, 0, 1], dtype=bool),
|
| 1272 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1273 |
+
if verbose > 2:
|
| 1274 |
+
print(m)
|
| 1275 |
+
assert_allclose(m, 4 / 5, rtol=0, atol=1e-10)
|
| 1276 |
+
assert_allclose(m2, 4 / 5, rtol=0, atol=1e-10)
|
| 1277 |
+
|
| 1278 |
+
def test_pdist_rogerstanimoto_mtica1(self):
|
| 1279 |
+
m = wrogerstanimoto(np.array([1, 0, 1, 1, 0]),
|
| 1280 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1281 |
+
m2 = wrogerstanimoto(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1282 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1283 |
+
if verbose > 2:
|
| 1284 |
+
print(m)
|
| 1285 |
+
assert_allclose(m, 3 / 4, rtol=0, atol=1e-10)
|
| 1286 |
+
assert_allclose(m2, 3 / 4, rtol=0, atol=1e-10)
|
| 1287 |
+
|
| 1288 |
+
def test_pdist_rogerstanimoto_mtica2(self):
|
| 1289 |
+
m = wrogerstanimoto(np.array([1, 0, 1]),
|
| 1290 |
+
np.array([1, 1, 0]))
|
| 1291 |
+
m2 = wrogerstanimoto(np.array([1, 0, 1], dtype=bool),
|
| 1292 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1293 |
+
if verbose > 2:
|
| 1294 |
+
print(m)
|
| 1295 |
+
assert_allclose(m, 4 / 5, rtol=0, atol=1e-10)
|
| 1296 |
+
assert_allclose(m2, 4 / 5, rtol=0, atol=1e-10)
|
| 1297 |
+
|
| 1298 |
+
def test_pdist_russellrao_mtica1(self):
|
| 1299 |
+
m = wrussellrao(np.array([1, 0, 1, 1, 0]),
|
| 1300 |
+
np.array([1, 1, 0, 1, 1]))
|
| 1301 |
+
m2 = wrussellrao(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 1302 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 1303 |
+
if verbose > 2:
|
| 1304 |
+
print(m)
|
| 1305 |
+
assert_allclose(m, 3 / 5, rtol=0, atol=1e-10)
|
| 1306 |
+
assert_allclose(m2, 3 / 5, rtol=0, atol=1e-10)
|
| 1307 |
+
|
| 1308 |
+
def test_pdist_russellrao_mtica2(self):
|
| 1309 |
+
m = wrussellrao(np.array([1, 0, 1]),
|
| 1310 |
+
np.array([1, 1, 0]))
|
| 1311 |
+
m2 = wrussellrao(np.array([1, 0, 1], dtype=bool),
|
| 1312 |
+
np.array([1, 1, 0], dtype=bool))
|
| 1313 |
+
if verbose > 2:
|
| 1314 |
+
print(m)
|
| 1315 |
+
assert_allclose(m, 2 / 3, rtol=0, atol=1e-10)
|
| 1316 |
+
assert_allclose(m2, 2 / 3, rtol=0, atol=1e-10)
|
| 1317 |
+
|
| 1318 |
+
@pytest.mark.slow
|
| 1319 |
+
def test_pdist_canberra_match(self):
|
| 1320 |
+
D = eo['iris']
|
| 1321 |
+
if verbose > 2:
|
| 1322 |
+
print(D.shape, D.dtype)
|
| 1323 |
+
eps = 1e-15
|
| 1324 |
+
y1 = wpdist_no_const(D, "canberra")
|
| 1325 |
+
y2 = wpdist_no_const(D, "test_canberra")
|
| 1326 |
+
assert_allclose(y1, y2, rtol=eps, verbose=verbose > 2)
|
| 1327 |
+
|
| 1328 |
+
def test_pdist_canberra_ticket_711(self):
|
| 1329 |
+
# Test pdist(X, 'canberra') to see if Canberra gives the right result
|
| 1330 |
+
# as reported on gh-1238.
|
| 1331 |
+
eps = 1e-8
|
| 1332 |
+
pdist_y = wpdist_no_const(([3.3], [3.4]), "canberra")
|
| 1333 |
+
right_y = 0.01492537
|
| 1334 |
+
assert_allclose(pdist_y, right_y, atol=eps, verbose=verbose > 2)
|
| 1335 |
+
|
| 1336 |
+
@skip_xp_invalid_arg
|
| 1337 |
+
def test_pdist_custom_notdouble(self):
|
| 1338 |
+
# tests that when using a custom metric the data type is not altered
|
| 1339 |
+
class myclass:
|
| 1340 |
+
pass
|
| 1341 |
+
|
| 1342 |
+
def _my_metric(x, y):
|
| 1343 |
+
if not isinstance(x[0], myclass) or not isinstance(y[0], myclass):
|
| 1344 |
+
raise ValueError("Type has been changed")
|
| 1345 |
+
return 1.123
|
| 1346 |
+
data = np.array([[myclass()], [myclass()]], dtype=object)
|
| 1347 |
+
pdist_y = pdist(data, metric=_my_metric)
|
| 1348 |
+
right_y = 1.123
|
| 1349 |
+
assert_equal(pdist_y, right_y, verbose=verbose > 2)
|
| 1350 |
+
|
| 1351 |
+
def _check_calling_conventions(self, X, metric, eps=1e-07, **kwargs):
|
| 1352 |
+
# helper function for test_pdist_calling_conventions
|
| 1353 |
+
try:
|
| 1354 |
+
y1 = pdist(X, metric=metric, **kwargs)
|
| 1355 |
+
y2 = pdist(X, metric=eval(metric), **kwargs)
|
| 1356 |
+
y3 = pdist(X, metric="test_" + metric, **kwargs)
|
| 1357 |
+
except Exception as e:
|
| 1358 |
+
e_cls = e.__class__
|
| 1359 |
+
if verbose > 2:
|
| 1360 |
+
print(e_cls.__name__)
|
| 1361 |
+
print(e)
|
| 1362 |
+
with pytest.raises(e_cls):
|
| 1363 |
+
pdist(X, metric=metric, **kwargs)
|
| 1364 |
+
with pytest.raises(e_cls):
|
| 1365 |
+
pdist(X, metric=eval(metric), **kwargs)
|
| 1366 |
+
with pytest.raises(e_cls):
|
| 1367 |
+
pdist(X, metric="test_" + metric, **kwargs)
|
| 1368 |
+
else:
|
| 1369 |
+
assert_allclose(y1, y2, rtol=eps, verbose=verbose > 2)
|
| 1370 |
+
assert_allclose(y1, y3, rtol=eps, verbose=verbose > 2)
|
| 1371 |
+
|
| 1372 |
+
def test_pdist_calling_conventions(self, metric):
|
| 1373 |
+
# Ensures that specifying the metric with a str or scipy function
|
| 1374 |
+
# gives the same behaviour (i.e. same result or same exception).
|
| 1375 |
+
# NOTE: The correctness should be checked within each metric tests.
|
| 1376 |
+
# NOTE: Extra args should be checked with a dedicated test
|
| 1377 |
+
for eo_name in self.rnd_eo_names:
|
| 1378 |
+
# subsampling input data to speed-up tests
|
| 1379 |
+
# NOTE: num samples needs to be > than dimensions for mahalanobis
|
| 1380 |
+
X = eo[eo_name][::5, ::2]
|
| 1381 |
+
if verbose > 2:
|
| 1382 |
+
print("testing: ", metric, " with: ", eo_name)
|
| 1383 |
+
if metric in {'dice', 'yule', 'matching', 'rogerstanimoto', 'russellrao',
|
| 1384 |
+
'sokalsneath'} and 'bool' not in eo_name:
|
| 1385 |
+
# python version permits non-bools e.g. for fuzzy logic
|
| 1386 |
+
continue
|
| 1387 |
+
self._check_calling_conventions(X, metric)
|
| 1388 |
+
|
| 1389 |
+
# Testing built-in metrics with extra args
|
| 1390 |
+
if metric == "seuclidean":
|
| 1391 |
+
V = np.var(X.astype(np.float64), axis=0, ddof=1)
|
| 1392 |
+
self._check_calling_conventions(X, metric, V=V)
|
| 1393 |
+
elif metric == "mahalanobis":
|
| 1394 |
+
V = np.atleast_2d(np.cov(X.astype(np.float64).T))
|
| 1395 |
+
VI = np.array(np.linalg.inv(V).T)
|
| 1396 |
+
self._check_calling_conventions(X, metric, VI=VI)
|
| 1397 |
+
|
| 1398 |
+
def test_pdist_dtype_equivalence(self, metric):
|
| 1399 |
+
# Tests that the result is not affected by type up-casting
|
| 1400 |
+
eps = 1e-07
|
| 1401 |
+
tests = [(eo['random-bool-data'], self.valid_upcasts['bool']),
|
| 1402 |
+
(eo['random-uint-data'], self.valid_upcasts['uint']),
|
| 1403 |
+
(eo['random-int-data'], self.valid_upcasts['int']),
|
| 1404 |
+
(eo['random-float32-data'], self.valid_upcasts['float32'])]
|
| 1405 |
+
for test in tests:
|
| 1406 |
+
X1 = test[0][::5, ::2]
|
| 1407 |
+
try:
|
| 1408 |
+
y1 = pdist(X1, metric=metric)
|
| 1409 |
+
except Exception as e:
|
| 1410 |
+
e_cls = e.__class__
|
| 1411 |
+
if verbose > 2:
|
| 1412 |
+
print(e_cls.__name__)
|
| 1413 |
+
print(e)
|
| 1414 |
+
for new_type in test[1]:
|
| 1415 |
+
X2 = new_type(X1)
|
| 1416 |
+
with pytest.raises(e_cls):
|
| 1417 |
+
pdist(X2, metric=metric)
|
| 1418 |
+
else:
|
| 1419 |
+
for new_type in test[1]:
|
| 1420 |
+
y2 = pdist(new_type(X1), metric=metric)
|
| 1421 |
+
assert_allclose(y1, y2, rtol=eps, verbose=verbose > 2)
|
| 1422 |
+
|
| 1423 |
+
def test_pdist_out(self, metric):
|
| 1424 |
+
# Test that out parameter works properly
|
| 1425 |
+
eps = 1e-15
|
| 1426 |
+
X = eo['random-float32-data'][::5, ::2]
|
| 1427 |
+
out_size = int((X.shape[0] * (X.shape[0] - 1)) / 2)
|
| 1428 |
+
|
| 1429 |
+
kwargs = dict()
|
| 1430 |
+
if metric == 'minkowski':
|
| 1431 |
+
kwargs['p'] = 1.23
|
| 1432 |
+
out1 = np.empty(out_size, dtype=np.float64)
|
| 1433 |
+
Y_right = pdist(X, metric, **kwargs)
|
| 1434 |
+
Y_test1 = pdist(X, metric, out=out1, **kwargs)
|
| 1435 |
+
|
| 1436 |
+
# test that output is numerically equivalent
|
| 1437 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 1438 |
+
|
| 1439 |
+
# test that Y_test1 and out1 are the same object
|
| 1440 |
+
assert_(Y_test1 is out1)
|
| 1441 |
+
|
| 1442 |
+
# test for incorrect shape
|
| 1443 |
+
out2 = np.empty(out_size + 3, dtype=np.float64)
|
| 1444 |
+
with pytest.raises(ValueError):
|
| 1445 |
+
pdist(X, metric, out=out2, **kwargs)
|
| 1446 |
+
|
| 1447 |
+
# test for (C-)contiguous output
|
| 1448 |
+
out3 = np.empty(2 * out_size, dtype=np.float64)[::2]
|
| 1449 |
+
with pytest.raises(ValueError):
|
| 1450 |
+
pdist(X, metric, out=out3, **kwargs)
|
| 1451 |
+
|
| 1452 |
+
# test for incorrect dtype
|
| 1453 |
+
out5 = np.empty(out_size, dtype=np.int64)
|
| 1454 |
+
with pytest.raises(ValueError):
|
| 1455 |
+
pdist(X, metric, out=out5, **kwargs)
|
| 1456 |
+
|
| 1457 |
+
def test_striding(self, metric):
|
| 1458 |
+
# test that striding is handled correct with calls to
|
| 1459 |
+
# _copy_array_if_base_present
|
| 1460 |
+
eps = 1e-15
|
| 1461 |
+
X = eo['random-float32-data'][::5, ::2]
|
| 1462 |
+
X_copy = X.copy()
|
| 1463 |
+
|
| 1464 |
+
# confirm contiguity
|
| 1465 |
+
assert_(not X.flags.c_contiguous)
|
| 1466 |
+
assert_(X_copy.flags.c_contiguous)
|
| 1467 |
+
|
| 1468 |
+
kwargs = dict()
|
| 1469 |
+
if metric == 'minkowski':
|
| 1470 |
+
kwargs['p'] = 1.23
|
| 1471 |
+
Y1 = pdist(X, metric, **kwargs)
|
| 1472 |
+
Y2 = pdist(X_copy, metric, **kwargs)
|
| 1473 |
+
# test that output is numerically equivalent
|
| 1474 |
+
assert_allclose(Y1, Y2, rtol=eps, verbose=verbose > 2)
|
| 1475 |
+
|
| 1476 |
+
class TestSomeDistanceFunctions:
|
| 1477 |
+
|
| 1478 |
+
def setup_method(self):
|
| 1479 |
+
# 1D arrays
|
| 1480 |
+
x = np.array([1.0, 2.0, 3.0])
|
| 1481 |
+
y = np.array([1.0, 1.0, 5.0])
|
| 1482 |
+
|
| 1483 |
+
self.cases = [(x, y)]
|
| 1484 |
+
|
| 1485 |
+
def test_minkowski(self):
|
| 1486 |
+
for x, y in self.cases:
|
| 1487 |
+
dist1 = minkowski(x, y, p=1)
|
| 1488 |
+
assert_almost_equal(dist1, 3.0)
|
| 1489 |
+
dist1p5 = minkowski(x, y, p=1.5)
|
| 1490 |
+
assert_almost_equal(dist1p5, (1.0 + 2.0**1.5)**(2. / 3))
|
| 1491 |
+
dist2 = minkowski(x, y, p=2)
|
| 1492 |
+
assert_almost_equal(dist2, 5.0 ** 0.5)
|
| 1493 |
+
dist0p25 = minkowski(x, y, p=0.25)
|
| 1494 |
+
assert_almost_equal(dist0p25, (1.0 + 2.0 ** 0.25) ** 4)
|
| 1495 |
+
|
| 1496 |
+
# Check that casting input to minimum scalar type doesn't affect result
|
| 1497 |
+
# (issue #10262). This could be extended to more test inputs with
|
| 1498 |
+
# np.min_scalar_type(np.max(input_matrix)).
|
| 1499 |
+
a = np.array([352, 916])
|
| 1500 |
+
b = np.array([350, 660])
|
| 1501 |
+
assert_equal(minkowski(a, b),
|
| 1502 |
+
minkowski(a.astype('uint16'), b.astype('uint16')))
|
| 1503 |
+
|
| 1504 |
+
def test_euclidean(self):
|
| 1505 |
+
for x, y in self.cases:
|
| 1506 |
+
dist = weuclidean(x, y)
|
| 1507 |
+
assert_almost_equal(dist, np.sqrt(5))
|
| 1508 |
+
|
| 1509 |
+
def test_sqeuclidean(self):
|
| 1510 |
+
for x, y in self.cases:
|
| 1511 |
+
dist = wsqeuclidean(x, y)
|
| 1512 |
+
assert_almost_equal(dist, 5.0)
|
| 1513 |
+
|
| 1514 |
+
def test_cosine(self):
|
| 1515 |
+
for x, y in self.cases:
|
| 1516 |
+
dist = wcosine(x, y)
|
| 1517 |
+
assert_almost_equal(dist, 1.0 - 18.0 / (np.sqrt(14) * np.sqrt(27)))
|
| 1518 |
+
|
| 1519 |
+
def test_cosine_output_dtype(self):
|
| 1520 |
+
# Regression test for gh-19541
|
| 1521 |
+
assert isinstance(wcorrelation([1, 1], [1, 1], centered=False), float)
|
| 1522 |
+
assert isinstance(wcosine([1, 1], [1, 1]), float)
|
| 1523 |
+
|
| 1524 |
+
def test_correlation(self):
|
| 1525 |
+
xm = np.array([-1.0, 0, 1.0])
|
| 1526 |
+
ym = np.array([-4.0 / 3, -4.0 / 3, 5.0 - 7.0 / 3])
|
| 1527 |
+
for x, y in self.cases:
|
| 1528 |
+
dist = wcorrelation(x, y)
|
| 1529 |
+
assert_almost_equal(dist, 1.0 - np.dot(xm, ym) / (norm(xm) * norm(ym)))
|
| 1530 |
+
|
| 1531 |
+
def test_correlation_positive(self):
|
| 1532 |
+
# Regression test for gh-12320 (negative return value due to rounding
|
| 1533 |
+
x = np.array([0., 0., 0., 0., 0., 0., -2., 0., 0., 0., -2., -2., -2.,
|
| 1534 |
+
0., -2., 0., -2., 0., 0., -1., -2., 0., 1., 0., 0., -2.,
|
| 1535 |
+
0., 0., -2., 0., -2., -2., -2., -2., -2., -2., 0.])
|
| 1536 |
+
y = np.array([1., 1., 1., 1., 1., 1., -1., 1., 1., 1., -1., -1., -1.,
|
| 1537 |
+
1., -1., 1., -1., 1., 1., 0., -1., 1., 2., 1., 1., -1.,
|
| 1538 |
+
1., 1., -1., 1., -1., -1., -1., -1., -1., -1., 1.])
|
| 1539 |
+
dist = correlation(x, y)
|
| 1540 |
+
assert 0 <= dist <= 10 * np.finfo(np.float64).eps
|
| 1541 |
+
|
| 1542 |
+
@pytest.mark.filterwarnings('ignore:Casting complex')
|
| 1543 |
+
@pytest.mark.parametrize("func", [correlation, cosine])
|
| 1544 |
+
def test_corr_dep_complex(self, func):
|
| 1545 |
+
x = [1+0j, 2+0j]
|
| 1546 |
+
y = [3+0j, 4+0j]
|
| 1547 |
+
with pytest.raises(TypeError, match="real"):
|
| 1548 |
+
func(x, y)
|
| 1549 |
+
|
| 1550 |
+
def test_mahalanobis(self):
|
| 1551 |
+
x = np.array([1.0, 2.0, 3.0])
|
| 1552 |
+
y = np.array([1.0, 1.0, 5.0])
|
| 1553 |
+
vi = np.array([[2.0, 1.0, 0.0], [1.0, 2.0, 1.0], [0.0, 1.0, 2.0]])
|
| 1554 |
+
for x, y in self.cases:
|
| 1555 |
+
dist = mahalanobis(x, y, vi)
|
| 1556 |
+
assert_almost_equal(dist, np.sqrt(6.0))
|
| 1557 |
+
|
| 1558 |
+
|
| 1559 |
+
class TestSquareForm:
|
| 1560 |
+
checked_dtypes = [np.float64, np.float32, np.int32, np.int8, bool]
|
| 1561 |
+
|
| 1562 |
+
def test_squareform_matrix(self):
|
| 1563 |
+
for dtype in self.checked_dtypes:
|
| 1564 |
+
self.check_squareform_matrix(dtype)
|
| 1565 |
+
|
| 1566 |
+
def test_squareform_vector(self):
|
| 1567 |
+
for dtype in self.checked_dtypes:
|
| 1568 |
+
self.check_squareform_vector(dtype)
|
| 1569 |
+
|
| 1570 |
+
def check_squareform_matrix(self, dtype):
|
| 1571 |
+
A = np.zeros((0, 0), dtype=dtype)
|
| 1572 |
+
rA = squareform(A)
|
| 1573 |
+
assert_equal(rA.shape, (0,))
|
| 1574 |
+
assert_equal(rA.dtype, dtype)
|
| 1575 |
+
|
| 1576 |
+
A = np.zeros((1, 1), dtype=dtype)
|
| 1577 |
+
rA = squareform(A)
|
| 1578 |
+
assert_equal(rA.shape, (0,))
|
| 1579 |
+
assert_equal(rA.dtype, dtype)
|
| 1580 |
+
|
| 1581 |
+
A = np.array([[0, 4.2], [4.2, 0]], dtype=dtype)
|
| 1582 |
+
rA = squareform(A)
|
| 1583 |
+
assert_equal(rA.shape, (1,))
|
| 1584 |
+
assert_equal(rA.dtype, dtype)
|
| 1585 |
+
assert_array_equal(rA, np.array([4.2], dtype=dtype))
|
| 1586 |
+
|
| 1587 |
+
def check_squareform_vector(self, dtype):
|
| 1588 |
+
v = np.zeros((0,), dtype=dtype)
|
| 1589 |
+
rv = squareform(v)
|
| 1590 |
+
assert_equal(rv.shape, (1, 1))
|
| 1591 |
+
assert_equal(rv.dtype, dtype)
|
| 1592 |
+
assert_array_equal(rv, [[0]])
|
| 1593 |
+
|
| 1594 |
+
v = np.array([8.3], dtype=dtype)
|
| 1595 |
+
rv = squareform(v)
|
| 1596 |
+
assert_equal(rv.shape, (2, 2))
|
| 1597 |
+
assert_equal(rv.dtype, dtype)
|
| 1598 |
+
assert_array_equal(rv, np.array([[0, 8.3], [8.3, 0]], dtype=dtype))
|
| 1599 |
+
|
| 1600 |
+
def test_squareform_multi_matrix(self):
|
| 1601 |
+
for n in range(2, 5):
|
| 1602 |
+
self.check_squareform_multi_matrix(n)
|
| 1603 |
+
|
| 1604 |
+
def check_squareform_multi_matrix(self, n):
|
| 1605 |
+
X = np.random.rand(n, 4)
|
| 1606 |
+
Y = wpdist_no_const(X)
|
| 1607 |
+
assert_equal(len(Y.shape), 1)
|
| 1608 |
+
A = squareform(Y)
|
| 1609 |
+
Yr = squareform(A)
|
| 1610 |
+
s = A.shape
|
| 1611 |
+
k = 0
|
| 1612 |
+
if verbose >= 3:
|
| 1613 |
+
print(A.shape, Y.shape, Yr.shape)
|
| 1614 |
+
assert_equal(len(s), 2)
|
| 1615 |
+
assert_equal(len(Yr.shape), 1)
|
| 1616 |
+
assert_equal(s[0], s[1])
|
| 1617 |
+
for i in range(0, s[0]):
|
| 1618 |
+
for j in range(i + 1, s[1]):
|
| 1619 |
+
if i != j:
|
| 1620 |
+
assert_equal(A[i, j], Y[k])
|
| 1621 |
+
k += 1
|
| 1622 |
+
else:
|
| 1623 |
+
assert_equal(A[i, j], 0)
|
| 1624 |
+
|
| 1625 |
+
|
| 1626 |
+
class TestNumObsY:
|
| 1627 |
+
|
| 1628 |
+
def test_num_obs_y_multi_matrix(self):
|
| 1629 |
+
for n in range(2, 10):
|
| 1630 |
+
X = np.random.rand(n, 4)
|
| 1631 |
+
Y = wpdist_no_const(X)
|
| 1632 |
+
assert_equal(num_obs_y(Y), n)
|
| 1633 |
+
|
| 1634 |
+
def test_num_obs_y_1(self):
|
| 1635 |
+
# Tests num_obs_y(y) on a condensed distance matrix over 1
|
| 1636 |
+
# observations. Expecting exception.
|
| 1637 |
+
with pytest.raises(ValueError):
|
| 1638 |
+
self.check_y(1)
|
| 1639 |
+
|
| 1640 |
+
def test_num_obs_y_2(self):
|
| 1641 |
+
# Tests num_obs_y(y) on a condensed distance matrix over 2
|
| 1642 |
+
# observations.
|
| 1643 |
+
assert_(self.check_y(2))
|
| 1644 |
+
|
| 1645 |
+
def test_num_obs_y_3(self):
|
| 1646 |
+
assert_(self.check_y(3))
|
| 1647 |
+
|
| 1648 |
+
def test_num_obs_y_4(self):
|
| 1649 |
+
assert_(self.check_y(4))
|
| 1650 |
+
|
| 1651 |
+
def test_num_obs_y_5_10(self):
|
| 1652 |
+
for i in range(5, 16):
|
| 1653 |
+
self.minit(i)
|
| 1654 |
+
|
| 1655 |
+
def test_num_obs_y_2_100(self):
|
| 1656 |
+
# Tests num_obs_y(y) on 100 improper condensed distance matrices.
|
| 1657 |
+
# Expecting exception.
|
| 1658 |
+
a = set()
|
| 1659 |
+
for n in range(2, 16):
|
| 1660 |
+
a.add(n * (n - 1) / 2)
|
| 1661 |
+
for i in range(5, 105):
|
| 1662 |
+
if i not in a:
|
| 1663 |
+
with pytest.raises(ValueError):
|
| 1664 |
+
self.bad_y(i)
|
| 1665 |
+
|
| 1666 |
+
def minit(self, n):
|
| 1667 |
+
assert_(self.check_y(n))
|
| 1668 |
+
|
| 1669 |
+
def bad_y(self, n):
|
| 1670 |
+
y = np.random.rand(n)
|
| 1671 |
+
return num_obs_y(y)
|
| 1672 |
+
|
| 1673 |
+
def check_y(self, n):
|
| 1674 |
+
return num_obs_y(self.make_y(n)) == n
|
| 1675 |
+
|
| 1676 |
+
def make_y(self, n):
|
| 1677 |
+
return np.random.rand((n * (n - 1)) // 2)
|
| 1678 |
+
|
| 1679 |
+
|
| 1680 |
+
class TestNumObsDM:
|
| 1681 |
+
|
| 1682 |
+
def test_num_obs_dm_multi_matrix(self):
|
| 1683 |
+
for n in range(1, 10):
|
| 1684 |
+
X = np.random.rand(n, 4)
|
| 1685 |
+
Y = wpdist_no_const(X)
|
| 1686 |
+
A = squareform(Y)
|
| 1687 |
+
if verbose >= 3:
|
| 1688 |
+
print(A.shape, Y.shape)
|
| 1689 |
+
assert_equal(num_obs_dm(A), n)
|
| 1690 |
+
|
| 1691 |
+
def test_num_obs_dm_0(self):
|
| 1692 |
+
# Tests num_obs_dm(D) on a 0x0 distance matrix. Expecting exception.
|
| 1693 |
+
assert_(self.check_D(0))
|
| 1694 |
+
|
| 1695 |
+
def test_num_obs_dm_1(self):
|
| 1696 |
+
# Tests num_obs_dm(D) on a 1x1 distance matrix.
|
| 1697 |
+
assert_(self.check_D(1))
|
| 1698 |
+
|
| 1699 |
+
def test_num_obs_dm_2(self):
|
| 1700 |
+
assert_(self.check_D(2))
|
| 1701 |
+
|
| 1702 |
+
def test_num_obs_dm_3(self):
|
| 1703 |
+
assert_(self.check_D(2))
|
| 1704 |
+
|
| 1705 |
+
def test_num_obs_dm_4(self):
|
| 1706 |
+
assert_(self.check_D(4))
|
| 1707 |
+
|
| 1708 |
+
def check_D(self, n):
|
| 1709 |
+
return num_obs_dm(self.make_D(n)) == n
|
| 1710 |
+
|
| 1711 |
+
def make_D(self, n):
|
| 1712 |
+
return np.random.rand(n, n)
|
| 1713 |
+
|
| 1714 |
+
|
| 1715 |
+
def is_valid_dm_throw(D):
|
| 1716 |
+
return is_valid_dm(D, throw=True)
|
| 1717 |
+
|
| 1718 |
+
|
| 1719 |
+
class TestIsValidDM:
|
| 1720 |
+
|
| 1721 |
+
def test_is_valid_dm_improper_shape_1D_E(self):
|
| 1722 |
+
D = np.zeros((5,), dtype=np.float64)
|
| 1723 |
+
with pytest.raises(ValueError):
|
| 1724 |
+
is_valid_dm_throw(D)
|
| 1725 |
+
|
| 1726 |
+
def test_is_valid_dm_improper_shape_1D_F(self):
|
| 1727 |
+
D = np.zeros((5,), dtype=np.float64)
|
| 1728 |
+
assert_equal(is_valid_dm(D), False)
|
| 1729 |
+
|
| 1730 |
+
def test_is_valid_dm_improper_shape_3D_E(self):
|
| 1731 |
+
D = np.zeros((3, 3, 3), dtype=np.float64)
|
| 1732 |
+
with pytest.raises(ValueError):
|
| 1733 |
+
is_valid_dm_throw(D)
|
| 1734 |
+
|
| 1735 |
+
def test_is_valid_dm_improper_shape_3D_F(self):
|
| 1736 |
+
D = np.zeros((3, 3, 3), dtype=np.float64)
|
| 1737 |
+
assert_equal(is_valid_dm(D), False)
|
| 1738 |
+
|
| 1739 |
+
def test_is_valid_dm_nonzero_diagonal_E(self):
|
| 1740 |
+
y = np.random.rand(10)
|
| 1741 |
+
D = squareform(y)
|
| 1742 |
+
for i in range(0, 5):
|
| 1743 |
+
D[i, i] = 2.0
|
| 1744 |
+
with pytest.raises(ValueError):
|
| 1745 |
+
is_valid_dm_throw(D)
|
| 1746 |
+
|
| 1747 |
+
def test_is_valid_dm_nonzero_diagonal_F(self):
|
| 1748 |
+
y = np.random.rand(10)
|
| 1749 |
+
D = squareform(y)
|
| 1750 |
+
for i in range(0, 5):
|
| 1751 |
+
D[i, i] = 2.0
|
| 1752 |
+
assert_equal(is_valid_dm(D), False)
|
| 1753 |
+
|
| 1754 |
+
def test_is_valid_dm_asymmetric_E(self):
|
| 1755 |
+
y = np.random.rand(10)
|
| 1756 |
+
D = squareform(y)
|
| 1757 |
+
D[1, 3] = D[3, 1] + 1
|
| 1758 |
+
with pytest.raises(ValueError):
|
| 1759 |
+
is_valid_dm_throw(D)
|
| 1760 |
+
|
| 1761 |
+
def test_is_valid_dm_asymmetric_F(self):
|
| 1762 |
+
y = np.random.rand(10)
|
| 1763 |
+
D = squareform(y)
|
| 1764 |
+
D[1, 3] = D[3, 1] + 1
|
| 1765 |
+
assert_equal(is_valid_dm(D), False)
|
| 1766 |
+
|
| 1767 |
+
def test_is_valid_dm_correct_1_by_1(self):
|
| 1768 |
+
D = np.zeros((1, 1), dtype=np.float64)
|
| 1769 |
+
assert_equal(is_valid_dm(D), True)
|
| 1770 |
+
|
| 1771 |
+
def test_is_valid_dm_correct_2_by_2(self):
|
| 1772 |
+
y = np.random.rand(1)
|
| 1773 |
+
D = squareform(y)
|
| 1774 |
+
assert_equal(is_valid_dm(D), True)
|
| 1775 |
+
|
| 1776 |
+
def test_is_valid_dm_correct_3_by_3(self):
|
| 1777 |
+
y = np.random.rand(3)
|
| 1778 |
+
D = squareform(y)
|
| 1779 |
+
assert_equal(is_valid_dm(D), True)
|
| 1780 |
+
|
| 1781 |
+
def test_is_valid_dm_correct_4_by_4(self):
|
| 1782 |
+
y = np.random.rand(6)
|
| 1783 |
+
D = squareform(y)
|
| 1784 |
+
assert_equal(is_valid_dm(D), True)
|
| 1785 |
+
|
| 1786 |
+
def test_is_valid_dm_correct_5_by_5(self):
|
| 1787 |
+
y = np.random.rand(10)
|
| 1788 |
+
D = squareform(y)
|
| 1789 |
+
assert_equal(is_valid_dm(D), True)
|
| 1790 |
+
|
| 1791 |
+
|
| 1792 |
+
def is_valid_y_throw(y):
|
| 1793 |
+
return is_valid_y(y, throw=True)
|
| 1794 |
+
|
| 1795 |
+
|
| 1796 |
+
class TestIsValidY:
|
| 1797 |
+
# If test case name ends on "_E" then an exception is expected for the
|
| 1798 |
+
# given input, if it ends in "_F" then False is expected for the is_valid_y
|
| 1799 |
+
# check. Otherwise the input is expected to be valid.
|
| 1800 |
+
|
| 1801 |
+
def test_is_valid_y_improper_shape_2D_E(self):
|
| 1802 |
+
y = np.zeros((3, 3,), dtype=np.float64)
|
| 1803 |
+
with pytest.raises(ValueError):
|
| 1804 |
+
is_valid_y_throw(y)
|
| 1805 |
+
|
| 1806 |
+
def test_is_valid_y_improper_shape_2D_F(self):
|
| 1807 |
+
y = np.zeros((3, 3,), dtype=np.float64)
|
| 1808 |
+
assert_equal(is_valid_y(y), False)
|
| 1809 |
+
|
| 1810 |
+
def test_is_valid_y_improper_shape_3D_E(self):
|
| 1811 |
+
y = np.zeros((3, 3, 3), dtype=np.float64)
|
| 1812 |
+
with pytest.raises(ValueError):
|
| 1813 |
+
is_valid_y_throw(y)
|
| 1814 |
+
|
| 1815 |
+
def test_is_valid_y_improper_shape_3D_F(self):
|
| 1816 |
+
y = np.zeros((3, 3, 3), dtype=np.float64)
|
| 1817 |
+
assert_equal(is_valid_y(y), False)
|
| 1818 |
+
|
| 1819 |
+
def test_is_valid_y_correct_2_by_2(self):
|
| 1820 |
+
y = self.correct_n_by_n(2)
|
| 1821 |
+
assert_equal(is_valid_y(y), True)
|
| 1822 |
+
|
| 1823 |
+
def test_is_valid_y_correct_3_by_3(self):
|
| 1824 |
+
y = self.correct_n_by_n(3)
|
| 1825 |
+
assert_equal(is_valid_y(y), True)
|
| 1826 |
+
|
| 1827 |
+
def test_is_valid_y_correct_4_by_4(self):
|
| 1828 |
+
y = self.correct_n_by_n(4)
|
| 1829 |
+
assert_equal(is_valid_y(y), True)
|
| 1830 |
+
|
| 1831 |
+
def test_is_valid_y_correct_5_by_5(self):
|
| 1832 |
+
y = self.correct_n_by_n(5)
|
| 1833 |
+
assert_equal(is_valid_y(y), True)
|
| 1834 |
+
|
| 1835 |
+
def test_is_valid_y_2_100(self):
|
| 1836 |
+
a = set()
|
| 1837 |
+
for n in range(2, 16):
|
| 1838 |
+
a.add(n * (n - 1) / 2)
|
| 1839 |
+
for i in range(5, 105):
|
| 1840 |
+
if i not in a:
|
| 1841 |
+
with pytest.raises(ValueError):
|
| 1842 |
+
self.bad_y(i)
|
| 1843 |
+
|
| 1844 |
+
def bad_y(self, n):
|
| 1845 |
+
y = np.random.rand(n)
|
| 1846 |
+
return is_valid_y(y, throw=True)
|
| 1847 |
+
|
| 1848 |
+
def correct_n_by_n(self, n):
|
| 1849 |
+
y = np.random.rand((n * (n - 1)) // 2)
|
| 1850 |
+
return y
|
| 1851 |
+
|
| 1852 |
+
|
| 1853 |
+
@pytest.mark.parametrize("p", [-10.0, -0.5, 0.0])
|
| 1854 |
+
def test_bad_p(p):
|
| 1855 |
+
# Raise ValueError if p <=0.
|
| 1856 |
+
with pytest.raises(ValueError):
|
| 1857 |
+
minkowski([1, 2], [3, 4], p)
|
| 1858 |
+
with pytest.raises(ValueError):
|
| 1859 |
+
minkowski([1, 2], [3, 4], p, [1, 1])
|
| 1860 |
+
|
| 1861 |
+
|
| 1862 |
+
def test_sokalsneath_all_false():
|
| 1863 |
+
# Regression test for ticket #876
|
| 1864 |
+
with pytest.raises(ValueError):
|
| 1865 |
+
sokalsneath([False, False, False], [False, False, False])
|
| 1866 |
+
|
| 1867 |
+
|
| 1868 |
+
def test_canberra():
|
| 1869 |
+
# Regression test for ticket #1430.
|
| 1870 |
+
assert_equal(wcanberra([1, 2, 3], [2, 4, 6]), 1)
|
| 1871 |
+
assert_equal(wcanberra([1, 1, 0, 0], [1, 0, 1, 0]), 2)
|
| 1872 |
+
|
| 1873 |
+
|
| 1874 |
+
def test_braycurtis():
|
| 1875 |
+
# Regression test for ticket #1430.
|
| 1876 |
+
assert_almost_equal(wbraycurtis([1, 2, 3], [2, 4, 6]), 1. / 3, decimal=15)
|
| 1877 |
+
assert_almost_equal(wbraycurtis([1, 1, 0, 0], [1, 0, 1, 0]), 0.5, decimal=15)
|
| 1878 |
+
|
| 1879 |
+
|
| 1880 |
+
def test_euclideans():
|
| 1881 |
+
# Regression test for ticket #1328.
|
| 1882 |
+
x1 = np.array([1, 1, 1])
|
| 1883 |
+
x2 = np.array([0, 0, 0])
|
| 1884 |
+
|
| 1885 |
+
# Basic test of the calculation.
|
| 1886 |
+
assert_almost_equal(wsqeuclidean(x1, x2), 3.0, decimal=14)
|
| 1887 |
+
assert_almost_equal(weuclidean(x1, x2), np.sqrt(3), decimal=14)
|
| 1888 |
+
|
| 1889 |
+
# Check flattening for (1, N) or (N, 1) inputs
|
| 1890 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 1891 |
+
weuclidean(x1[np.newaxis, :], x2[np.newaxis, :]), np.sqrt(3)
|
| 1892 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 1893 |
+
wsqeuclidean(x1[np.newaxis, :], x2[np.newaxis, :])
|
| 1894 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 1895 |
+
wsqeuclidean(x1[:, np.newaxis], x2[:, np.newaxis])
|
| 1896 |
+
|
| 1897 |
+
# Distance metrics only defined for vectors (= 1-D)
|
| 1898 |
+
x = np.arange(4).reshape(2, 2)
|
| 1899 |
+
with pytest.raises(ValueError):
|
| 1900 |
+
weuclidean(x, x)
|
| 1901 |
+
with pytest.raises(ValueError):
|
| 1902 |
+
wsqeuclidean(x, x)
|
| 1903 |
+
|
| 1904 |
+
# Another check, with random data.
|
| 1905 |
+
rs = np.random.RandomState(1234567890)
|
| 1906 |
+
x = rs.rand(10)
|
| 1907 |
+
y = rs.rand(10)
|
| 1908 |
+
d1 = weuclidean(x, y)
|
| 1909 |
+
d2 = wsqeuclidean(x, y)
|
| 1910 |
+
assert_almost_equal(d1**2, d2, decimal=14)
|
| 1911 |
+
|
| 1912 |
+
|
| 1913 |
+
def test_hamming_unequal_length():
|
| 1914 |
+
# Regression test for gh-4290.
|
| 1915 |
+
x = [0, 0, 1]
|
| 1916 |
+
y = [1, 0, 1, 0]
|
| 1917 |
+
# Used to give an AttributeError from ndarray.mean called on bool
|
| 1918 |
+
with pytest.raises(ValueError):
|
| 1919 |
+
whamming(x, y)
|
| 1920 |
+
|
| 1921 |
+
|
| 1922 |
+
def test_hamming_unequal_length_with_w():
|
| 1923 |
+
u = [0, 0, 1]
|
| 1924 |
+
v = [0, 0, 1]
|
| 1925 |
+
w = [1, 0, 1, 0]
|
| 1926 |
+
msg = "'w' should have the same length as 'u' and 'v'."
|
| 1927 |
+
with pytest.raises(ValueError, match=msg):
|
| 1928 |
+
whamming(u, v, w)
|
| 1929 |
+
|
| 1930 |
+
|
| 1931 |
+
def test_hamming_string_array():
|
| 1932 |
+
# https://github.com/scikit-learn/scikit-learn/issues/4014
|
| 1933 |
+
a = np.array(['eggs', 'spam', 'spam', 'eggs', 'spam', 'spam', 'spam',
|
| 1934 |
+
'spam', 'spam', 'spam', 'spam', 'eggs', 'eggs', 'spam',
|
| 1935 |
+
'eggs', 'eggs', 'eggs', 'eggs', 'eggs', 'spam'],
|
| 1936 |
+
dtype='|S4')
|
| 1937 |
+
b = np.array(['eggs', 'spam', 'spam', 'eggs', 'eggs', 'spam', 'spam',
|
| 1938 |
+
'spam', 'spam', 'eggs', 'spam', 'eggs', 'spam', 'eggs',
|
| 1939 |
+
'spam', 'spam', 'eggs', 'spam', 'spam', 'eggs'],
|
| 1940 |
+
dtype='|S4')
|
| 1941 |
+
desired = 0.45
|
| 1942 |
+
assert_allclose(whamming(a, b), desired)
|
| 1943 |
+
|
| 1944 |
+
|
| 1945 |
+
def test_minkowski_w():
|
| 1946 |
+
# Regression test for gh-8142.
|
| 1947 |
+
arr_in = np.array([[83.33333333, 100., 83.33333333, 100., 36.,
|
| 1948 |
+
60., 90., 150., 24., 48.],
|
| 1949 |
+
[83.33333333, 100., 83.33333333, 100., 36.,
|
| 1950 |
+
60., 90., 150., 24., 48.]])
|
| 1951 |
+
p0 = pdist(arr_in, metric='minkowski', p=1, w=None)
|
| 1952 |
+
c0 = cdist(arr_in, arr_in, metric='minkowski', p=1, w=None)
|
| 1953 |
+
p1 = pdist(arr_in, metric='minkowski', p=1)
|
| 1954 |
+
c1 = cdist(arr_in, arr_in, metric='minkowski', p=1)
|
| 1955 |
+
|
| 1956 |
+
assert_allclose(p0, p1, rtol=1e-15)
|
| 1957 |
+
assert_allclose(c0, c1, rtol=1e-15)
|
| 1958 |
+
|
| 1959 |
+
|
| 1960 |
+
def test_sqeuclidean_dtypes():
|
| 1961 |
+
# Assert that sqeuclidean returns the right types of values.
|
| 1962 |
+
# Integer types should be converted to floating for stability.
|
| 1963 |
+
# Floating point types should be the same as the input.
|
| 1964 |
+
x = [1, 2, 3]
|
| 1965 |
+
y = [4, 5, 6]
|
| 1966 |
+
|
| 1967 |
+
for dtype in [np.int8, np.int16, np.int32, np.int64]:
|
| 1968 |
+
d = wsqeuclidean(np.asarray(x, dtype=dtype), np.asarray(y, dtype=dtype))
|
| 1969 |
+
assert_(np.issubdtype(d.dtype, np.floating))
|
| 1970 |
+
|
| 1971 |
+
for dtype in [np.uint8, np.uint16, np.uint32, np.uint64]:
|
| 1972 |
+
umax = np.iinfo(dtype).max
|
| 1973 |
+
d1 = wsqeuclidean([0], np.asarray([umax], dtype=dtype))
|
| 1974 |
+
d2 = wsqeuclidean(np.asarray([umax], dtype=dtype), [0])
|
| 1975 |
+
|
| 1976 |
+
assert_equal(d1, d2)
|
| 1977 |
+
assert_equal(d1, np.float64(umax)**2)
|
| 1978 |
+
|
| 1979 |
+
dtypes = [np.float32, np.float64, np.complex64, np.complex128]
|
| 1980 |
+
for dtype in ['float16', 'float128']:
|
| 1981 |
+
# These aren't present in older numpy versions; float128 may also not
|
| 1982 |
+
# be present on all platforms.
|
| 1983 |
+
if hasattr(np, dtype):
|
| 1984 |
+
dtypes.append(getattr(np, dtype))
|
| 1985 |
+
|
| 1986 |
+
for dtype in dtypes:
|
| 1987 |
+
d = wsqeuclidean(np.asarray(x, dtype=dtype), np.asarray(y, dtype=dtype))
|
| 1988 |
+
assert_equal(d.dtype, dtype)
|
| 1989 |
+
|
| 1990 |
+
|
| 1991 |
+
def test_modifies_input(metric):
|
| 1992 |
+
# test whether cdist or pdist modifies input arrays
|
| 1993 |
+
X1 = np.asarray([[1., 2., 3.],
|
| 1994 |
+
[1.2, 2.3, 3.4],
|
| 1995 |
+
[2.2, 2.3, 4.4],
|
| 1996 |
+
[22.2, 23.3, 44.4]])
|
| 1997 |
+
X1_copy = X1.copy()
|
| 1998 |
+
cdist(X1, X1, metric)
|
| 1999 |
+
pdist(X1, metric)
|
| 2000 |
+
assert_array_equal(X1, X1_copy)
|
| 2001 |
+
|
| 2002 |
+
|
| 2003 |
+
def test_Xdist_deprecated_args(metric):
|
| 2004 |
+
# testing both cdist and pdist deprecated warnings
|
| 2005 |
+
X1 = np.asarray([[1., 2., 3.],
|
| 2006 |
+
[1.2, 2.3, 3.4],
|
| 2007 |
+
[2.2, 2.3, 4.4],
|
| 2008 |
+
[22.2, 23.3, 44.4]])
|
| 2009 |
+
|
| 2010 |
+
with pytest.raises(TypeError):
|
| 2011 |
+
cdist(X1, X1, metric, 2.)
|
| 2012 |
+
|
| 2013 |
+
with pytest.raises(TypeError):
|
| 2014 |
+
pdist(X1, metric, 2.)
|
| 2015 |
+
|
| 2016 |
+
for arg in ["p", "V", "VI"]:
|
| 2017 |
+
kwargs = {arg: np.asarray(1.)}
|
| 2018 |
+
|
| 2019 |
+
if ((arg == "V" and metric == "seuclidean")
|
| 2020 |
+
or (arg == "VI" and metric == "mahalanobis")
|
| 2021 |
+
or (arg == "p" and metric == "minkowski")):
|
| 2022 |
+
continue
|
| 2023 |
+
|
| 2024 |
+
with pytest.raises(TypeError):
|
| 2025 |
+
cdist(X1, X1, metric, **kwargs)
|
| 2026 |
+
|
| 2027 |
+
with pytest.raises(TypeError):
|
| 2028 |
+
pdist(X1, metric, **kwargs)
|
| 2029 |
+
|
| 2030 |
+
|
| 2031 |
+
def test_Xdist_non_negative_weights(metric):
|
| 2032 |
+
X = eo['random-float32-data'][::5, ::2]
|
| 2033 |
+
w = np.ones(X.shape[1])
|
| 2034 |
+
w[::5] = -w[::5]
|
| 2035 |
+
|
| 2036 |
+
if metric in ['seuclidean', 'mahalanobis', 'jensenshannon']:
|
| 2037 |
+
pytest.skip("not applicable")
|
| 2038 |
+
|
| 2039 |
+
for m in [metric, eval(metric), "test_" + metric]:
|
| 2040 |
+
with pytest.raises(ValueError):
|
| 2041 |
+
pdist(X, m, w=w)
|
| 2042 |
+
with pytest.raises(ValueError):
|
| 2043 |
+
cdist(X, X, m, w=w)
|
| 2044 |
+
|
| 2045 |
+
|
| 2046 |
+
def test__validate_vector():
|
| 2047 |
+
x = [1, 2, 3]
|
| 2048 |
+
y = _validate_vector(x)
|
| 2049 |
+
assert_array_equal(y, x)
|
| 2050 |
+
|
| 2051 |
+
y = _validate_vector(x, dtype=np.float64)
|
| 2052 |
+
assert_array_equal(y, x)
|
| 2053 |
+
assert_equal(y.dtype, np.float64)
|
| 2054 |
+
|
| 2055 |
+
x = [1]
|
| 2056 |
+
y = _validate_vector(x)
|
| 2057 |
+
assert_equal(y.ndim, 1)
|
| 2058 |
+
assert_equal(y, x)
|
| 2059 |
+
|
| 2060 |
+
x = 1
|
| 2061 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 2062 |
+
_validate_vector(x)
|
| 2063 |
+
|
| 2064 |
+
x = np.arange(5).reshape(1, -1, 1)
|
| 2065 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 2066 |
+
_validate_vector(x)
|
| 2067 |
+
|
| 2068 |
+
x = [[1, 2], [3, 4]]
|
| 2069 |
+
with pytest.raises(ValueError, match="Input vector should be 1-D"):
|
| 2070 |
+
_validate_vector(x)
|
| 2071 |
+
|
| 2072 |
+
def test_yule_all_same():
|
| 2073 |
+
# Test yule avoids a divide by zero when exactly equal
|
| 2074 |
+
x = np.ones((2, 6), dtype=bool)
|
| 2075 |
+
d = wyule(x[0], x[0])
|
| 2076 |
+
assert d == 0.0
|
| 2077 |
+
|
| 2078 |
+
d = pdist(x, 'yule')
|
| 2079 |
+
assert_equal(d, [0.0])
|
| 2080 |
+
|
| 2081 |
+
d = cdist(x[:1], x[:1], 'yule')
|
| 2082 |
+
assert_equal(d, [[0.0]])
|
| 2083 |
+
|
| 2084 |
+
|
| 2085 |
+
def test_jensenshannon():
|
| 2086 |
+
assert_almost_equal(jensenshannon([1.0, 0.0, 0.0], [0.0, 1.0, 0.0], 2.0),
|
| 2087 |
+
1.0)
|
| 2088 |
+
assert_almost_equal(jensenshannon([1.0, 0.0], [0.5, 0.5]),
|
| 2089 |
+
0.46450140402245893)
|
| 2090 |
+
assert_almost_equal(jensenshannon([1.0, 0.0, 0.0], [1.0, 0.0, 0.0]), 0.0)
|
| 2091 |
+
|
| 2092 |
+
assert_almost_equal(jensenshannon([[1.0, 2.0]], [[0.5, 1.5]], axis=0),
|
| 2093 |
+
[0.0, 0.0])
|
| 2094 |
+
assert_almost_equal(jensenshannon([[1.0, 2.0]], [[0.5, 1.5]], axis=1),
|
| 2095 |
+
[0.0649045])
|
| 2096 |
+
assert_almost_equal(jensenshannon([[1.0, 2.0]], [[0.5, 1.5]], axis=0,
|
| 2097 |
+
keepdims=True), [[0.0, 0.0]])
|
| 2098 |
+
assert_almost_equal(jensenshannon([[1.0, 2.0]], [[0.5, 1.5]], axis=1,
|
| 2099 |
+
keepdims=True), [[0.0649045]])
|
| 2100 |
+
|
| 2101 |
+
a = np.array([[1, 2, 3, 4],
|
| 2102 |
+
[5, 6, 7, 8],
|
| 2103 |
+
[9, 10, 11, 12]])
|
| 2104 |
+
b = np.array([[13, 14, 15, 16],
|
| 2105 |
+
[17, 18, 19, 20],
|
| 2106 |
+
[21, 22, 23, 24]])
|
| 2107 |
+
|
| 2108 |
+
assert_almost_equal(jensenshannon(a, b, axis=0),
|
| 2109 |
+
[0.1954288, 0.1447697, 0.1138377, 0.0927636])
|
| 2110 |
+
assert_almost_equal(jensenshannon(a, b, axis=1),
|
| 2111 |
+
[0.1402339, 0.0399106, 0.0201815])
|
| 2112 |
+
|
| 2113 |
+
|
| 2114 |
+
def test_gh_17703():
|
| 2115 |
+
arr_1 = np.array([1, 0, 0])
|
| 2116 |
+
arr_2 = np.array([2, 0, 0])
|
| 2117 |
+
expected = dice(arr_1, arr_2)
|
| 2118 |
+
actual = pdist([arr_1, arr_2], metric='dice')
|
| 2119 |
+
assert_allclose(actual, expected)
|
| 2120 |
+
actual = cdist(np.atleast_2d(arr_1),
|
| 2121 |
+
np.atleast_2d(arr_2), metric='dice')
|
| 2122 |
+
assert_allclose(actual, expected)
|
| 2123 |
+
|
| 2124 |
+
|
| 2125 |
+
def test_immutable_input(metric):
|
| 2126 |
+
if metric in ("jensenshannon", "mahalanobis", "seuclidean"):
|
| 2127 |
+
pytest.skip("not applicable")
|
| 2128 |
+
x = np.arange(10, dtype=np.float64)
|
| 2129 |
+
x.setflags(write=False)
|
| 2130 |
+
getattr(scipy.spatial.distance, metric)(x, x, w=x)
|
| 2131 |
+
|
| 2132 |
+
|
| 2133 |
+
def test_gh_23109():
|
| 2134 |
+
a = np.array([0, 0, 1, 1])
|
| 2135 |
+
b = np.array([0, 1, 1, 0])
|
| 2136 |
+
w = np.asarray([1.5, 1.2, 0.7, 1.3])
|
| 2137 |
+
expected = yule(a, b, w=w)
|
| 2138 |
+
assert_allclose(expected, 1.1954022988505748)
|
| 2139 |
+
actual = cdist(np.atleast_2d(a),
|
| 2140 |
+
np.atleast_2d(b),
|
| 2141 |
+
metric='yule', w=w)
|
| 2142 |
+
assert_allclose(actual, expected)
|
| 2143 |
+
|
| 2144 |
+
|
| 2145 |
+
class TestJaccard:
|
| 2146 |
+
|
| 2147 |
+
def test_pdist_jaccard_random(self):
|
| 2148 |
+
eps = 1e-8
|
| 2149 |
+
X = eo['pdist-boolean-inp']
|
| 2150 |
+
Y_right = eo['pdist-jaccard']
|
| 2151 |
+
Y_test1 = wpdist(X, 'jaccard')
|
| 2152 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2153 |
+
|
| 2154 |
+
def test_pdist_jaccard_random_float32(self):
|
| 2155 |
+
eps = 1e-8
|
| 2156 |
+
X = np.float32(eo['pdist-boolean-inp'])
|
| 2157 |
+
Y_right = eo['pdist-jaccard']
|
| 2158 |
+
Y_test1 = wpdist(X, 'jaccard')
|
| 2159 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2160 |
+
|
| 2161 |
+
def test_pdist_jaccard_random_nonC(self):
|
| 2162 |
+
eps = 1e-8
|
| 2163 |
+
X = eo['pdist-boolean-inp']
|
| 2164 |
+
Y_right = eo['pdist-jaccard']
|
| 2165 |
+
Y_test2 = wpdist(X, 'test_jaccard')
|
| 2166 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 2167 |
+
|
| 2168 |
+
def test_pdist_djaccard_random(self):
|
| 2169 |
+
eps = 1e-8
|
| 2170 |
+
X = np.float64(eo['pdist-boolean-inp'])
|
| 2171 |
+
Y_right = eo['pdist-jaccard']
|
| 2172 |
+
Y_test1 = wpdist(X, 'jaccard')
|
| 2173 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2174 |
+
|
| 2175 |
+
def test_pdist_djaccard_random_float32(self):
|
| 2176 |
+
eps = 1e-8
|
| 2177 |
+
X = np.float32(eo['pdist-boolean-inp'])
|
| 2178 |
+
Y_right = eo['pdist-jaccard']
|
| 2179 |
+
Y_test1 = wpdist(X, 'jaccard')
|
| 2180 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2181 |
+
|
| 2182 |
+
def test_pdist_djaccard_allzeros(self):
|
| 2183 |
+
eps = 1e-15
|
| 2184 |
+
Y = pdist(np.zeros((5, 3)), 'jaccard')
|
| 2185 |
+
assert_allclose(np.zeros(10), Y, rtol=eps)
|
| 2186 |
+
|
| 2187 |
+
def test_pdist_djaccard_random_nonC(self):
|
| 2188 |
+
eps = 1e-8
|
| 2189 |
+
X = np.float64(eo['pdist-boolean-inp'])
|
| 2190 |
+
Y_right = eo['pdist-jaccard']
|
| 2191 |
+
Y_test2 = wpdist(X, 'test_jaccard')
|
| 2192 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 2193 |
+
|
| 2194 |
+
def test_pdist_djaccard_allzeros_nonC(self):
|
| 2195 |
+
eps = 1e-15
|
| 2196 |
+
Y = pdist(np.zeros((5, 3)), 'test_jaccard')
|
| 2197 |
+
assert_allclose(np.zeros(10), Y, rtol=eps)
|
| 2198 |
+
|
| 2199 |
+
def test_pdist_jaccard_mtica1(self):
|
| 2200 |
+
m = wjaccard(np.array([1, 0, 1, 1, 0]),
|
| 2201 |
+
np.array([1, 1, 0, 1, 1]))
|
| 2202 |
+
m2 = wjaccard(np.array([1, 0, 1, 1, 0], dtype=bool),
|
| 2203 |
+
np.array([1, 1, 0, 1, 1], dtype=bool))
|
| 2204 |
+
assert_allclose(m, 0.6, rtol=0, atol=1e-10)
|
| 2205 |
+
assert_allclose(m2, 0.6, rtol=0, atol=1e-10)
|
| 2206 |
+
|
| 2207 |
+
def test_pdist_jaccard_mtica2(self):
|
| 2208 |
+
m = wjaccard(np.array([1, 0, 1]),
|
| 2209 |
+
np.array([1, 1, 0]))
|
| 2210 |
+
m2 = wjaccard(np.array([1, 0, 1], dtype=bool),
|
| 2211 |
+
np.array([1, 1, 0], dtype=bool))
|
| 2212 |
+
assert_allclose(m, 2 / 3, rtol=0, atol=1e-10)
|
| 2213 |
+
assert_allclose(m2, 2 / 3, rtol=0, atol=1e-10)
|
| 2214 |
+
|
| 2215 |
+
def test_non_01_input(self):
|
| 2216 |
+
# Non-0/1 numeric input should be cast to bool before computation.
|
| 2217 |
+
# See gh-21176.
|
| 2218 |
+
x = np.array([-10, 2.5, 0]) # [True, True, False]
|
| 2219 |
+
y = np.array([ 2, -5, 2]) # [True, True, True]
|
| 2220 |
+
eps = np.finfo(float).eps
|
| 2221 |
+
assert_allclose(jaccard(x, y), 1/3, rtol=eps)
|
| 2222 |
+
assert_allclose(cdist([x], [y], 'jaccard'), [[1/3]])
|
| 2223 |
+
assert_allclose(pdist([x, y], 'jaccard'), [1/3])
|
| 2224 |
+
|
| 2225 |
+
|
| 2226 |
+
class TestChebyshev:
|
| 2227 |
+
|
| 2228 |
+
def test_pdist_chebyshev_random(self):
|
| 2229 |
+
eps = 1e-8
|
| 2230 |
+
X = eo['pdist-double-inp']
|
| 2231 |
+
Y_right = eo['pdist-chebyshev']
|
| 2232 |
+
Y_test1 = pdist(X, 'chebyshev')
|
| 2233 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2234 |
+
|
| 2235 |
+
def test_pdist_chebyshev_random_float32(self):
|
| 2236 |
+
eps = 1e-7
|
| 2237 |
+
X = np.float32(eo['pdist-double-inp'])
|
| 2238 |
+
Y_right = eo['pdist-chebyshev']
|
| 2239 |
+
Y_test1 = pdist(X, 'chebyshev')
|
| 2240 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 2241 |
+
|
| 2242 |
+
def test_pdist_chebyshev_random_nonC(self):
|
| 2243 |
+
eps = 1e-8
|
| 2244 |
+
X = eo['pdist-double-inp']
|
| 2245 |
+
Y_right = eo['pdist-chebyshev']
|
| 2246 |
+
Y_test2 = pdist(X, 'test_chebyshev')
|
| 2247 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 2248 |
+
|
| 2249 |
+
def test_pdist_chebyshev_iris(self):
|
| 2250 |
+
eps = 1e-14
|
| 2251 |
+
X = eo['iris']
|
| 2252 |
+
Y_right = eo['pdist-chebyshev-iris']
|
| 2253 |
+
Y_test1 = pdist(X, 'chebyshev')
|
| 2254 |
+
assert_allclose(Y_test1, Y_right, rtol=eps)
|
| 2255 |
+
|
| 2256 |
+
def test_pdist_chebyshev_iris_float32(self):
|
| 2257 |
+
eps = 1e-5
|
| 2258 |
+
X = np.float32(eo['iris'])
|
| 2259 |
+
Y_right = eo['pdist-chebyshev-iris']
|
| 2260 |
+
Y_test1 = pdist(X, 'chebyshev')
|
| 2261 |
+
assert_allclose(Y_test1, Y_right, rtol=eps, verbose=verbose > 2)
|
| 2262 |
+
|
| 2263 |
+
def test_pdist_chebyshev_iris_nonC(self):
|
| 2264 |
+
eps = 1e-14
|
| 2265 |
+
X = eo['iris']
|
| 2266 |
+
Y_right = eo['pdist-chebyshev-iris']
|
| 2267 |
+
Y_test2 = pdist(X, 'test_chebyshev')
|
| 2268 |
+
assert_allclose(Y_test2, Y_right, rtol=eps)
|
| 2269 |
+
|
| 2270 |
+
def test_weighted(self):
|
| 2271 |
+
# Basic test for weighted Chebyshev. Only components with non-zero
|
| 2272 |
+
# weight participate in the 'max'.
|
| 2273 |
+
x = [1, 2, 3]
|
| 2274 |
+
y = [6, 5, 4]
|
| 2275 |
+
w = [0, 1, 5]
|
| 2276 |
+
assert_equal(chebyshev(x, y, w), 3)
|
| 2277 |
+
assert_equal(pdist([x, y], 'chebyshev', w=w), [3])
|
| 2278 |
+
assert_equal(cdist([x], [y], 'chebyshev', w=w), [[3]])
|
| 2279 |
+
|
| 2280 |
+
def test_zero_weight(self):
|
| 2281 |
+
# If the weight is identically zero, the distance should be zero.
|
| 2282 |
+
x = [1, 2, 3]
|
| 2283 |
+
y = [6, 5, 4]
|
| 2284 |
+
w = [0, 0, 0]
|
| 2285 |
+
assert_equal(chebyshev(x, y, w), 0)
|
| 2286 |
+
assert_equal(pdist([x, y], 'chebyshev', w=w), [0])
|
| 2287 |
+
assert_equal(cdist([x], [y], 'chebyshev', w=w), [[0]])
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_hausdorff.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from numpy.testing import (assert_allclose,
|
| 3 |
+
assert_array_equal,
|
| 4 |
+
assert_equal)
|
| 5 |
+
import pytest
|
| 6 |
+
from scipy.spatial.distance import directed_hausdorff
|
| 7 |
+
from scipy.spatial import distance
|
| 8 |
+
from scipy._lib._util import check_random_state
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class TestHausdorff:
|
| 12 |
+
# Test various properties of the directed Hausdorff code.
|
| 13 |
+
|
| 14 |
+
def setup_method(self):
|
| 15 |
+
np.random.seed(1234)
|
| 16 |
+
random_angles = np.random.random(100) * np.pi * 2
|
| 17 |
+
random_columns = np.column_stack(
|
| 18 |
+
(random_angles, random_angles, np.zeros(100)))
|
| 19 |
+
random_columns[..., 0] = np.cos(random_columns[..., 0])
|
| 20 |
+
random_columns[..., 1] = np.sin(random_columns[..., 1])
|
| 21 |
+
random_columns_2 = np.column_stack(
|
| 22 |
+
(random_angles, random_angles, np.zeros(100)))
|
| 23 |
+
random_columns_2[1:, 0] = np.cos(random_columns_2[1:, 0]) * 2.0
|
| 24 |
+
random_columns_2[1:, 1] = np.sin(random_columns_2[1:, 1]) * 2.0
|
| 25 |
+
# move one point farther out so we don't have two perfect circles
|
| 26 |
+
random_columns_2[0, 0] = np.cos(random_columns_2[0, 0]) * 3.3
|
| 27 |
+
random_columns_2[0, 1] = np.sin(random_columns_2[0, 1]) * 3.3
|
| 28 |
+
self.path_1 = random_columns
|
| 29 |
+
self.path_2 = random_columns_2
|
| 30 |
+
self.path_1_4d = np.insert(self.path_1, 3, 5, axis=1)
|
| 31 |
+
self.path_2_4d = np.insert(self.path_2, 3, 27, axis=1)
|
| 32 |
+
|
| 33 |
+
def test_symmetry(self):
|
| 34 |
+
# Ensure that the directed (asymmetric) Hausdorff distance is
|
| 35 |
+
# actually asymmetric
|
| 36 |
+
|
| 37 |
+
forward = directed_hausdorff(self.path_1, self.path_2)[0]
|
| 38 |
+
reverse = directed_hausdorff(self.path_2, self.path_1)[0]
|
| 39 |
+
assert forward != reverse
|
| 40 |
+
|
| 41 |
+
def test_brute_force_comparison_forward(self):
|
| 42 |
+
# Ensure that the algorithm for directed_hausdorff gives the
|
| 43 |
+
# same result as the simple / brute force approach in the
|
| 44 |
+
# forward direction.
|
| 45 |
+
actual = directed_hausdorff(self.path_1, self.path_2)[0]
|
| 46 |
+
# brute force over rows:
|
| 47 |
+
expected = max(np.amin(distance.cdist(self.path_1, self.path_2),
|
| 48 |
+
axis=1))
|
| 49 |
+
assert_allclose(actual, expected)
|
| 50 |
+
|
| 51 |
+
def test_brute_force_comparison_reverse(self):
|
| 52 |
+
# Ensure that the algorithm for directed_hausdorff gives the
|
| 53 |
+
# same result as the simple / brute force approach in the
|
| 54 |
+
# reverse direction.
|
| 55 |
+
actual = directed_hausdorff(self.path_2, self.path_1)[0]
|
| 56 |
+
# brute force over columns:
|
| 57 |
+
expected = max(np.amin(distance.cdist(self.path_1, self.path_2),
|
| 58 |
+
axis=0))
|
| 59 |
+
assert_allclose(actual, expected)
|
| 60 |
+
|
| 61 |
+
def test_degenerate_case(self):
|
| 62 |
+
# The directed Hausdorff distance must be zero if both input
|
| 63 |
+
# data arrays match.
|
| 64 |
+
actual = directed_hausdorff(self.path_1, self.path_1)[0]
|
| 65 |
+
assert_allclose(actual, 0.0)
|
| 66 |
+
|
| 67 |
+
def test_2d_data_forward(self):
|
| 68 |
+
# Ensure that 2D data is handled properly for a simple case
|
| 69 |
+
# relative to brute force approach.
|
| 70 |
+
actual = directed_hausdorff(self.path_1[..., :2],
|
| 71 |
+
self.path_2[..., :2])[0]
|
| 72 |
+
expected = max(np.amin(distance.cdist(self.path_1[..., :2],
|
| 73 |
+
self.path_2[..., :2]),
|
| 74 |
+
axis=1))
|
| 75 |
+
assert_allclose(actual, expected)
|
| 76 |
+
|
| 77 |
+
def test_4d_data_reverse(self):
|
| 78 |
+
# Ensure that 4D data is handled properly for a simple case
|
| 79 |
+
# relative to brute force approach.
|
| 80 |
+
actual = directed_hausdorff(self.path_2_4d, self.path_1_4d)[0]
|
| 81 |
+
# brute force over columns:
|
| 82 |
+
expected = max(np.amin(distance.cdist(self.path_1_4d, self.path_2_4d),
|
| 83 |
+
axis=0))
|
| 84 |
+
assert_allclose(actual, expected)
|
| 85 |
+
|
| 86 |
+
def test_indices(self):
|
| 87 |
+
# Ensure that correct point indices are returned -- they should
|
| 88 |
+
# correspond to the Hausdorff pair
|
| 89 |
+
path_simple_1 = np.array([[-1,-12],[0,0], [1,1], [3,7], [1,2]])
|
| 90 |
+
path_simple_2 = np.array([[0,0], [1,1], [4,100], [10,9]])
|
| 91 |
+
actual = directed_hausdorff(path_simple_2, path_simple_1)[1:]
|
| 92 |
+
expected = (2, 3)
|
| 93 |
+
assert_array_equal(actual, expected)
|
| 94 |
+
|
| 95 |
+
def test_random_state(self):
|
| 96 |
+
# ensure that the global random state is not modified because
|
| 97 |
+
# the directed Hausdorff algorithm uses randomization
|
| 98 |
+
rs = check_random_state(None)
|
| 99 |
+
old_global_state = rs.get_state()
|
| 100 |
+
directed_hausdorff(self.path_1, self.path_2)
|
| 101 |
+
rs2 = check_random_state(None)
|
| 102 |
+
new_global_state = rs2.get_state()
|
| 103 |
+
assert_equal(new_global_state, old_global_state)
|
| 104 |
+
|
| 105 |
+
@pytest.mark.parametrize("seed", [None, 27870671, np.random.default_rng(177)])
|
| 106 |
+
def test_random_state_None_int(self, seed):
|
| 107 |
+
# check that seed values of None or int do not alter global
|
| 108 |
+
# random state
|
| 109 |
+
rs = check_random_state(None)
|
| 110 |
+
old_global_state = rs.get_state()
|
| 111 |
+
directed_hausdorff(self.path_1, self.path_2, seed)
|
| 112 |
+
rs2 = check_random_state(None)
|
| 113 |
+
new_global_state = rs2.get_state()
|
| 114 |
+
assert_equal(new_global_state, old_global_state)
|
| 115 |
+
|
| 116 |
+
def test_invalid_dimensions(self):
|
| 117 |
+
# Ensure that a ValueError is raised when the number of columns
|
| 118 |
+
# is not the same
|
| 119 |
+
rng = np.random.default_rng(189048172503940875434364128139223470523)
|
| 120 |
+
A = rng.random((3, 2))
|
| 121 |
+
B = rng.random((3, 5))
|
| 122 |
+
msg = r"need to have the same number of columns"
|
| 123 |
+
with pytest.raises(ValueError, match=msg):
|
| 124 |
+
directed_hausdorff(A, B)
|
| 125 |
+
|
| 126 |
+
# preserve use of legacy keyword `seed` during SPEC 7 transition
|
| 127 |
+
@pytest.mark.parametrize("A, B, seed, expected", [
|
| 128 |
+
# the two cases from gh-11332
|
| 129 |
+
([(0,0)],
|
| 130 |
+
[(0,1), (0,0)],
|
| 131 |
+
np.int64(0),
|
| 132 |
+
(0.0, 0, 1)),
|
| 133 |
+
([(0,0)],
|
| 134 |
+
[(0,1), (0,0)],
|
| 135 |
+
1,
|
| 136 |
+
(0.0, 0, 1)),
|
| 137 |
+
# gh-11332 cases with a Generator
|
| 138 |
+
([(0,0)],
|
| 139 |
+
[(0,1), (0,0)],
|
| 140 |
+
np.random.default_rng(0),
|
| 141 |
+
(0.0, 0, 1)),
|
| 142 |
+
([(0,0)],
|
| 143 |
+
[(0,1), (0,0)],
|
| 144 |
+
np.random.default_rng(1),
|
| 145 |
+
(0.0, 0, 1)),
|
| 146 |
+
# slightly more complex case
|
| 147 |
+
([(-5, 3), (0,0)],
|
| 148 |
+
[(0,1), (0,0), (-5, 3)],
|
| 149 |
+
77098,
|
| 150 |
+
# the maximum minimum distance will
|
| 151 |
+
# be the last one found, but a unique
|
| 152 |
+
# solution is not guaranteed more broadly
|
| 153 |
+
(0.0, 1, 1)),
|
| 154 |
+
# repeated with Generator seeding
|
| 155 |
+
([(-5, 3), (0,0)],
|
| 156 |
+
[(0,1), (0,0), (-5, 3)],
|
| 157 |
+
np.random.default_rng(77098),
|
| 158 |
+
# NOTE: using a Generator changes the
|
| 159 |
+
# indices but not the distance (unique solution
|
| 160 |
+
# not guaranteed)
|
| 161 |
+
(0.0, 0, 2)),
|
| 162 |
+
])
|
| 163 |
+
def test_subsets(self, A, B, seed, expected, num_parallel_threads):
|
| 164 |
+
# verify fix for gh-11332
|
| 165 |
+
actual = directed_hausdorff(u=A, v=B, seed=seed)
|
| 166 |
+
# check distance
|
| 167 |
+
assert_allclose(actual[0], expected[0])
|
| 168 |
+
starting_seed = seed
|
| 169 |
+
if hasattr(seed, 'bit_generator'):
|
| 170 |
+
starting_seed = seed.bit_generator._seed_seq.entropy
|
| 171 |
+
# check indices
|
| 172 |
+
if num_parallel_threads == 1 or starting_seed != 77098:
|
| 173 |
+
assert actual[1:] == expected[1:]
|
| 174 |
+
|
| 175 |
+
if not isinstance(seed, np.random.RandomState):
|
| 176 |
+
# Check that new `rng` keyword is also accepted
|
| 177 |
+
actual = directed_hausdorff(u=A, v=B, rng=seed)
|
| 178 |
+
assert_allclose(actual[0], expected[0])
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
@pytest.mark.xslow
|
| 182 |
+
def test_massive_arr_overflow():
|
| 183 |
+
# on 64-bit systems we should be able to
|
| 184 |
+
# handle arrays that exceed the indexing
|
| 185 |
+
# size of a 32-bit signed integer
|
| 186 |
+
try:
|
| 187 |
+
import psutil
|
| 188 |
+
except ModuleNotFoundError:
|
| 189 |
+
pytest.skip("psutil required to check available memory")
|
| 190 |
+
if psutil.virtual_memory().available < 80*2**30:
|
| 191 |
+
# Don't run the test if there is less than 80 gig of RAM available.
|
| 192 |
+
pytest.skip('insufficient memory available to run this test')
|
| 193 |
+
size = int(3e9)
|
| 194 |
+
arr1 = np.zeros(shape=(size, 2))
|
| 195 |
+
arr2 = np.zeros(shape=(3, 2))
|
| 196 |
+
arr1[size - 1] = [5, 5]
|
| 197 |
+
actual = directed_hausdorff(u=arr1, v=arr2)
|
| 198 |
+
assert_allclose(actual[0], 7.0710678118654755)
|
| 199 |
+
assert_allclose(actual[1], size - 1)
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_kdtree.py
ADDED
|
@@ -0,0 +1,1536 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright Anne M. Archibald 2008
|
| 2 |
+
# Released under the scipy license
|
| 3 |
+
|
| 4 |
+
import os
|
| 5 |
+
from numpy.testing import (assert_equal, assert_array_equal, assert_,
|
| 6 |
+
assert_almost_equal, assert_array_almost_equal,
|
| 7 |
+
assert_allclose)
|
| 8 |
+
from pytest import raises as assert_raises
|
| 9 |
+
import pytest
|
| 10 |
+
from platform import python_implementation
|
| 11 |
+
import numpy as np
|
| 12 |
+
from scipy.spatial import KDTree, Rectangle, distance_matrix, cKDTree
|
| 13 |
+
from scipy.spatial._ckdtree import cKDTreeNode
|
| 14 |
+
from scipy.spatial import minkowski_distance
|
| 15 |
+
|
| 16 |
+
import itertools
|
| 17 |
+
|
| 18 |
+
@pytest.fixture(params=[KDTree, cKDTree])
|
| 19 |
+
def kdtree_type(request):
|
| 20 |
+
return request.param
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def KDTreeTest(kls):
|
| 24 |
+
"""Class decorator to create test cases for KDTree and cKDTree
|
| 25 |
+
|
| 26 |
+
Tests use the class variable ``kdtree_type`` as the tree constructor.
|
| 27 |
+
"""
|
| 28 |
+
if not kls.__name__.startswith('_Test'):
|
| 29 |
+
raise RuntimeError("Expected a class name starting with _Test")
|
| 30 |
+
|
| 31 |
+
for tree in (KDTree, cKDTree):
|
| 32 |
+
test_name = kls.__name__[1:] + '_' + tree.__name__
|
| 33 |
+
|
| 34 |
+
if test_name in globals():
|
| 35 |
+
raise RuntimeError("Duplicated test name: " + test_name)
|
| 36 |
+
|
| 37 |
+
# Create a new sub-class with kdtree_type defined
|
| 38 |
+
test_case = type(test_name, (kls,), {'kdtree_type': tree})
|
| 39 |
+
globals()[test_name] = test_case
|
| 40 |
+
return kls
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def distance_box(a, b, p, boxsize):
|
| 44 |
+
diff = a - b
|
| 45 |
+
diff[diff > 0.5 * boxsize] -= boxsize
|
| 46 |
+
diff[diff < -0.5 * boxsize] += boxsize
|
| 47 |
+
d = minkowski_distance(diff, 0, p)
|
| 48 |
+
return d
|
| 49 |
+
|
| 50 |
+
class ConsistencyTests:
|
| 51 |
+
def distance(self, a, b, p):
|
| 52 |
+
return minkowski_distance(a, b, p)
|
| 53 |
+
|
| 54 |
+
def test_nearest(self):
|
| 55 |
+
x = self.x
|
| 56 |
+
d, i = self.kdtree.query(x, 1)
|
| 57 |
+
assert_almost_equal(d**2, np.sum((x-self.data[i])**2))
|
| 58 |
+
eps = 1e-8
|
| 59 |
+
assert_(np.all(np.sum((self.data-x[np.newaxis, :])**2, axis=1) > d**2-eps))
|
| 60 |
+
|
| 61 |
+
def test_m_nearest(self):
|
| 62 |
+
x = self.x
|
| 63 |
+
m = self.m
|
| 64 |
+
dd, ii = self.kdtree.query(x, m)
|
| 65 |
+
d = np.amax(dd)
|
| 66 |
+
i = ii[np.argmax(dd)]
|
| 67 |
+
assert_almost_equal(d**2, np.sum((x-self.data[i])**2))
|
| 68 |
+
eps = 1e-8
|
| 69 |
+
assert_equal(
|
| 70 |
+
np.sum(np.sum((self.data-x[np.newaxis, :])**2, axis=1) < d**2+eps),
|
| 71 |
+
m,
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
def test_points_near(self):
|
| 75 |
+
x = self.x
|
| 76 |
+
d = self.d
|
| 77 |
+
dd, ii = self.kdtree.query(x, k=self.kdtree.n, distance_upper_bound=d)
|
| 78 |
+
eps = 1e-8
|
| 79 |
+
hits = 0
|
| 80 |
+
for near_d, near_i in zip(dd, ii):
|
| 81 |
+
if near_d == np.inf:
|
| 82 |
+
continue
|
| 83 |
+
hits += 1
|
| 84 |
+
assert_almost_equal(near_d**2, np.sum((x-self.data[near_i])**2))
|
| 85 |
+
assert_(near_d < d+eps, f"near_d={near_d:g} should be less than {d:g}")
|
| 86 |
+
assert_equal(np.sum(self.distance(self.data, x, 2) < d**2+eps), hits)
|
| 87 |
+
|
| 88 |
+
def test_points_near_l1(self):
|
| 89 |
+
x = self.x
|
| 90 |
+
d = self.d
|
| 91 |
+
dd, ii = self.kdtree.query(x, k=self.kdtree.n, p=1, distance_upper_bound=d)
|
| 92 |
+
eps = 1e-8
|
| 93 |
+
hits = 0
|
| 94 |
+
for near_d, near_i in zip(dd, ii):
|
| 95 |
+
if near_d == np.inf:
|
| 96 |
+
continue
|
| 97 |
+
hits += 1
|
| 98 |
+
assert_almost_equal(near_d, self.distance(x, self.data[near_i], 1))
|
| 99 |
+
assert_(near_d < d+eps, f"near_d={near_d:g} should be less than {d:g}")
|
| 100 |
+
assert_equal(np.sum(self.distance(self.data, x, 1) < d+eps), hits)
|
| 101 |
+
|
| 102 |
+
def test_points_near_linf(self):
|
| 103 |
+
x = self.x
|
| 104 |
+
d = self.d
|
| 105 |
+
dd, ii = self.kdtree.query(x, k=self.kdtree.n, p=np.inf, distance_upper_bound=d)
|
| 106 |
+
eps = 1e-8
|
| 107 |
+
hits = 0
|
| 108 |
+
for near_d, near_i in zip(dd, ii):
|
| 109 |
+
if near_d == np.inf:
|
| 110 |
+
continue
|
| 111 |
+
hits += 1
|
| 112 |
+
assert_almost_equal(near_d, self.distance(x, self.data[near_i], np.inf))
|
| 113 |
+
assert_(near_d < d+eps, f"near_d={near_d:g} should be less than {d:g}")
|
| 114 |
+
assert_equal(np.sum(self.distance(self.data, x, np.inf) < d+eps), hits)
|
| 115 |
+
|
| 116 |
+
def test_approx(self):
|
| 117 |
+
x = self.x
|
| 118 |
+
k = self.k
|
| 119 |
+
eps = 0.1
|
| 120 |
+
d_real, i_real = self.kdtree.query(x, k)
|
| 121 |
+
d, i = self.kdtree.query(x, k, eps=eps)
|
| 122 |
+
assert_(np.all(d <= d_real*(1+eps)))
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
@KDTreeTest
|
| 126 |
+
class _Test_random(ConsistencyTests):
|
| 127 |
+
def setup_method(self):
|
| 128 |
+
self.n = 100
|
| 129 |
+
self.m = 4
|
| 130 |
+
np.random.seed(1234)
|
| 131 |
+
self.data = np.random.randn(self.n, self.m)
|
| 132 |
+
self.kdtree = self.kdtree_type(self.data, leafsize=2)
|
| 133 |
+
self.x = np.random.randn(self.m)
|
| 134 |
+
self.d = 0.2
|
| 135 |
+
self.k = 10
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
@KDTreeTest
|
| 139 |
+
class _Test_random_far(_Test_random):
|
| 140 |
+
def setup_method(self):
|
| 141 |
+
super().setup_method()
|
| 142 |
+
self.x = np.random.randn(self.m)+10
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
@KDTreeTest
|
| 146 |
+
class _Test_small(ConsistencyTests):
|
| 147 |
+
def setup_method(self):
|
| 148 |
+
self.data = np.array([[0, 0, 0],
|
| 149 |
+
[0, 0, 1],
|
| 150 |
+
[0, 1, 0],
|
| 151 |
+
[0, 1, 1],
|
| 152 |
+
[1, 0, 0],
|
| 153 |
+
[1, 0, 1],
|
| 154 |
+
[1, 1, 0],
|
| 155 |
+
[1, 1, 1]])
|
| 156 |
+
self.kdtree = self.kdtree_type(self.data)
|
| 157 |
+
self.n = self.kdtree.n
|
| 158 |
+
self.m = self.kdtree.m
|
| 159 |
+
np.random.seed(1234)
|
| 160 |
+
self.x = np.random.randn(3)
|
| 161 |
+
self.d = 0.5
|
| 162 |
+
self.k = 4
|
| 163 |
+
|
| 164 |
+
def test_nearest(self):
|
| 165 |
+
assert_array_equal(
|
| 166 |
+
self.kdtree.query((0, 0, 0.1), 1),
|
| 167 |
+
(0.1, 0))
|
| 168 |
+
|
| 169 |
+
def test_nearest_two(self):
|
| 170 |
+
assert_array_equal(
|
| 171 |
+
self.kdtree.query((0, 0, 0.1), 2),
|
| 172 |
+
([0.1, 0.9], [0, 1]))
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
@KDTreeTest
|
| 176 |
+
class _Test_small_nonleaf(_Test_small):
|
| 177 |
+
def setup_method(self):
|
| 178 |
+
super().setup_method()
|
| 179 |
+
self.kdtree = self.kdtree_type(self.data, leafsize=1)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class Test_vectorization_KDTree:
|
| 183 |
+
def setup_method(self):
|
| 184 |
+
self.data = np.array([[0, 0, 0],
|
| 185 |
+
[0, 0, 1],
|
| 186 |
+
[0, 1, 0],
|
| 187 |
+
[0, 1, 1],
|
| 188 |
+
[1, 0, 0],
|
| 189 |
+
[1, 0, 1],
|
| 190 |
+
[1, 1, 0],
|
| 191 |
+
[1, 1, 1]])
|
| 192 |
+
self.kdtree = KDTree(self.data)
|
| 193 |
+
|
| 194 |
+
def test_single_query(self):
|
| 195 |
+
d, i = self.kdtree.query(np.array([0, 0, 0]))
|
| 196 |
+
assert_(isinstance(d, float))
|
| 197 |
+
assert_(np.issubdtype(i, np.signedinteger))
|
| 198 |
+
|
| 199 |
+
def test_vectorized_query(self):
|
| 200 |
+
d, i = self.kdtree.query(np.zeros((2, 4, 3)))
|
| 201 |
+
assert_equal(np.shape(d), (2, 4))
|
| 202 |
+
assert_equal(np.shape(i), (2, 4))
|
| 203 |
+
|
| 204 |
+
def test_single_query_multiple_neighbors(self):
|
| 205 |
+
s = 23
|
| 206 |
+
kk = self.kdtree.n+s
|
| 207 |
+
d, i = self.kdtree.query(np.array([0, 0, 0]), k=kk)
|
| 208 |
+
assert_equal(np.shape(d), (kk,))
|
| 209 |
+
assert_equal(np.shape(i), (kk,))
|
| 210 |
+
assert_(np.all(~np.isfinite(d[-s:])))
|
| 211 |
+
assert_(np.all(i[-s:] == self.kdtree.n))
|
| 212 |
+
|
| 213 |
+
def test_vectorized_query_multiple_neighbors(self):
|
| 214 |
+
s = 23
|
| 215 |
+
kk = self.kdtree.n+s
|
| 216 |
+
d, i = self.kdtree.query(np.zeros((2, 4, 3)), k=kk)
|
| 217 |
+
assert_equal(np.shape(d), (2, 4, kk))
|
| 218 |
+
assert_equal(np.shape(i), (2, 4, kk))
|
| 219 |
+
assert_(np.all(~np.isfinite(d[:, :, -s:])))
|
| 220 |
+
assert_(np.all(i[:, :, -s:] == self.kdtree.n))
|
| 221 |
+
|
| 222 |
+
def test_query_raises_for_k_none(self):
|
| 223 |
+
x = 1.0
|
| 224 |
+
with pytest.raises(ValueError, match="k must be an integer or*"):
|
| 225 |
+
self.kdtree.query(x, k=None)
|
| 226 |
+
|
| 227 |
+
class Test_vectorization_cKDTree:
|
| 228 |
+
def setup_method(self):
|
| 229 |
+
self.data = np.array([[0, 0, 0],
|
| 230 |
+
[0, 0, 1],
|
| 231 |
+
[0, 1, 0],
|
| 232 |
+
[0, 1, 1],
|
| 233 |
+
[1, 0, 0],
|
| 234 |
+
[1, 0, 1],
|
| 235 |
+
[1, 1, 0],
|
| 236 |
+
[1, 1, 1]])
|
| 237 |
+
self.kdtree = cKDTree(self.data)
|
| 238 |
+
|
| 239 |
+
def test_single_query(self):
|
| 240 |
+
d, i = self.kdtree.query([0, 0, 0])
|
| 241 |
+
assert_(isinstance(d, float))
|
| 242 |
+
assert_(isinstance(i, int))
|
| 243 |
+
|
| 244 |
+
def test_vectorized_query(self):
|
| 245 |
+
d, i = self.kdtree.query(np.zeros((2, 4, 3)))
|
| 246 |
+
assert_equal(np.shape(d), (2, 4))
|
| 247 |
+
assert_equal(np.shape(i), (2, 4))
|
| 248 |
+
|
| 249 |
+
def test_vectorized_query_noncontiguous_values(self):
|
| 250 |
+
np.random.seed(1234)
|
| 251 |
+
qs = np.random.randn(3, 1000).T
|
| 252 |
+
ds, i_s = self.kdtree.query(qs)
|
| 253 |
+
for q, d, i in zip(qs, ds, i_s):
|
| 254 |
+
assert_equal(self.kdtree.query(q), (d, i))
|
| 255 |
+
|
| 256 |
+
def test_single_query_multiple_neighbors(self):
|
| 257 |
+
s = 23
|
| 258 |
+
kk = self.kdtree.n+s
|
| 259 |
+
d, i = self.kdtree.query([0, 0, 0], k=kk)
|
| 260 |
+
assert_equal(np.shape(d), (kk,))
|
| 261 |
+
assert_equal(np.shape(i), (kk,))
|
| 262 |
+
assert_(np.all(~np.isfinite(d[-s:])))
|
| 263 |
+
assert_(np.all(i[-s:] == self.kdtree.n))
|
| 264 |
+
|
| 265 |
+
def test_vectorized_query_multiple_neighbors(self):
|
| 266 |
+
s = 23
|
| 267 |
+
kk = self.kdtree.n+s
|
| 268 |
+
d, i = self.kdtree.query(np.zeros((2, 4, 3)), k=kk)
|
| 269 |
+
assert_equal(np.shape(d), (2, 4, kk))
|
| 270 |
+
assert_equal(np.shape(i), (2, 4, kk))
|
| 271 |
+
assert_(np.all(~np.isfinite(d[:, :, -s:])))
|
| 272 |
+
assert_(np.all(i[:, :, -s:] == self.kdtree.n))
|
| 273 |
+
|
| 274 |
+
class ball_consistency:
|
| 275 |
+
tol = 0.0
|
| 276 |
+
|
| 277 |
+
def distance(self, a, b, p):
|
| 278 |
+
return minkowski_distance(a * 1.0, b * 1.0, p)
|
| 279 |
+
|
| 280 |
+
def test_in_ball(self):
|
| 281 |
+
x = np.atleast_2d(self.x)
|
| 282 |
+
d = np.broadcast_to(self.d, x.shape[:-1])
|
| 283 |
+
l = self.T.query_ball_point(x, self.d, p=self.p, eps=self.eps)
|
| 284 |
+
for i, ind in enumerate(l):
|
| 285 |
+
dist = self.distance(self.data[ind], x[i], self.p) - d[i]*(1.+self.eps)
|
| 286 |
+
norm = self.distance(self.data[ind], x[i], self.p) + d[i]*(1.+self.eps)
|
| 287 |
+
assert_array_equal(dist < self.tol * norm, True)
|
| 288 |
+
|
| 289 |
+
def test_found_all(self):
|
| 290 |
+
x = np.atleast_2d(self.x)
|
| 291 |
+
d = np.broadcast_to(self.d, x.shape[:-1])
|
| 292 |
+
l = self.T.query_ball_point(x, self.d, p=self.p, eps=self.eps)
|
| 293 |
+
for i, ind in enumerate(l):
|
| 294 |
+
c = np.ones(self.T.n, dtype=bool)
|
| 295 |
+
c[ind] = False
|
| 296 |
+
dist = self.distance(self.data[c], x[i], self.p) - d[i]/(1.+self.eps)
|
| 297 |
+
norm = self.distance(self.data[c], x[i], self.p) + d[i]/(1.+self.eps)
|
| 298 |
+
assert_array_equal(dist > -self.tol * norm, True)
|
| 299 |
+
|
| 300 |
+
@KDTreeTest
|
| 301 |
+
class _Test_random_ball(ball_consistency):
|
| 302 |
+
def setup_method(self):
|
| 303 |
+
n = 100
|
| 304 |
+
m = 4
|
| 305 |
+
np.random.seed(1234)
|
| 306 |
+
self.data = np.random.randn(n, m)
|
| 307 |
+
self.T = self.kdtree_type(self.data, leafsize=2)
|
| 308 |
+
self.x = np.random.randn(m)
|
| 309 |
+
self.p = 2.
|
| 310 |
+
self.eps = 0
|
| 311 |
+
self.d = 0.2
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
@KDTreeTest
|
| 315 |
+
class _Test_random_ball_periodic(ball_consistency):
|
| 316 |
+
def distance(self, a, b, p):
|
| 317 |
+
return distance_box(a, b, p, 1.0)
|
| 318 |
+
|
| 319 |
+
def setup_method(self):
|
| 320 |
+
n = 10000
|
| 321 |
+
m = 4
|
| 322 |
+
np.random.seed(1234)
|
| 323 |
+
self.data = np.random.uniform(size=(n, m))
|
| 324 |
+
self.T = self.kdtree_type(self.data, leafsize=2, boxsize=1)
|
| 325 |
+
self.x = np.full(m, 0.1)
|
| 326 |
+
self.p = 2.
|
| 327 |
+
self.eps = 0
|
| 328 |
+
self.d = 0.2
|
| 329 |
+
|
| 330 |
+
def test_in_ball_outside(self):
|
| 331 |
+
l = self.T.query_ball_point(self.x + 1.0, self.d, p=self.p, eps=self.eps)
|
| 332 |
+
for i in l:
|
| 333 |
+
assert_(self.distance(self.data[i], self.x, self.p) <= self.d*(1.+self.eps))
|
| 334 |
+
l = self.T.query_ball_point(self.x - 1.0, self.d, p=self.p, eps=self.eps)
|
| 335 |
+
for i in l:
|
| 336 |
+
assert_(self.distance(self.data[i], self.x, self.p) <= self.d*(1.+self.eps))
|
| 337 |
+
|
| 338 |
+
def test_found_all_outside(self):
|
| 339 |
+
c = np.ones(self.T.n, dtype=bool)
|
| 340 |
+
l = self.T.query_ball_point(self.x + 1.0, self.d, p=self.p, eps=self.eps)
|
| 341 |
+
c[l] = False
|
| 342 |
+
assert np.all(
|
| 343 |
+
self.distance(self.data[c], self.x, self.p) >= self.d/(1.+self.eps)
|
| 344 |
+
)
|
| 345 |
+
|
| 346 |
+
l = self.T.query_ball_point(self.x - 1.0, self.d, p=self.p, eps=self.eps)
|
| 347 |
+
c[l] = False
|
| 348 |
+
assert np.all(
|
| 349 |
+
self.distance(self.data[c], self.x, self.p) >= self.d/(1.+self.eps)
|
| 350 |
+
)
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
@KDTreeTest
|
| 354 |
+
class _Test_random_ball_largep_issue9890(ball_consistency):
|
| 355 |
+
|
| 356 |
+
# allow some roundoff errors due to numerical issues
|
| 357 |
+
tol = 1e-13
|
| 358 |
+
|
| 359 |
+
def setup_method(self):
|
| 360 |
+
n = 1000
|
| 361 |
+
m = 2
|
| 362 |
+
np.random.seed(123)
|
| 363 |
+
self.data = np.random.randint(100, 1000, size=(n, m))
|
| 364 |
+
self.T = self.kdtree_type(self.data)
|
| 365 |
+
self.x = self.data
|
| 366 |
+
self.p = 100
|
| 367 |
+
self.eps = 0
|
| 368 |
+
self.d = 10
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
@KDTreeTest
|
| 372 |
+
class _Test_random_ball_approx(_Test_random_ball):
|
| 373 |
+
|
| 374 |
+
def setup_method(self):
|
| 375 |
+
super().setup_method()
|
| 376 |
+
self.eps = 0.1
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
@KDTreeTest
|
| 380 |
+
class _Test_random_ball_approx_periodic(_Test_random_ball):
|
| 381 |
+
|
| 382 |
+
def setup_method(self):
|
| 383 |
+
super().setup_method()
|
| 384 |
+
self.eps = 0.1
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
@KDTreeTest
|
| 388 |
+
class _Test_random_ball_far(_Test_random_ball):
|
| 389 |
+
|
| 390 |
+
def setup_method(self):
|
| 391 |
+
super().setup_method()
|
| 392 |
+
self.d = 2.
|
| 393 |
+
|
| 394 |
+
@KDTreeTest
|
| 395 |
+
class _Test_random_ball_far_periodic(_Test_random_ball_periodic):
|
| 396 |
+
|
| 397 |
+
def setup_method(self):
|
| 398 |
+
super().setup_method()
|
| 399 |
+
self.d = 2.
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
@KDTreeTest
|
| 403 |
+
class _Test_random_ball_l1(_Test_random_ball):
|
| 404 |
+
|
| 405 |
+
def setup_method(self):
|
| 406 |
+
super().setup_method()
|
| 407 |
+
self.p = 1
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
@KDTreeTest
|
| 411 |
+
class _Test_random_ball_linf(_Test_random_ball):
|
| 412 |
+
|
| 413 |
+
def setup_method(self):
|
| 414 |
+
super().setup_method()
|
| 415 |
+
self.p = np.inf
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
def test_random_ball_vectorized(kdtree_type):
|
| 419 |
+
n = 20
|
| 420 |
+
m = 5
|
| 421 |
+
np.random.seed(1234)
|
| 422 |
+
T = kdtree_type(np.random.randn(n, m))
|
| 423 |
+
|
| 424 |
+
r = T.query_ball_point(np.random.randn(2, 3, m), 1)
|
| 425 |
+
assert_equal(r.shape, (2, 3))
|
| 426 |
+
assert_(isinstance(r[0, 0], list))
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
@pytest.mark.fail_slow(5)
|
| 430 |
+
def test_query_ball_point_multithreading(kdtree_type):
|
| 431 |
+
np.random.seed(0)
|
| 432 |
+
n = 5000
|
| 433 |
+
k = 2
|
| 434 |
+
points = np.random.randn(n, k)
|
| 435 |
+
T = kdtree_type(points)
|
| 436 |
+
l1 = T.query_ball_point(points, 0.003, workers=1)
|
| 437 |
+
l2 = T.query_ball_point(points, 0.003, workers=64)
|
| 438 |
+
l3 = T.query_ball_point(points, 0.003, workers=-1)
|
| 439 |
+
|
| 440 |
+
for i in range(n):
|
| 441 |
+
if l1[i] or l2[i]:
|
| 442 |
+
assert_array_equal(l1[i], l2[i])
|
| 443 |
+
|
| 444 |
+
for i in range(n):
|
| 445 |
+
if l1[i] or l3[i]:
|
| 446 |
+
assert_array_equal(l1[i], l3[i])
|
| 447 |
+
|
| 448 |
+
|
| 449 |
+
class two_trees_consistency:
|
| 450 |
+
|
| 451 |
+
def distance(self, a, b, p):
|
| 452 |
+
return minkowski_distance(a, b, p)
|
| 453 |
+
|
| 454 |
+
def test_all_in_ball(self):
|
| 455 |
+
r = self.T1.query_ball_tree(self.T2, self.d, p=self.p, eps=self.eps)
|
| 456 |
+
for i, l in enumerate(r):
|
| 457 |
+
for j in l:
|
| 458 |
+
assert (self.distance(self.data1[i], self.data2[j], self.p)
|
| 459 |
+
<= self.d*(1.+self.eps))
|
| 460 |
+
|
| 461 |
+
def test_found_all(self):
|
| 462 |
+
r = self.T1.query_ball_tree(self.T2, self.d, p=self.p, eps=self.eps)
|
| 463 |
+
for i, l in enumerate(r):
|
| 464 |
+
c = np.ones(self.T2.n, dtype=bool)
|
| 465 |
+
c[l] = False
|
| 466 |
+
assert np.all(self.distance(self.data2[c], self.data1[i], self.p)
|
| 467 |
+
>= self.d/(1.+self.eps))
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
@KDTreeTest
|
| 471 |
+
class _Test_two_random_trees(two_trees_consistency):
|
| 472 |
+
|
| 473 |
+
def setup_method(self):
|
| 474 |
+
n = 50
|
| 475 |
+
m = 4
|
| 476 |
+
np.random.seed(1234)
|
| 477 |
+
self.data1 = np.random.randn(n, m)
|
| 478 |
+
self.T1 = self.kdtree_type(self.data1, leafsize=2)
|
| 479 |
+
self.data2 = np.random.randn(n, m)
|
| 480 |
+
self.T2 = self.kdtree_type(self.data2, leafsize=2)
|
| 481 |
+
self.p = 2.
|
| 482 |
+
self.eps = 0
|
| 483 |
+
self.d = 0.2
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
@KDTreeTest
|
| 487 |
+
class _Test_two_random_trees_periodic(two_trees_consistency):
|
| 488 |
+
def distance(self, a, b, p):
|
| 489 |
+
return distance_box(a, b, p, 1.0)
|
| 490 |
+
|
| 491 |
+
def setup_method(self):
|
| 492 |
+
n = 50
|
| 493 |
+
m = 4
|
| 494 |
+
np.random.seed(1234)
|
| 495 |
+
self.data1 = np.random.uniform(size=(n, m))
|
| 496 |
+
self.T1 = self.kdtree_type(self.data1, leafsize=2, boxsize=1.0)
|
| 497 |
+
self.data2 = np.random.uniform(size=(n, m))
|
| 498 |
+
self.T2 = self.kdtree_type(self.data2, leafsize=2, boxsize=1.0)
|
| 499 |
+
self.p = 2.
|
| 500 |
+
self.eps = 0
|
| 501 |
+
self.d = 0.2
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
@KDTreeTest
|
| 505 |
+
class _Test_two_random_trees_far(_Test_two_random_trees):
|
| 506 |
+
|
| 507 |
+
def setup_method(self):
|
| 508 |
+
super().setup_method()
|
| 509 |
+
self.d = 2
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
@KDTreeTest
|
| 513 |
+
class _Test_two_random_trees_far_periodic(_Test_two_random_trees_periodic):
|
| 514 |
+
|
| 515 |
+
def setup_method(self):
|
| 516 |
+
super().setup_method()
|
| 517 |
+
self.d = 2
|
| 518 |
+
|
| 519 |
+
|
| 520 |
+
@KDTreeTest
|
| 521 |
+
class _Test_two_random_trees_linf(_Test_two_random_trees):
|
| 522 |
+
|
| 523 |
+
def setup_method(self):
|
| 524 |
+
super().setup_method()
|
| 525 |
+
self.p = np.inf
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
@KDTreeTest
|
| 529 |
+
class _Test_two_random_trees_linf_periodic(_Test_two_random_trees_periodic):
|
| 530 |
+
|
| 531 |
+
def setup_method(self):
|
| 532 |
+
super().setup_method()
|
| 533 |
+
self.p = np.inf
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
class Test_rectangle:
|
| 537 |
+
|
| 538 |
+
def setup_method(self):
|
| 539 |
+
self.rect = Rectangle([0, 0], [1, 1])
|
| 540 |
+
|
| 541 |
+
def test_min_inside(self):
|
| 542 |
+
assert_almost_equal(self.rect.min_distance_point([0.5, 0.5]), 0)
|
| 543 |
+
|
| 544 |
+
def test_min_one_side(self):
|
| 545 |
+
assert_almost_equal(self.rect.min_distance_point([0.5, 1.5]), 0.5)
|
| 546 |
+
|
| 547 |
+
def test_min_two_sides(self):
|
| 548 |
+
assert_almost_equal(self.rect.min_distance_point([2, 2]), np.sqrt(2))
|
| 549 |
+
|
| 550 |
+
def test_max_inside(self):
|
| 551 |
+
assert_almost_equal(self.rect.max_distance_point([0.5, 0.5]), 1/np.sqrt(2))
|
| 552 |
+
|
| 553 |
+
def test_max_one_side(self):
|
| 554 |
+
assert_almost_equal(self.rect.max_distance_point([0.5, 1.5]),
|
| 555 |
+
np.hypot(0.5, 1.5))
|
| 556 |
+
|
| 557 |
+
def test_max_two_sides(self):
|
| 558 |
+
assert_almost_equal(self.rect.max_distance_point([2, 2]), 2*np.sqrt(2))
|
| 559 |
+
|
| 560 |
+
def test_split(self):
|
| 561 |
+
less, greater = self.rect.split(0, 0.1)
|
| 562 |
+
assert_array_equal(less.maxes, [0.1, 1])
|
| 563 |
+
assert_array_equal(less.mins, [0, 0])
|
| 564 |
+
assert_array_equal(greater.maxes, [1, 1])
|
| 565 |
+
assert_array_equal(greater.mins, [0.1, 0])
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
def test_distance_l2():
|
| 569 |
+
assert_almost_equal(minkowski_distance([0, 0], [1, 1], 2), np.sqrt(2))
|
| 570 |
+
|
| 571 |
+
|
| 572 |
+
def test_distance_l1():
|
| 573 |
+
assert_almost_equal(minkowski_distance([0, 0], [1, 1], 1), 2)
|
| 574 |
+
|
| 575 |
+
|
| 576 |
+
def test_distance_linf():
|
| 577 |
+
assert_almost_equal(minkowski_distance([0, 0], [1, 1], np.inf), 1)
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
def test_distance_vectorization():
|
| 581 |
+
np.random.seed(1234)
|
| 582 |
+
x = np.random.randn(10, 1, 3)
|
| 583 |
+
y = np.random.randn(1, 7, 3)
|
| 584 |
+
assert_equal(minkowski_distance(x, y).shape, (10, 7))
|
| 585 |
+
|
| 586 |
+
|
| 587 |
+
class count_neighbors_consistency:
|
| 588 |
+
def test_one_radius(self):
|
| 589 |
+
r = 0.2
|
| 590 |
+
assert_equal(self.T1.count_neighbors(self.T2, r),
|
| 591 |
+
np.sum([len(l) for l in self.T1.query_ball_tree(self.T2, r)]))
|
| 592 |
+
|
| 593 |
+
def test_large_radius(self):
|
| 594 |
+
r = 1000
|
| 595 |
+
assert_equal(self.T1.count_neighbors(self.T2, r),
|
| 596 |
+
np.sum([len(l) for l in self.T1.query_ball_tree(self.T2, r)]))
|
| 597 |
+
|
| 598 |
+
def test_multiple_radius(self):
|
| 599 |
+
rs = np.exp(np.linspace(np.log(0.01), np.log(10), 3))
|
| 600 |
+
results = self.T1.count_neighbors(self.T2, rs)
|
| 601 |
+
assert_(np.all(np.diff(results) >= 0))
|
| 602 |
+
for r, result in zip(rs, results):
|
| 603 |
+
assert_equal(self.T1.count_neighbors(self.T2, r), result)
|
| 604 |
+
|
| 605 |
+
@KDTreeTest
|
| 606 |
+
class _Test_count_neighbors(count_neighbors_consistency):
|
| 607 |
+
def setup_method(self):
|
| 608 |
+
n = 50
|
| 609 |
+
m = 2
|
| 610 |
+
np.random.seed(1234)
|
| 611 |
+
self.T1 = self.kdtree_type(np.random.randn(n, m), leafsize=2)
|
| 612 |
+
self.T2 = self.kdtree_type(np.random.randn(n, m), leafsize=2)
|
| 613 |
+
|
| 614 |
+
|
| 615 |
+
class sparse_distance_matrix_consistency:
|
| 616 |
+
|
| 617 |
+
def distance(self, a, b, p):
|
| 618 |
+
return minkowski_distance(a, b, p)
|
| 619 |
+
|
| 620 |
+
def test_consistency_with_neighbors(self):
|
| 621 |
+
M = self.T1.sparse_distance_matrix(self.T2, self.r)
|
| 622 |
+
r = self.T1.query_ball_tree(self.T2, self.r)
|
| 623 |
+
for i, l in enumerate(r):
|
| 624 |
+
for j in l:
|
| 625 |
+
assert_almost_equal(
|
| 626 |
+
M[i, j],
|
| 627 |
+
self.distance(self.T1.data[i], self.T2.data[j], self.p),
|
| 628 |
+
decimal=14
|
| 629 |
+
)
|
| 630 |
+
for ((i, j), d) in M.items():
|
| 631 |
+
assert_(j in r[i])
|
| 632 |
+
|
| 633 |
+
def test_zero_distance(self):
|
| 634 |
+
# raises an exception for bug 870 (FIXME: Does it?)
|
| 635 |
+
self.T1.sparse_distance_matrix(self.T1, self.r)
|
| 636 |
+
|
| 637 |
+
def test_consistency(self):
|
| 638 |
+
# Test consistency with a distance_matrix
|
| 639 |
+
M1 = self.T1.sparse_distance_matrix(self.T2, self.r)
|
| 640 |
+
expected = distance_matrix(self.T1.data, self.T2.data)
|
| 641 |
+
expected[expected > self.r] = 0
|
| 642 |
+
assert_array_almost_equal(M1.toarray(), expected, decimal=14)
|
| 643 |
+
|
| 644 |
+
def test_against_logic_error_regression(self):
|
| 645 |
+
# regression test for gh-5077 logic error
|
| 646 |
+
np.random.seed(0)
|
| 647 |
+
too_many = np.array(np.random.randn(18, 2), dtype=int)
|
| 648 |
+
tree = self.kdtree_type(
|
| 649 |
+
too_many, balanced_tree=False, compact_nodes=False)
|
| 650 |
+
d = tree.sparse_distance_matrix(tree, 3).toarray()
|
| 651 |
+
assert_array_almost_equal(d, d.T, decimal=14)
|
| 652 |
+
|
| 653 |
+
def test_ckdtree_return_types(self):
|
| 654 |
+
# brute-force reference
|
| 655 |
+
ref = np.zeros((self.n, self.n))
|
| 656 |
+
for i in range(self.n):
|
| 657 |
+
for j in range(self.n):
|
| 658 |
+
v = self.data1[i, :] - self.data2[j, :]
|
| 659 |
+
ref[i, j] = np.dot(v, v)
|
| 660 |
+
ref = np.sqrt(ref)
|
| 661 |
+
ref[ref > self.r] = 0.
|
| 662 |
+
# test return type 'dict'
|
| 663 |
+
dist = np.zeros((self.n, self.n))
|
| 664 |
+
r = self.T1.sparse_distance_matrix(self.T2, self.r, output_type='dict')
|
| 665 |
+
for i, j in r.keys():
|
| 666 |
+
dist[i, j] = r[(i, j)]
|
| 667 |
+
assert_array_almost_equal(ref, dist, decimal=14)
|
| 668 |
+
# test return type 'ndarray'
|
| 669 |
+
dist = np.zeros((self.n, self.n))
|
| 670 |
+
r = self.T1.sparse_distance_matrix(self.T2, self.r,
|
| 671 |
+
output_type='ndarray')
|
| 672 |
+
for k in range(r.shape[0]):
|
| 673 |
+
i = r['i'][k]
|
| 674 |
+
j = r['j'][k]
|
| 675 |
+
v = r['v'][k]
|
| 676 |
+
dist[i, j] = v
|
| 677 |
+
assert_array_almost_equal(ref, dist, decimal=14)
|
| 678 |
+
# test return type 'dok_matrix'
|
| 679 |
+
r = self.T1.sparse_distance_matrix(self.T2, self.r,
|
| 680 |
+
output_type='dok_matrix')
|
| 681 |
+
assert_array_almost_equal(ref, r.toarray(), decimal=14)
|
| 682 |
+
# test return type 'coo_matrix'
|
| 683 |
+
r = self.T1.sparse_distance_matrix(self.T2, self.r,
|
| 684 |
+
output_type='coo_matrix')
|
| 685 |
+
assert_array_almost_equal(ref, r.toarray(), decimal=14)
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
@KDTreeTest
|
| 689 |
+
class _Test_sparse_distance_matrix(sparse_distance_matrix_consistency):
|
| 690 |
+
def setup_method(self):
|
| 691 |
+
n = 50
|
| 692 |
+
m = 4
|
| 693 |
+
np.random.seed(1234)
|
| 694 |
+
data1 = np.random.randn(n, m)
|
| 695 |
+
data2 = np.random.randn(n, m)
|
| 696 |
+
self.T1 = self.kdtree_type(data1, leafsize=2)
|
| 697 |
+
self.T2 = self.kdtree_type(data2, leafsize=2)
|
| 698 |
+
self.r = 0.5
|
| 699 |
+
self.p = 2
|
| 700 |
+
self.data1 = data1
|
| 701 |
+
self.data2 = data2
|
| 702 |
+
self.n = n
|
| 703 |
+
self.m = m
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
def test_distance_matrix():
|
| 707 |
+
m = 10
|
| 708 |
+
n = 11
|
| 709 |
+
k = 4
|
| 710 |
+
np.random.seed(1234)
|
| 711 |
+
xs = np.random.randn(m, k)
|
| 712 |
+
ys = np.random.randn(n, k)
|
| 713 |
+
ds = distance_matrix(xs, ys)
|
| 714 |
+
assert_equal(ds.shape, (m, n))
|
| 715 |
+
for i in range(m):
|
| 716 |
+
for j in range(n):
|
| 717 |
+
assert_almost_equal(minkowski_distance(xs[i], ys[j]), ds[i, j])
|
| 718 |
+
|
| 719 |
+
|
| 720 |
+
def test_distance_matrix_looping():
|
| 721 |
+
m = 10
|
| 722 |
+
n = 11
|
| 723 |
+
k = 4
|
| 724 |
+
np.random.seed(1234)
|
| 725 |
+
xs = np.random.randn(m, k)
|
| 726 |
+
ys = np.random.randn(n, k)
|
| 727 |
+
ds = distance_matrix(xs, ys)
|
| 728 |
+
dsl = distance_matrix(xs, ys, threshold=1)
|
| 729 |
+
assert_equal(ds, dsl)
|
| 730 |
+
|
| 731 |
+
|
| 732 |
+
def check_onetree_query(T, d):
|
| 733 |
+
r = T.query_ball_tree(T, d)
|
| 734 |
+
s = set()
|
| 735 |
+
for i, l in enumerate(r):
|
| 736 |
+
for j in l:
|
| 737 |
+
if i < j:
|
| 738 |
+
s.add((i, j))
|
| 739 |
+
|
| 740 |
+
assert_(s == T.query_pairs(d))
|
| 741 |
+
|
| 742 |
+
def test_onetree_query(kdtree_type):
|
| 743 |
+
np.random.seed(0)
|
| 744 |
+
n = 50
|
| 745 |
+
k = 4
|
| 746 |
+
points = np.random.randn(n, k)
|
| 747 |
+
T = kdtree_type(points)
|
| 748 |
+
check_onetree_query(T, 0.1)
|
| 749 |
+
|
| 750 |
+
points = np.random.randn(3*n, k)
|
| 751 |
+
points[:n] *= 0.001
|
| 752 |
+
points[n:2*n] += 2
|
| 753 |
+
T = kdtree_type(points)
|
| 754 |
+
check_onetree_query(T, 0.1)
|
| 755 |
+
check_onetree_query(T, 0.001)
|
| 756 |
+
check_onetree_query(T, 0.00001)
|
| 757 |
+
check_onetree_query(T, 1e-6)
|
| 758 |
+
|
| 759 |
+
|
| 760 |
+
def test_query_pairs_single_node(kdtree_type):
|
| 761 |
+
tree = kdtree_type([[0, 1]])
|
| 762 |
+
assert_equal(tree.query_pairs(0.5), set())
|
| 763 |
+
|
| 764 |
+
|
| 765 |
+
def test_kdtree_query_pairs(kdtree_type):
|
| 766 |
+
np.random.seed(0)
|
| 767 |
+
n = 50
|
| 768 |
+
k = 2
|
| 769 |
+
r = 0.1
|
| 770 |
+
r2 = r**2
|
| 771 |
+
points = np.random.randn(n, k)
|
| 772 |
+
T = kdtree_type(points)
|
| 773 |
+
# brute force reference
|
| 774 |
+
brute = set()
|
| 775 |
+
for i in range(n):
|
| 776 |
+
for j in range(i+1, n):
|
| 777 |
+
v = points[i, :] - points[j, :]
|
| 778 |
+
if np.dot(v, v) <= r2:
|
| 779 |
+
brute.add((i, j))
|
| 780 |
+
l0 = sorted(brute)
|
| 781 |
+
# test default return type
|
| 782 |
+
s = T.query_pairs(r)
|
| 783 |
+
l1 = sorted(s)
|
| 784 |
+
assert_array_equal(l0, l1)
|
| 785 |
+
# test return type 'set'
|
| 786 |
+
s = T.query_pairs(r, output_type='set')
|
| 787 |
+
l1 = sorted(s)
|
| 788 |
+
assert_array_equal(l0, l1)
|
| 789 |
+
# test return type 'ndarray'
|
| 790 |
+
s = set()
|
| 791 |
+
arr = T.query_pairs(r, output_type='ndarray')
|
| 792 |
+
for i in range(arr.shape[0]):
|
| 793 |
+
s.add((int(arr[i, 0]), int(arr[i, 1])))
|
| 794 |
+
l2 = sorted(s)
|
| 795 |
+
assert_array_equal(l0, l2)
|
| 796 |
+
|
| 797 |
+
|
| 798 |
+
def test_query_pairs_eps(kdtree_type):
|
| 799 |
+
spacing = np.sqrt(2)
|
| 800 |
+
# irrational spacing to have potential rounding errors
|
| 801 |
+
x_range = np.linspace(0, 3 * spacing, 4)
|
| 802 |
+
y_range = np.linspace(0, 3 * spacing, 4)
|
| 803 |
+
xy_array = [(xi, yi) for xi in x_range for yi in y_range]
|
| 804 |
+
tree = kdtree_type(xy_array)
|
| 805 |
+
pairs_eps = tree.query_pairs(r=spacing, eps=.1)
|
| 806 |
+
# result: 24 with eps, 16 without due to rounding
|
| 807 |
+
pairs = tree.query_pairs(r=spacing * 1.01)
|
| 808 |
+
# result: 24
|
| 809 |
+
assert_equal(pairs, pairs_eps)
|
| 810 |
+
|
| 811 |
+
|
| 812 |
+
def test_ball_point_ints(kdtree_type):
|
| 813 |
+
# Regression test for #1373.
|
| 814 |
+
x, y = np.mgrid[0:4, 0:4]
|
| 815 |
+
points = list(zip(x.ravel(), y.ravel()))
|
| 816 |
+
tree = kdtree_type(points)
|
| 817 |
+
assert_equal(sorted([4, 8, 9, 12]),
|
| 818 |
+
sorted(tree.query_ball_point((2, 0), 1)))
|
| 819 |
+
points = np.asarray(points, dtype=float)
|
| 820 |
+
tree = kdtree_type(points)
|
| 821 |
+
assert_equal(sorted([4, 8, 9, 12]),
|
| 822 |
+
sorted(tree.query_ball_point((2, 0), 1)))
|
| 823 |
+
|
| 824 |
+
|
| 825 |
+
def test_kdtree_comparisons():
|
| 826 |
+
# Regression test: node comparisons were done wrong in 0.12 w/Py3.
|
| 827 |
+
nodes = [KDTree.node() for _ in range(3)]
|
| 828 |
+
assert_equal(sorted(nodes), sorted(nodes[::-1]))
|
| 829 |
+
|
| 830 |
+
|
| 831 |
+
def test_kdtree_build_modes(kdtree_type):
|
| 832 |
+
# check if different build modes for KDTree give similar query results
|
| 833 |
+
np.random.seed(0)
|
| 834 |
+
n = 5000
|
| 835 |
+
k = 4
|
| 836 |
+
points = np.random.randn(n, k)
|
| 837 |
+
T1 = kdtree_type(points).query(points, k=5)[-1]
|
| 838 |
+
T2 = kdtree_type(points, compact_nodes=False).query(points, k=5)[-1]
|
| 839 |
+
T3 = kdtree_type(points, balanced_tree=False).query(points, k=5)[-1]
|
| 840 |
+
T4 = kdtree_type(points, compact_nodes=False,
|
| 841 |
+
balanced_tree=False).query(points, k=5)[-1]
|
| 842 |
+
assert_array_equal(T1, T2)
|
| 843 |
+
assert_array_equal(T1, T3)
|
| 844 |
+
assert_array_equal(T1, T4)
|
| 845 |
+
|
| 846 |
+
def test_kdtree_pickle(kdtree_type):
|
| 847 |
+
# test if it is possible to pickle a KDTree
|
| 848 |
+
import pickle
|
| 849 |
+
np.random.seed(0)
|
| 850 |
+
n = 50
|
| 851 |
+
k = 4
|
| 852 |
+
points = np.random.randn(n, k)
|
| 853 |
+
T1 = kdtree_type(points)
|
| 854 |
+
tmp = pickle.dumps(T1)
|
| 855 |
+
T2 = pickle.loads(tmp)
|
| 856 |
+
T1 = T1.query(points, k=5)[-1]
|
| 857 |
+
T2 = T2.query(points, k=5)[-1]
|
| 858 |
+
assert_array_equal(T1, T2)
|
| 859 |
+
|
| 860 |
+
def test_kdtree_pickle_boxsize(kdtree_type):
|
| 861 |
+
# test if it is possible to pickle a periodic KDTree
|
| 862 |
+
import pickle
|
| 863 |
+
np.random.seed(0)
|
| 864 |
+
n = 50
|
| 865 |
+
k = 4
|
| 866 |
+
points = np.random.uniform(size=(n, k))
|
| 867 |
+
T1 = kdtree_type(points, boxsize=1.0)
|
| 868 |
+
tmp = pickle.dumps(T1)
|
| 869 |
+
T2 = pickle.loads(tmp)
|
| 870 |
+
T1 = T1.query(points, k=5)[-1]
|
| 871 |
+
T2 = T2.query(points, k=5)[-1]
|
| 872 |
+
assert_array_equal(T1, T2)
|
| 873 |
+
|
| 874 |
+
def test_kdtree_copy_data(kdtree_type):
|
| 875 |
+
# check if copy_data=True makes the kd-tree
|
| 876 |
+
# impervious to data corruption by modification of
|
| 877 |
+
# the data arrray
|
| 878 |
+
np.random.seed(0)
|
| 879 |
+
n = 5000
|
| 880 |
+
k = 4
|
| 881 |
+
points = np.random.randn(n, k)
|
| 882 |
+
T = kdtree_type(points, copy_data=True)
|
| 883 |
+
q = points.copy()
|
| 884 |
+
T1 = T.query(q, k=5)[-1]
|
| 885 |
+
points[...] = np.random.randn(n, k)
|
| 886 |
+
T2 = T.query(q, k=5)[-1]
|
| 887 |
+
assert_array_equal(T1, T2)
|
| 888 |
+
|
| 889 |
+
def test_ckdtree_parallel(kdtree_type, monkeypatch):
|
| 890 |
+
# check if parallel=True also generates correct query results
|
| 891 |
+
np.random.seed(0)
|
| 892 |
+
n = 5000
|
| 893 |
+
k = 4
|
| 894 |
+
points = np.random.randn(n, k)
|
| 895 |
+
T = kdtree_type(points)
|
| 896 |
+
T1 = T.query(points, k=5, workers=64)[-1]
|
| 897 |
+
T2 = T.query(points, k=5, workers=-1)[-1]
|
| 898 |
+
T3 = T.query(points, k=5)[-1]
|
| 899 |
+
assert_array_equal(T1, T2)
|
| 900 |
+
assert_array_equal(T1, T3)
|
| 901 |
+
|
| 902 |
+
monkeypatch.setattr(os, 'cpu_count', lambda: None)
|
| 903 |
+
with pytest.raises(NotImplementedError, match="Cannot determine the"):
|
| 904 |
+
T.query(points, 1, workers=-1)
|
| 905 |
+
|
| 906 |
+
|
| 907 |
+
def test_ckdtree_view():
|
| 908 |
+
# Check that the nodes can be correctly viewed from Python.
|
| 909 |
+
# This test also sanity checks each node in the cKDTree, and
|
| 910 |
+
# thus verifies the internal structure of the kd-tree.
|
| 911 |
+
np.random.seed(0)
|
| 912 |
+
n = 100
|
| 913 |
+
k = 4
|
| 914 |
+
points = np.random.randn(n, k)
|
| 915 |
+
kdtree = cKDTree(points)
|
| 916 |
+
|
| 917 |
+
# walk the whole kd-tree and sanity check each node
|
| 918 |
+
def recurse_tree(n):
|
| 919 |
+
assert_(isinstance(n, cKDTreeNode))
|
| 920 |
+
if n.split_dim == -1:
|
| 921 |
+
assert_(n.lesser is None)
|
| 922 |
+
assert_(n.greater is None)
|
| 923 |
+
assert_(n.indices.shape[0] <= kdtree.leafsize)
|
| 924 |
+
else:
|
| 925 |
+
recurse_tree(n.lesser)
|
| 926 |
+
recurse_tree(n.greater)
|
| 927 |
+
x = n.lesser.data_points[:, n.split_dim]
|
| 928 |
+
y = n.greater.data_points[:, n.split_dim]
|
| 929 |
+
assert_(x.max() < y.min())
|
| 930 |
+
|
| 931 |
+
recurse_tree(kdtree.tree)
|
| 932 |
+
# check that indices are correctly retrieved
|
| 933 |
+
n = kdtree.tree
|
| 934 |
+
assert_array_equal(np.sort(n.indices), range(100))
|
| 935 |
+
# check that data_points are correctly retrieved
|
| 936 |
+
assert_array_equal(kdtree.data[n.indices, :], n.data_points)
|
| 937 |
+
|
| 938 |
+
# KDTree is specialized to type double points, so no need to make
|
| 939 |
+
# a unit test corresponding to test_ball_point_ints()
|
| 940 |
+
|
| 941 |
+
def test_kdtree_list_k(kdtree_type):
|
| 942 |
+
# check kdtree periodic boundary
|
| 943 |
+
n = 200
|
| 944 |
+
m = 2
|
| 945 |
+
klist = [1, 2, 3]
|
| 946 |
+
kint = 3
|
| 947 |
+
|
| 948 |
+
np.random.seed(1234)
|
| 949 |
+
data = np.random.uniform(size=(n, m))
|
| 950 |
+
kdtree = kdtree_type(data, leafsize=1)
|
| 951 |
+
|
| 952 |
+
# check agreement between arange(1, k+1) and k
|
| 953 |
+
dd, ii = kdtree.query(data, klist)
|
| 954 |
+
dd1, ii1 = kdtree.query(data, kint)
|
| 955 |
+
assert_equal(dd, dd1)
|
| 956 |
+
assert_equal(ii, ii1)
|
| 957 |
+
|
| 958 |
+
# now check skipping one element
|
| 959 |
+
klist = np.array([1, 3])
|
| 960 |
+
kint = 3
|
| 961 |
+
dd, ii = kdtree.query(data, kint)
|
| 962 |
+
dd1, ii1 = kdtree.query(data, klist)
|
| 963 |
+
assert_equal(dd1, dd[..., klist - 1])
|
| 964 |
+
assert_equal(ii1, ii[..., klist - 1])
|
| 965 |
+
|
| 966 |
+
# check k == 1 special case
|
| 967 |
+
# and k == [1] non-special case
|
| 968 |
+
dd, ii = kdtree.query(data, 1)
|
| 969 |
+
dd1, ii1 = kdtree.query(data, [1])
|
| 970 |
+
assert_equal(len(dd.shape), 1)
|
| 971 |
+
assert_equal(len(dd1.shape), 2)
|
| 972 |
+
assert_equal(dd, np.ravel(dd1))
|
| 973 |
+
assert_equal(ii, np.ravel(ii1))
|
| 974 |
+
|
| 975 |
+
@pytest.mark.fail_slow(10)
|
| 976 |
+
def test_kdtree_box(kdtree_type):
|
| 977 |
+
# check ckdtree periodic boundary
|
| 978 |
+
n = 2000
|
| 979 |
+
m = 3
|
| 980 |
+
k = 3
|
| 981 |
+
np.random.seed(1234)
|
| 982 |
+
data = np.random.uniform(size=(n, m))
|
| 983 |
+
kdtree = kdtree_type(data, leafsize=1, boxsize=1.0)
|
| 984 |
+
|
| 985 |
+
# use the standard python KDTree for the simulated periodic box
|
| 986 |
+
kdtree2 = kdtree_type(data, leafsize=1)
|
| 987 |
+
|
| 988 |
+
for p in [1, 2, 3.0, np.inf]:
|
| 989 |
+
dd, ii = kdtree.query(data, k, p=p)
|
| 990 |
+
|
| 991 |
+
dd1, ii1 = kdtree.query(data + 1.0, k, p=p)
|
| 992 |
+
assert_almost_equal(dd, dd1)
|
| 993 |
+
assert_equal(ii, ii1)
|
| 994 |
+
|
| 995 |
+
dd1, ii1 = kdtree.query(data - 1.0, k, p=p)
|
| 996 |
+
assert_almost_equal(dd, dd1)
|
| 997 |
+
assert_equal(ii, ii1)
|
| 998 |
+
|
| 999 |
+
dd2, ii2 = simulate_periodic_box(kdtree2, data, k, boxsize=1.0, p=p)
|
| 1000 |
+
assert_almost_equal(dd, dd2)
|
| 1001 |
+
assert_equal(ii, ii2)
|
| 1002 |
+
|
| 1003 |
+
def test_kdtree_box_0boxsize(kdtree_type):
|
| 1004 |
+
# check ckdtree periodic boundary that mimics non-periodic
|
| 1005 |
+
n = 2000
|
| 1006 |
+
m = 2
|
| 1007 |
+
k = 3
|
| 1008 |
+
np.random.seed(1234)
|
| 1009 |
+
data = np.random.uniform(size=(n, m))
|
| 1010 |
+
kdtree = kdtree_type(data, leafsize=1, boxsize=0.0)
|
| 1011 |
+
|
| 1012 |
+
# use the standard python KDTree for the simulated periodic box
|
| 1013 |
+
kdtree2 = kdtree_type(data, leafsize=1)
|
| 1014 |
+
|
| 1015 |
+
for p in [1, 2, np.inf]:
|
| 1016 |
+
dd, ii = kdtree.query(data, k, p=p)
|
| 1017 |
+
|
| 1018 |
+
dd1, ii1 = kdtree2.query(data, k, p=p)
|
| 1019 |
+
assert_almost_equal(dd, dd1)
|
| 1020 |
+
assert_equal(ii, ii1)
|
| 1021 |
+
|
| 1022 |
+
def test_kdtree_box_upper_bounds(kdtree_type):
|
| 1023 |
+
data = np.linspace(0, 2, 10).reshape(-1, 2)
|
| 1024 |
+
data[:, 1] += 10
|
| 1025 |
+
with pytest.raises(ValueError):
|
| 1026 |
+
kdtree_type(data, leafsize=1, boxsize=1.0)
|
| 1027 |
+
with pytest.raises(ValueError):
|
| 1028 |
+
kdtree_type(data, leafsize=1, boxsize=(0.0, 2.0))
|
| 1029 |
+
# skip a dimension.
|
| 1030 |
+
kdtree_type(data, leafsize=1, boxsize=(2.0, 0.0))
|
| 1031 |
+
|
| 1032 |
+
def test_kdtree_box_lower_bounds(kdtree_type):
|
| 1033 |
+
data = np.linspace(-1, 1, 10)
|
| 1034 |
+
assert_raises(ValueError, kdtree_type, data, leafsize=1, boxsize=1.0)
|
| 1035 |
+
|
| 1036 |
+
def simulate_periodic_box(kdtree, data, k, boxsize, p):
|
| 1037 |
+
dd = []
|
| 1038 |
+
ii = []
|
| 1039 |
+
x = np.arange(3 ** data.shape[1])
|
| 1040 |
+
nn = np.array(np.unravel_index(x, [3] * data.shape[1])).T
|
| 1041 |
+
nn = nn - 1.0
|
| 1042 |
+
for n in nn:
|
| 1043 |
+
image = data + n * 1.0 * boxsize
|
| 1044 |
+
dd2, ii2 = kdtree.query(image, k, p=p)
|
| 1045 |
+
dd2 = dd2.reshape(-1, k)
|
| 1046 |
+
ii2 = ii2.reshape(-1, k)
|
| 1047 |
+
dd.append(dd2)
|
| 1048 |
+
ii.append(ii2)
|
| 1049 |
+
dd = np.concatenate(dd, axis=-1)
|
| 1050 |
+
ii = np.concatenate(ii, axis=-1)
|
| 1051 |
+
|
| 1052 |
+
result = np.empty([len(data), len(nn) * k], dtype=[
|
| 1053 |
+
('ii', 'i8'),
|
| 1054 |
+
('dd', 'f8')])
|
| 1055 |
+
result['ii'][:] = ii
|
| 1056 |
+
result['dd'][:] = dd
|
| 1057 |
+
result.sort(order='dd')
|
| 1058 |
+
return result['dd'][:, :k], result['ii'][:, :k]
|
| 1059 |
+
|
| 1060 |
+
|
| 1061 |
+
@pytest.mark.skipif(python_implementation() == 'PyPy',
|
| 1062 |
+
reason="Fails on PyPy CI runs. See #9507")
|
| 1063 |
+
def test_ckdtree_memuse():
|
| 1064 |
+
# unit test adaptation of gh-5630
|
| 1065 |
+
|
| 1066 |
+
# NOTE: this will fail when run via valgrind,
|
| 1067 |
+
# because rss is no longer a reliable memory usage indicator.
|
| 1068 |
+
|
| 1069 |
+
try:
|
| 1070 |
+
import resource
|
| 1071 |
+
except ImportError:
|
| 1072 |
+
# resource is not available on Windows
|
| 1073 |
+
return
|
| 1074 |
+
# Make some data
|
| 1075 |
+
dx, dy = 0.05, 0.05
|
| 1076 |
+
y, x = np.mgrid[slice(1, 5 + dy, dy),
|
| 1077 |
+
slice(1, 5 + dx, dx)]
|
| 1078 |
+
z = np.sin(x)**10 + np.cos(10 + y*x) * np.cos(x)
|
| 1079 |
+
z_copy = np.empty_like(z)
|
| 1080 |
+
z_copy[:] = z
|
| 1081 |
+
# Place FILLVAL in z_copy at random number of random locations
|
| 1082 |
+
FILLVAL = 99.
|
| 1083 |
+
mask = np.random.randint(0, z.size, np.random.randint(50) + 5)
|
| 1084 |
+
z_copy.flat[mask] = FILLVAL
|
| 1085 |
+
igood = np.vstack(np.nonzero(x != FILLVAL)).T
|
| 1086 |
+
ibad = np.vstack(np.nonzero(x == FILLVAL)).T
|
| 1087 |
+
mem_use = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
| 1088 |
+
# burn-in
|
| 1089 |
+
for i in range(10):
|
| 1090 |
+
tree = cKDTree(igood)
|
| 1091 |
+
# count memleaks while constructing and querying cKDTree
|
| 1092 |
+
num_leaks = 0
|
| 1093 |
+
for i in range(100):
|
| 1094 |
+
mem_use = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
| 1095 |
+
tree = cKDTree(igood)
|
| 1096 |
+
dist, iquery = tree.query(ibad, k=4, p=2)
|
| 1097 |
+
new_mem_use = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
|
| 1098 |
+
if new_mem_use > mem_use:
|
| 1099 |
+
num_leaks += 1
|
| 1100 |
+
# ideally zero leaks, but errors might accidentally happen
|
| 1101 |
+
# outside cKDTree
|
| 1102 |
+
assert_(num_leaks < 10)
|
| 1103 |
+
|
| 1104 |
+
def test_kdtree_weights(kdtree_type):
|
| 1105 |
+
|
| 1106 |
+
data = np.linspace(0, 1, 4).reshape(-1, 1)
|
| 1107 |
+
tree1 = kdtree_type(data, leafsize=1)
|
| 1108 |
+
weights = np.ones(len(data), dtype='f4')
|
| 1109 |
+
|
| 1110 |
+
nw = tree1._build_weights(weights)
|
| 1111 |
+
assert_array_equal(nw, [4, 2, 1, 1, 2, 1, 1])
|
| 1112 |
+
|
| 1113 |
+
assert_raises(ValueError, tree1._build_weights, weights[:-1])
|
| 1114 |
+
|
| 1115 |
+
for i in range(10):
|
| 1116 |
+
# since weights are uniform, these shall agree:
|
| 1117 |
+
c1 = tree1.count_neighbors(tree1, np.linspace(0, 10, i))
|
| 1118 |
+
c2 = tree1.count_neighbors(tree1, np.linspace(0, 10, i),
|
| 1119 |
+
weights=(weights, weights))
|
| 1120 |
+
c3 = tree1.count_neighbors(tree1, np.linspace(0, 10, i),
|
| 1121 |
+
weights=(weights, None))
|
| 1122 |
+
c4 = tree1.count_neighbors(tree1, np.linspace(0, 10, i),
|
| 1123 |
+
weights=(None, weights))
|
| 1124 |
+
tree1.count_neighbors(tree1, np.linspace(0, 10, i),
|
| 1125 |
+
weights=weights)
|
| 1126 |
+
|
| 1127 |
+
assert_array_equal(c1, c2)
|
| 1128 |
+
assert_array_equal(c1, c3)
|
| 1129 |
+
assert_array_equal(c1, c4)
|
| 1130 |
+
|
| 1131 |
+
for i in range(len(data)):
|
| 1132 |
+
# this tests removal of one data point by setting weight to 0
|
| 1133 |
+
w1 = weights.copy()
|
| 1134 |
+
w1[i] = 0
|
| 1135 |
+
data2 = data[w1 != 0]
|
| 1136 |
+
tree2 = kdtree_type(data2)
|
| 1137 |
+
|
| 1138 |
+
c1 = tree1.count_neighbors(tree1, np.linspace(0, 10, 100),
|
| 1139 |
+
weights=(w1, w1))
|
| 1140 |
+
# "c2 is correct"
|
| 1141 |
+
c2 = tree2.count_neighbors(tree2, np.linspace(0, 10, 100))
|
| 1142 |
+
|
| 1143 |
+
assert_array_equal(c1, c2)
|
| 1144 |
+
|
| 1145 |
+
#this asserts for two different trees, singular weights
|
| 1146 |
+
# crashes
|
| 1147 |
+
assert_raises(ValueError, tree1.count_neighbors,
|
| 1148 |
+
tree2, np.linspace(0, 10, 100), weights=w1)
|
| 1149 |
+
|
| 1150 |
+
@pytest.mark.fail_slow(10)
|
| 1151 |
+
def test_kdtree_count_neighbous_multiple_r(kdtree_type):
|
| 1152 |
+
n = 2000
|
| 1153 |
+
m = 2
|
| 1154 |
+
np.random.seed(1234)
|
| 1155 |
+
data = np.random.normal(size=(n, m))
|
| 1156 |
+
kdtree = kdtree_type(data, leafsize=1)
|
| 1157 |
+
r0 = [0, 0.01, 0.01, 0.02, 0.05]
|
| 1158 |
+
i0 = np.arange(len(r0))
|
| 1159 |
+
n0 = kdtree.count_neighbors(kdtree, r0)
|
| 1160 |
+
nnc = kdtree.count_neighbors(kdtree, r0, cumulative=False)
|
| 1161 |
+
assert_equal(n0, nnc.cumsum())
|
| 1162 |
+
|
| 1163 |
+
for i, r in zip(itertools.permutations(i0),
|
| 1164 |
+
itertools.permutations(r0)):
|
| 1165 |
+
# permute n0 by i and it shall agree
|
| 1166 |
+
n = kdtree.count_neighbors(kdtree, r)
|
| 1167 |
+
assert_array_equal(n, n0[list(i)])
|
| 1168 |
+
|
| 1169 |
+
def test_len0_arrays(kdtree_type):
|
| 1170 |
+
# make sure len-0 arrays are handled correctly
|
| 1171 |
+
# in range queries (gh-5639)
|
| 1172 |
+
rng = np.random.RandomState(1234)
|
| 1173 |
+
X = rng.rand(10, 2)
|
| 1174 |
+
Y = rng.rand(10, 2)
|
| 1175 |
+
tree = kdtree_type(X)
|
| 1176 |
+
# query_ball_point (single)
|
| 1177 |
+
d, i = tree.query([.5, .5], k=1)
|
| 1178 |
+
z = tree.query_ball_point([.5, .5], 0.1*d)
|
| 1179 |
+
assert_array_equal(z, [])
|
| 1180 |
+
# query_ball_point (multiple)
|
| 1181 |
+
d, i = tree.query(Y, k=1)
|
| 1182 |
+
mind = d.min()
|
| 1183 |
+
z = tree.query_ball_point(Y, 0.1*mind)
|
| 1184 |
+
y = np.empty(shape=(10, ), dtype=object)
|
| 1185 |
+
y.fill([])
|
| 1186 |
+
assert_array_equal(y, z)
|
| 1187 |
+
# query_ball_tree
|
| 1188 |
+
other = kdtree_type(Y)
|
| 1189 |
+
y = tree.query_ball_tree(other, 0.1*mind)
|
| 1190 |
+
assert_array_equal(10*[[]], y)
|
| 1191 |
+
# count_neighbors
|
| 1192 |
+
y = tree.count_neighbors(other, 0.1*mind)
|
| 1193 |
+
assert_(y == 0)
|
| 1194 |
+
# sparse_distance_matrix
|
| 1195 |
+
y = tree.sparse_distance_matrix(other, 0.1*mind, output_type='dok_matrix')
|
| 1196 |
+
assert_array_equal(y == np.zeros((10, 10)), True)
|
| 1197 |
+
y = tree.sparse_distance_matrix(other, 0.1*mind, output_type='coo_matrix')
|
| 1198 |
+
assert_array_equal(y == np.zeros((10, 10)), True)
|
| 1199 |
+
y = tree.sparse_distance_matrix(other, 0.1*mind, output_type='dict')
|
| 1200 |
+
assert_equal(y, {})
|
| 1201 |
+
y = tree.sparse_distance_matrix(other, 0.1*mind, output_type='ndarray')
|
| 1202 |
+
_dtype = [('i', np.intp), ('j', np.intp), ('v', np.float64)]
|
| 1203 |
+
res_dtype = np.dtype(_dtype, align=True)
|
| 1204 |
+
z = np.empty(shape=(0, ), dtype=res_dtype)
|
| 1205 |
+
assert_array_equal(y, z)
|
| 1206 |
+
# query_pairs
|
| 1207 |
+
d, i = tree.query(X, k=2)
|
| 1208 |
+
mind = d[:, -1].min()
|
| 1209 |
+
y = tree.query_pairs(0.1*mind, output_type='set')
|
| 1210 |
+
assert_equal(y, set())
|
| 1211 |
+
y = tree.query_pairs(0.1*mind, output_type='ndarray')
|
| 1212 |
+
z = np.empty(shape=(0, 2), dtype=np.intp)
|
| 1213 |
+
assert_array_equal(y, z)
|
| 1214 |
+
|
| 1215 |
+
def test_kdtree_duplicated_inputs(kdtree_type):
|
| 1216 |
+
# check kdtree with duplicated inputs
|
| 1217 |
+
n = 1024
|
| 1218 |
+
for m in range(1, 8):
|
| 1219 |
+
data = np.ones((n, m))
|
| 1220 |
+
data[n//2:] = 2
|
| 1221 |
+
|
| 1222 |
+
for balanced, compact in itertools.product((False, True), repeat=2):
|
| 1223 |
+
kdtree = kdtree_type(data, balanced_tree=balanced,
|
| 1224 |
+
compact_nodes=compact, leafsize=1)
|
| 1225 |
+
assert kdtree.size == 3
|
| 1226 |
+
|
| 1227 |
+
tree = (kdtree.tree if kdtree_type is cKDTree else
|
| 1228 |
+
kdtree.tree._node)
|
| 1229 |
+
|
| 1230 |
+
assert_equal(
|
| 1231 |
+
np.sort(tree.lesser.indices),
|
| 1232 |
+
np.arange(0, n // 2))
|
| 1233 |
+
assert_equal(
|
| 1234 |
+
np.sort(tree.greater.indices),
|
| 1235 |
+
np.arange(n // 2, n))
|
| 1236 |
+
|
| 1237 |
+
|
| 1238 |
+
def test_kdtree_noncumulative_nondecreasing(kdtree_type):
|
| 1239 |
+
# check kdtree with duplicated inputs
|
| 1240 |
+
|
| 1241 |
+
# it shall not divide more than 3 nodes.
|
| 1242 |
+
# root left (1), and right (2)
|
| 1243 |
+
kdtree = kdtree_type([[0]], leafsize=1)
|
| 1244 |
+
|
| 1245 |
+
assert_raises(ValueError, kdtree.count_neighbors,
|
| 1246 |
+
kdtree, [0.1, 0], cumulative=False)
|
| 1247 |
+
|
| 1248 |
+
def test_short_knn(kdtree_type):
|
| 1249 |
+
|
| 1250 |
+
# The test case is based on github: #6425 by @SteveDoyle2
|
| 1251 |
+
|
| 1252 |
+
xyz = np.array([
|
| 1253 |
+
[0., 0., 0.],
|
| 1254 |
+
[1.01, 0., 0.],
|
| 1255 |
+
[0., 1., 0.],
|
| 1256 |
+
[0., 1.01, 0.],
|
| 1257 |
+
[1., 0., 0.],
|
| 1258 |
+
[1., 1., 0.]],
|
| 1259 |
+
dtype='float64')
|
| 1260 |
+
|
| 1261 |
+
ckdt = kdtree_type(xyz)
|
| 1262 |
+
|
| 1263 |
+
deq, ieq = ckdt.query(xyz, k=4, distance_upper_bound=0.2)
|
| 1264 |
+
|
| 1265 |
+
assert_array_almost_equal(deq,
|
| 1266 |
+
[[0., np.inf, np.inf, np.inf],
|
| 1267 |
+
[0., 0.01, np.inf, np.inf],
|
| 1268 |
+
[0., 0.01, np.inf, np.inf],
|
| 1269 |
+
[0., 0.01, np.inf, np.inf],
|
| 1270 |
+
[0., 0.01, np.inf, np.inf],
|
| 1271 |
+
[0., np.inf, np.inf, np.inf]])
|
| 1272 |
+
|
| 1273 |
+
def test_query_ball_point_vector_r(kdtree_type):
|
| 1274 |
+
|
| 1275 |
+
np.random.seed(1234)
|
| 1276 |
+
data = np.random.normal(size=(100, 3))
|
| 1277 |
+
query = np.random.normal(size=(100, 3))
|
| 1278 |
+
tree = kdtree_type(data)
|
| 1279 |
+
d = np.random.uniform(0, 0.3, size=len(query))
|
| 1280 |
+
|
| 1281 |
+
rvector = tree.query_ball_point(query, d)
|
| 1282 |
+
rscalar = [tree.query_ball_point(qi, di) for qi, di in zip(query, d)]
|
| 1283 |
+
for a, b in zip(rvector, rscalar):
|
| 1284 |
+
assert_array_equal(sorted(a), sorted(b))
|
| 1285 |
+
|
| 1286 |
+
def test_query_ball_point_length(kdtree_type):
|
| 1287 |
+
|
| 1288 |
+
np.random.seed(1234)
|
| 1289 |
+
data = np.random.normal(size=(100, 3))
|
| 1290 |
+
query = np.random.normal(size=(100, 3))
|
| 1291 |
+
tree = kdtree_type(data)
|
| 1292 |
+
d = 0.3
|
| 1293 |
+
|
| 1294 |
+
length = tree.query_ball_point(query, d, return_length=True)
|
| 1295 |
+
length2 = [len(ind) for ind in tree.query_ball_point(query, d, return_length=False)]
|
| 1296 |
+
length3 = [len(tree.query_ball_point(qi, d)) for qi in query]
|
| 1297 |
+
length4 = [tree.query_ball_point(qi, d, return_length=True) for qi in query]
|
| 1298 |
+
assert_array_equal(length, length2)
|
| 1299 |
+
assert_array_equal(length, length3)
|
| 1300 |
+
assert_array_equal(length, length4)
|
| 1301 |
+
|
| 1302 |
+
def test_discontiguous(kdtree_type):
|
| 1303 |
+
|
| 1304 |
+
np.random.seed(1234)
|
| 1305 |
+
data = np.random.normal(size=(100, 3))
|
| 1306 |
+
d_contiguous = np.arange(100) * 0.04
|
| 1307 |
+
d_discontiguous = np.ascontiguousarray(
|
| 1308 |
+
np.arange(100)[::-1] * 0.04)[::-1]
|
| 1309 |
+
query_contiguous = np.random.normal(size=(100, 3))
|
| 1310 |
+
query_discontiguous = np.ascontiguousarray(query_contiguous.T).T
|
| 1311 |
+
assert query_discontiguous.strides[-1] != query_contiguous.strides[-1]
|
| 1312 |
+
assert d_discontiguous.strides[-1] != d_contiguous.strides[-1]
|
| 1313 |
+
|
| 1314 |
+
tree = kdtree_type(data)
|
| 1315 |
+
|
| 1316 |
+
length1 = tree.query_ball_point(query_contiguous,
|
| 1317 |
+
d_contiguous, return_length=True)
|
| 1318 |
+
length2 = tree.query_ball_point(query_discontiguous,
|
| 1319 |
+
d_discontiguous, return_length=True)
|
| 1320 |
+
|
| 1321 |
+
assert_array_equal(length1, length2)
|
| 1322 |
+
|
| 1323 |
+
d1, i1 = tree.query(query_contiguous, 1)
|
| 1324 |
+
d2, i2 = tree.query(query_discontiguous, 1)
|
| 1325 |
+
|
| 1326 |
+
assert_array_equal(d1, d2)
|
| 1327 |
+
assert_array_equal(i1, i2)
|
| 1328 |
+
|
| 1329 |
+
|
| 1330 |
+
@pytest.mark.parametrize("balanced_tree, compact_nodes",
|
| 1331 |
+
[(True, False),
|
| 1332 |
+
(True, True),
|
| 1333 |
+
(False, False),
|
| 1334 |
+
(False, True)])
|
| 1335 |
+
def test_kdtree_empty_input(kdtree_type, balanced_tree, compact_nodes):
|
| 1336 |
+
# https://github.com/scipy/scipy/issues/5040
|
| 1337 |
+
np.random.seed(1234)
|
| 1338 |
+
empty_v3 = np.empty(shape=(0, 3))
|
| 1339 |
+
query_v3 = np.ones(shape=(1, 3))
|
| 1340 |
+
query_v2 = np.ones(shape=(2, 3))
|
| 1341 |
+
|
| 1342 |
+
tree = kdtree_type(empty_v3, balanced_tree=balanced_tree,
|
| 1343 |
+
compact_nodes=compact_nodes)
|
| 1344 |
+
length = tree.query_ball_point(query_v3, 0.3, return_length=True)
|
| 1345 |
+
assert length == 0
|
| 1346 |
+
|
| 1347 |
+
dd, ii = tree.query(query_v2, 2)
|
| 1348 |
+
assert ii.shape == (2, 2)
|
| 1349 |
+
assert dd.shape == (2, 2)
|
| 1350 |
+
assert np.isinf(dd).all()
|
| 1351 |
+
|
| 1352 |
+
N = tree.count_neighbors(tree, [0, 1])
|
| 1353 |
+
assert_array_equal(N, [0, 0])
|
| 1354 |
+
|
| 1355 |
+
M = tree.sparse_distance_matrix(tree, 0.3)
|
| 1356 |
+
assert M.shape == (0, 0)
|
| 1357 |
+
|
| 1358 |
+
@KDTreeTest
|
| 1359 |
+
class _Test_sorted_query_ball_point:
|
| 1360 |
+
def setup_method(self):
|
| 1361 |
+
np.random.seed(1234)
|
| 1362 |
+
self.x = np.random.randn(100, 1)
|
| 1363 |
+
self.ckdt = self.kdtree_type(self.x)
|
| 1364 |
+
|
| 1365 |
+
def test_return_sorted_True(self):
|
| 1366 |
+
idxs_list = self.ckdt.query_ball_point(self.x, 1., return_sorted=True)
|
| 1367 |
+
for idxs in idxs_list:
|
| 1368 |
+
assert_array_equal(idxs, sorted(idxs))
|
| 1369 |
+
|
| 1370 |
+
for xi in self.x:
|
| 1371 |
+
idxs = self.ckdt.query_ball_point(xi, 1., return_sorted=True)
|
| 1372 |
+
assert_array_equal(idxs, sorted(idxs))
|
| 1373 |
+
|
| 1374 |
+
def test_return_sorted_None(self):
|
| 1375 |
+
"""Previous behavior was to sort the returned indices if there were
|
| 1376 |
+
multiple points per query but not sort them if there was a single point
|
| 1377 |
+
per query."""
|
| 1378 |
+
idxs_list = self.ckdt.query_ball_point(self.x, 1.)
|
| 1379 |
+
for idxs in idxs_list:
|
| 1380 |
+
assert_array_equal(idxs, sorted(idxs))
|
| 1381 |
+
|
| 1382 |
+
idxs_list_single = [self.ckdt.query_ball_point(xi, 1.) for xi in self.x]
|
| 1383 |
+
idxs_list_False = self.ckdt.query_ball_point(self.x, 1., return_sorted=False)
|
| 1384 |
+
for idxs0, idxs1 in zip(idxs_list_False, idxs_list_single):
|
| 1385 |
+
assert_array_equal(idxs0, idxs1)
|
| 1386 |
+
|
| 1387 |
+
|
| 1388 |
+
def test_kdtree_complex_data():
|
| 1389 |
+
# Test that KDTree rejects complex input points (gh-9108)
|
| 1390 |
+
points = np.random.rand(10, 2).view(complex)
|
| 1391 |
+
|
| 1392 |
+
with pytest.raises(TypeError, match="complex data"):
|
| 1393 |
+
t = KDTree(points)
|
| 1394 |
+
|
| 1395 |
+
t = KDTree(points.real)
|
| 1396 |
+
|
| 1397 |
+
with pytest.raises(TypeError, match="complex data"):
|
| 1398 |
+
t.query(points)
|
| 1399 |
+
|
| 1400 |
+
with pytest.raises(TypeError, match="complex data"):
|
| 1401 |
+
t.query_ball_point(points, r=1)
|
| 1402 |
+
|
| 1403 |
+
|
| 1404 |
+
def test_kdtree_tree_access():
|
| 1405 |
+
# Test KDTree.tree can be used to traverse the KDTree
|
| 1406 |
+
np.random.seed(1234)
|
| 1407 |
+
points = np.random.rand(100, 4)
|
| 1408 |
+
t = KDTree(points)
|
| 1409 |
+
root = t.tree
|
| 1410 |
+
|
| 1411 |
+
assert isinstance(root, KDTree.innernode)
|
| 1412 |
+
assert root.children == points.shape[0]
|
| 1413 |
+
|
| 1414 |
+
# Visit the tree and assert some basic properties for each node
|
| 1415 |
+
nodes = [root]
|
| 1416 |
+
while nodes:
|
| 1417 |
+
n = nodes.pop(-1)
|
| 1418 |
+
|
| 1419 |
+
if isinstance(n, KDTree.leafnode):
|
| 1420 |
+
assert isinstance(n.children, int)
|
| 1421 |
+
assert n.children == len(n.idx)
|
| 1422 |
+
assert_array_equal(points[n.idx], n._node.data_points)
|
| 1423 |
+
else:
|
| 1424 |
+
assert isinstance(n, KDTree.innernode)
|
| 1425 |
+
assert isinstance(n.split_dim, int)
|
| 1426 |
+
assert 0 <= n.split_dim < t.m
|
| 1427 |
+
assert isinstance(n.split, float)
|
| 1428 |
+
assert isinstance(n.children, int)
|
| 1429 |
+
assert n.children == n.less.children + n.greater.children
|
| 1430 |
+
nodes.append(n.greater)
|
| 1431 |
+
nodes.append(n.less)
|
| 1432 |
+
|
| 1433 |
+
|
| 1434 |
+
def test_kdtree_attributes():
|
| 1435 |
+
# Test KDTree's attributes are available
|
| 1436 |
+
np.random.seed(1234)
|
| 1437 |
+
points = np.random.rand(100, 4)
|
| 1438 |
+
t = KDTree(points)
|
| 1439 |
+
|
| 1440 |
+
assert isinstance(t.m, int)
|
| 1441 |
+
assert t.n == points.shape[0]
|
| 1442 |
+
|
| 1443 |
+
assert isinstance(t.n, int)
|
| 1444 |
+
assert t.m == points.shape[1]
|
| 1445 |
+
|
| 1446 |
+
assert isinstance(t.leafsize, int)
|
| 1447 |
+
assert t.leafsize == 10
|
| 1448 |
+
|
| 1449 |
+
assert_array_equal(t.maxes, np.amax(points, axis=0))
|
| 1450 |
+
assert_array_equal(t.mins, np.amin(points, axis=0))
|
| 1451 |
+
assert t.data is points
|
| 1452 |
+
|
| 1453 |
+
|
| 1454 |
+
@pytest.mark.parametrize("kdtree_class", [KDTree, cKDTree])
|
| 1455 |
+
def test_kdtree_count_neighbors_weighted(kdtree_class):
|
| 1456 |
+
rng = np.random.RandomState(1234)
|
| 1457 |
+
r = np.arange(0.05, 1, 0.05)
|
| 1458 |
+
|
| 1459 |
+
A = rng.random(21).reshape((7,3))
|
| 1460 |
+
B = rng.random(45).reshape((15,3))
|
| 1461 |
+
|
| 1462 |
+
wA = rng.random(7)
|
| 1463 |
+
wB = rng.random(15)
|
| 1464 |
+
|
| 1465 |
+
kdA = kdtree_class(A)
|
| 1466 |
+
kdB = kdtree_class(B)
|
| 1467 |
+
|
| 1468 |
+
nAB = kdA.count_neighbors(kdB, r, cumulative=False, weights=(wA,wB))
|
| 1469 |
+
|
| 1470 |
+
# Compare against brute-force
|
| 1471 |
+
weights = wA[None, :] * wB[:, None]
|
| 1472 |
+
dist = np.linalg.norm(A[None, :, :] - B[:, None, :], axis=-1)
|
| 1473 |
+
expect = [np.sum(weights[(prev_radius < dist) & (dist <= radius)])
|
| 1474 |
+
for prev_radius, radius in zip(itertools.chain([0], r[:-1]), r)]
|
| 1475 |
+
assert_allclose(nAB, expect)
|
| 1476 |
+
|
| 1477 |
+
|
| 1478 |
+
def test_kdtree_nan():
|
| 1479 |
+
vals = [1, 5, -10, 7, -4, -16, -6, 6, 3, -11]
|
| 1480 |
+
n = len(vals)
|
| 1481 |
+
data = np.concatenate([vals, np.full(n, np.nan)])[:, None]
|
| 1482 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1483 |
+
KDTree(data)
|
| 1484 |
+
|
| 1485 |
+
|
| 1486 |
+
def test_nonfinite_inputs_gh_18223():
|
| 1487 |
+
rng = np.random.default_rng(12345)
|
| 1488 |
+
coords = rng.uniform(size=(100, 3), low=0.0, high=0.1)
|
| 1489 |
+
t = KDTree(coords, balanced_tree=False, compact_nodes=False)
|
| 1490 |
+
bad_coord = [np.nan for _ in range(3)]
|
| 1491 |
+
|
| 1492 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1493 |
+
t.query(bad_coord)
|
| 1494 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1495 |
+
t.query_ball_point(bad_coord, 1)
|
| 1496 |
+
|
| 1497 |
+
coords[0, :] = np.nan
|
| 1498 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1499 |
+
KDTree(coords, balanced_tree=True, compact_nodes=False)
|
| 1500 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1501 |
+
KDTree(coords, balanced_tree=False, compact_nodes=True)
|
| 1502 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1503 |
+
KDTree(coords, balanced_tree=True, compact_nodes=True)
|
| 1504 |
+
with pytest.raises(ValueError, match="must be finite"):
|
| 1505 |
+
KDTree(coords, balanced_tree=False, compact_nodes=False)
|
| 1506 |
+
|
| 1507 |
+
|
| 1508 |
+
@pytest.mark.parametrize("incantation", [cKDTree, KDTree])
|
| 1509 |
+
def test_gh_18800(incantation):
|
| 1510 |
+
# our prohibition on non-finite values
|
| 1511 |
+
# in kd-tree workflows means we need
|
| 1512 |
+
# coercion to NumPy arrays enforced
|
| 1513 |
+
|
| 1514 |
+
class ArrLike(np.ndarray):
|
| 1515 |
+
def __new__(cls, input_array):
|
| 1516 |
+
obj = np.asarray(input_array).view(cls)
|
| 1517 |
+
# we override all() to mimic the problem
|
| 1518 |
+
# pandas DataFrames encountered in gh-18800
|
| 1519 |
+
obj.all = None
|
| 1520 |
+
return obj
|
| 1521 |
+
|
| 1522 |
+
def __array_finalize__(self, obj):
|
| 1523 |
+
if obj is None:
|
| 1524 |
+
return
|
| 1525 |
+
self.all = getattr(obj, 'all', None)
|
| 1526 |
+
|
| 1527 |
+
points = [
|
| 1528 |
+
[66.22, 32.54],
|
| 1529 |
+
[22.52, 22.39],
|
| 1530 |
+
[31.01, 81.21],
|
| 1531 |
+
]
|
| 1532 |
+
arr = np.array(points)
|
| 1533 |
+
arr_like = ArrLike(arr)
|
| 1534 |
+
tree = incantation(points, 10)
|
| 1535 |
+
tree.query(arr_like, 1)
|
| 1536 |
+
tree.query_ball_point(arr_like, 200)
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_qhull.py
ADDED
|
@@ -0,0 +1,1311 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import copy
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
from numpy.testing import (assert_equal, assert_almost_equal,
|
| 6 |
+
assert_, assert_allclose, assert_array_equal)
|
| 7 |
+
import pytest
|
| 8 |
+
from pytest import raises as assert_raises
|
| 9 |
+
|
| 10 |
+
import scipy.spatial._qhull as qhull
|
| 11 |
+
from scipy.spatial import cKDTree as KDTree # type: ignore[attr-defined]
|
| 12 |
+
from scipy.spatial import Voronoi
|
| 13 |
+
|
| 14 |
+
import itertools
|
| 15 |
+
|
| 16 |
+
def sorted_tuple(x):
|
| 17 |
+
return tuple(sorted(x))
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def assert_unordered_tuple_list_equal(a, b, tpl=tuple):
|
| 21 |
+
if isinstance(a, np.ndarray):
|
| 22 |
+
a = a.tolist()
|
| 23 |
+
if isinstance(b, np.ndarray):
|
| 24 |
+
b = b.tolist()
|
| 25 |
+
a = list(map(tpl, a))
|
| 26 |
+
a.sort()
|
| 27 |
+
b = list(map(tpl, b))
|
| 28 |
+
b.sort()
|
| 29 |
+
assert_equal(a, b)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
np.random.seed(1234)
|
| 33 |
+
|
| 34 |
+
points = [(0,0), (0,1), (1,0), (1,1), (0.5, 0.5), (0.5, 1.5)]
|
| 35 |
+
|
| 36 |
+
pathological_data_1 = np.array([
|
| 37 |
+
[-3.14,-3.14], [-3.14,-2.36], [-3.14,-1.57], [-3.14,-0.79],
|
| 38 |
+
[-3.14,0.0], [-3.14,0.79], [-3.14,1.57], [-3.14,2.36],
|
| 39 |
+
[-3.14,3.14], [-2.36,-3.14], [-2.36,-2.36], [-2.36,-1.57],
|
| 40 |
+
[-2.36,-0.79], [-2.36,0.0], [-2.36,0.79], [-2.36,1.57],
|
| 41 |
+
[-2.36,2.36], [-2.36,3.14], [-1.57,-0.79], [-1.57,0.79],
|
| 42 |
+
[-1.57,-1.57], [-1.57,0.0], [-1.57,1.57], [-1.57,-3.14],
|
| 43 |
+
[-1.57,-2.36], [-1.57,2.36], [-1.57,3.14], [-0.79,-1.57],
|
| 44 |
+
[-0.79,1.57], [-0.79,-3.14], [-0.79,-2.36], [-0.79,-0.79],
|
| 45 |
+
[-0.79,0.0], [-0.79,0.79], [-0.79,2.36], [-0.79,3.14],
|
| 46 |
+
[0.0,-3.14], [0.0,-2.36], [0.0,-1.57], [0.0,-0.79], [0.0,0.0],
|
| 47 |
+
[0.0,0.79], [0.0,1.57], [0.0,2.36], [0.0,3.14], [0.79,-3.14],
|
| 48 |
+
[0.79,-2.36], [0.79,-0.79], [0.79,0.0], [0.79,0.79],
|
| 49 |
+
[0.79,2.36], [0.79,3.14], [0.79,-1.57], [0.79,1.57],
|
| 50 |
+
[1.57,-3.14], [1.57,-2.36], [1.57,2.36], [1.57,3.14],
|
| 51 |
+
[1.57,-1.57], [1.57,0.0], [1.57,1.57], [1.57,-0.79],
|
| 52 |
+
[1.57,0.79], [2.36,-3.14], [2.36,-2.36], [2.36,-1.57],
|
| 53 |
+
[2.36,-0.79], [2.36,0.0], [2.36,0.79], [2.36,1.57],
|
| 54 |
+
[2.36,2.36], [2.36,3.14], [3.14,-3.14], [3.14,-2.36],
|
| 55 |
+
[3.14,-1.57], [3.14,-0.79], [3.14,0.0], [3.14,0.79],
|
| 56 |
+
[3.14,1.57], [3.14,2.36], [3.14,3.14],
|
| 57 |
+
])
|
| 58 |
+
|
| 59 |
+
pathological_data_2 = np.array([
|
| 60 |
+
[-1, -1], [-1, 0], [-1, 1],
|
| 61 |
+
[0, -1], [0, 0], [0, 1],
|
| 62 |
+
[1, -1 - np.finfo(np.float64).eps], [1, 0], [1, 1],
|
| 63 |
+
])
|
| 64 |
+
|
| 65 |
+
bug_2850_chunks = [np.random.rand(10, 2),
|
| 66 |
+
np.array([[0,0], [0,1], [1,0], [1,1]]) # add corners
|
| 67 |
+
]
|
| 68 |
+
|
| 69 |
+
# same with some additional chunks
|
| 70 |
+
bug_2850_chunks_2 = (bug_2850_chunks +
|
| 71 |
+
[np.random.rand(10, 2),
|
| 72 |
+
0.25 + np.array([[0,0], [0,1], [1,0], [1,1]])])
|
| 73 |
+
|
| 74 |
+
DATASETS = {
|
| 75 |
+
'some-points': np.asarray(points),
|
| 76 |
+
'random-2d': np.random.rand(30, 2),
|
| 77 |
+
'random-3d': np.random.rand(30, 3),
|
| 78 |
+
'random-4d': np.random.rand(30, 4),
|
| 79 |
+
'random-5d': np.random.rand(30, 5),
|
| 80 |
+
'random-6d': np.random.rand(10, 6),
|
| 81 |
+
'random-7d': np.random.rand(10, 7),
|
| 82 |
+
'random-8d': np.random.rand(10, 8),
|
| 83 |
+
'pathological-1': pathological_data_1,
|
| 84 |
+
'pathological-2': pathological_data_2
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
INCREMENTAL_DATASETS = {
|
| 88 |
+
'bug-2850': (bug_2850_chunks, None),
|
| 89 |
+
'bug-2850-2': (bug_2850_chunks_2, None),
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def _add_inc_data(name, chunksize):
|
| 94 |
+
"""
|
| 95 |
+
Generate incremental datasets from basic data sets
|
| 96 |
+
"""
|
| 97 |
+
points = DATASETS[name]
|
| 98 |
+
ndim = points.shape[1]
|
| 99 |
+
|
| 100 |
+
opts = None
|
| 101 |
+
nmin = ndim + 2
|
| 102 |
+
|
| 103 |
+
if name == 'some-points':
|
| 104 |
+
# since Qz is not allowed, use QJ
|
| 105 |
+
opts = 'QJ Pp'
|
| 106 |
+
elif name == 'pathological-1':
|
| 107 |
+
# include enough points so that we get different x-coordinates
|
| 108 |
+
nmin = 12
|
| 109 |
+
|
| 110 |
+
chunks = [points[:nmin]]
|
| 111 |
+
for j in range(nmin, len(points), chunksize):
|
| 112 |
+
chunks.append(points[j:j+chunksize])
|
| 113 |
+
|
| 114 |
+
new_name = f"{name}-chunk-{chunksize}"
|
| 115 |
+
assert new_name not in INCREMENTAL_DATASETS
|
| 116 |
+
INCREMENTAL_DATASETS[new_name] = (chunks, opts)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
for name in DATASETS:
|
| 120 |
+
for chunksize in 1, 4, 16:
|
| 121 |
+
_add_inc_data(name, chunksize)
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class Test_Qhull:
|
| 125 |
+
def test_swapping(self):
|
| 126 |
+
# Check that Qhull state swapping works
|
| 127 |
+
|
| 128 |
+
x = qhull._Qhull(b'v',
|
| 129 |
+
np.array([[0,0],[0,1],[1,0],[1,1.],[0.5,0.5]]),
|
| 130 |
+
b'Qz')
|
| 131 |
+
xd = copy.deepcopy(x.get_voronoi_diagram())
|
| 132 |
+
|
| 133 |
+
y = qhull._Qhull(b'v',
|
| 134 |
+
np.array([[0,0],[0,1],[1,0],[1,2.]]),
|
| 135 |
+
b'Qz')
|
| 136 |
+
yd = copy.deepcopy(y.get_voronoi_diagram())
|
| 137 |
+
|
| 138 |
+
xd2 = copy.deepcopy(x.get_voronoi_diagram())
|
| 139 |
+
x.close()
|
| 140 |
+
yd2 = copy.deepcopy(y.get_voronoi_diagram())
|
| 141 |
+
y.close()
|
| 142 |
+
|
| 143 |
+
assert_raises(RuntimeError, x.get_voronoi_diagram)
|
| 144 |
+
assert_raises(RuntimeError, y.get_voronoi_diagram)
|
| 145 |
+
|
| 146 |
+
assert_allclose(xd[0], xd2[0])
|
| 147 |
+
assert_unordered_tuple_list_equal(xd[1], xd2[1], tpl=sorted_tuple)
|
| 148 |
+
assert_unordered_tuple_list_equal(xd[2], xd2[2], tpl=sorted_tuple)
|
| 149 |
+
assert_unordered_tuple_list_equal(xd[3], xd2[3], tpl=sorted_tuple)
|
| 150 |
+
assert_array_equal(xd[4], xd2[4])
|
| 151 |
+
|
| 152 |
+
assert_allclose(yd[0], yd2[0])
|
| 153 |
+
assert_unordered_tuple_list_equal(yd[1], yd2[1], tpl=sorted_tuple)
|
| 154 |
+
assert_unordered_tuple_list_equal(yd[2], yd2[2], tpl=sorted_tuple)
|
| 155 |
+
assert_unordered_tuple_list_equal(yd[3], yd2[3], tpl=sorted_tuple)
|
| 156 |
+
assert_array_equal(yd[4], yd2[4])
|
| 157 |
+
|
| 158 |
+
x.close()
|
| 159 |
+
assert_raises(RuntimeError, x.get_voronoi_diagram)
|
| 160 |
+
y.close()
|
| 161 |
+
assert_raises(RuntimeError, y.get_voronoi_diagram)
|
| 162 |
+
|
| 163 |
+
def test_issue_8051(self):
|
| 164 |
+
points = np.array(
|
| 165 |
+
[[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2],[2, 0], [2, 1], [2, 2]]
|
| 166 |
+
)
|
| 167 |
+
Voronoi(points)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
class TestUtilities:
|
| 171 |
+
"""
|
| 172 |
+
Check that utility functions work.
|
| 173 |
+
|
| 174 |
+
"""
|
| 175 |
+
|
| 176 |
+
def test_find_simplex(self):
|
| 177 |
+
# Simple check that simplex finding works
|
| 178 |
+
points = np.array([(0,0), (0,1), (1,1), (1,0)], dtype=np.float64)
|
| 179 |
+
tri = qhull.Delaunay(points)
|
| 180 |
+
|
| 181 |
+
# +---+
|
| 182 |
+
# |\ 0|
|
| 183 |
+
# | \ |
|
| 184 |
+
# |1 \|
|
| 185 |
+
# +---+
|
| 186 |
+
|
| 187 |
+
assert_equal(tri.simplices, [[1, 3, 2], [3, 1, 0]])
|
| 188 |
+
|
| 189 |
+
for p in [(0.25, 0.25, 1),
|
| 190 |
+
(0.75, 0.75, 0),
|
| 191 |
+
(0.3, 0.2, 1)]:
|
| 192 |
+
i = tri.find_simplex(p[:2])
|
| 193 |
+
assert_equal(i, p[2], err_msg=f'{p!r}')
|
| 194 |
+
j = qhull.tsearch(tri, p[:2])
|
| 195 |
+
assert_equal(i, j)
|
| 196 |
+
|
| 197 |
+
def test_plane_distance(self):
|
| 198 |
+
# Compare plane distance from hyperplane equations obtained from Qhull
|
| 199 |
+
# to manually computed plane equations
|
| 200 |
+
x = np.array([(0,0), (1, 1), (1, 0), (0.99189033, 0.37674127),
|
| 201 |
+
(0.99440079, 0.45182168)], dtype=np.float64)
|
| 202 |
+
p = np.array([0.99966555, 0.15685619], dtype=np.float64)
|
| 203 |
+
|
| 204 |
+
tri = qhull.Delaunay(x)
|
| 205 |
+
|
| 206 |
+
z = tri.lift_points(x)
|
| 207 |
+
pz = tri.lift_points(p)
|
| 208 |
+
|
| 209 |
+
dist = tri.plane_distance(p)
|
| 210 |
+
|
| 211 |
+
for j, v in enumerate(tri.simplices):
|
| 212 |
+
x1 = z[v[0]]
|
| 213 |
+
x2 = z[v[1]]
|
| 214 |
+
x3 = z[v[2]]
|
| 215 |
+
|
| 216 |
+
n = np.cross(x1 - x3, x2 - x3)
|
| 217 |
+
n /= np.sqrt(np.dot(n, n))
|
| 218 |
+
n *= -np.sign(n[2])
|
| 219 |
+
|
| 220 |
+
d = np.dot(n, pz - x3)
|
| 221 |
+
|
| 222 |
+
assert_almost_equal(dist[j], d)
|
| 223 |
+
|
| 224 |
+
def test_convex_hull(self):
|
| 225 |
+
# Simple check that the convex hull seems to works
|
| 226 |
+
points = np.array([(0,0), (0,1), (1,1), (1,0)], dtype=np.float64)
|
| 227 |
+
tri = qhull.Delaunay(points)
|
| 228 |
+
|
| 229 |
+
# +---+
|
| 230 |
+
# |\ 0|
|
| 231 |
+
# | \ |
|
| 232 |
+
# |1 \|
|
| 233 |
+
# +---+
|
| 234 |
+
|
| 235 |
+
assert_equal(tri.convex_hull, [[3, 2], [1, 2], [1, 0], [3, 0]])
|
| 236 |
+
|
| 237 |
+
def test_volume_area(self):
|
| 238 |
+
#Basic check that we get back the correct volume and area for a cube
|
| 239 |
+
points = np.array([(0, 0, 0), (0, 1, 0), (1, 0, 0), (1, 1, 0),
|
| 240 |
+
(0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)])
|
| 241 |
+
hull = qhull.ConvexHull(points)
|
| 242 |
+
|
| 243 |
+
assert_allclose(hull.volume, 1., rtol=1e-14,
|
| 244 |
+
err_msg="Volume of cube is incorrect")
|
| 245 |
+
assert_allclose(hull.area, 6., rtol=1e-14,
|
| 246 |
+
err_msg="Area of cube is incorrect")
|
| 247 |
+
|
| 248 |
+
def test_random_volume_area(self):
|
| 249 |
+
#Test that the results for a random 10-point convex are
|
| 250 |
+
#coherent with the output of qconvex Qt s FA
|
| 251 |
+
points = np.array([(0.362568364506, 0.472712355305, 0.347003084477),
|
| 252 |
+
(0.733731893414, 0.634480295684, 0.950513180209),
|
| 253 |
+
(0.511239955611, 0.876839441267, 0.418047827863),
|
| 254 |
+
(0.0765906233393, 0.527373281342, 0.6509863541),
|
| 255 |
+
(0.146694972056, 0.596725793348, 0.894860986685),
|
| 256 |
+
(0.513808585741, 0.069576205858, 0.530890338876),
|
| 257 |
+
(0.512343805118, 0.663537132612, 0.037689295973),
|
| 258 |
+
(0.47282965018, 0.462176697655, 0.14061843691),
|
| 259 |
+
(0.240584597123, 0.778660020591, 0.722913476339),
|
| 260 |
+
(0.951271745935, 0.967000673944, 0.890661319684)])
|
| 261 |
+
|
| 262 |
+
hull = qhull.ConvexHull(points)
|
| 263 |
+
assert_allclose(hull.volume, 0.14562013, rtol=1e-07,
|
| 264 |
+
err_msg="Volume of random polyhedron is incorrect")
|
| 265 |
+
assert_allclose(hull.area, 1.6670425, rtol=1e-07,
|
| 266 |
+
err_msg="Area of random polyhedron is incorrect")
|
| 267 |
+
|
| 268 |
+
def test_incremental_volume_area_random_input(self):
|
| 269 |
+
"""Test that incremental mode gives the same volume/area as
|
| 270 |
+
non-incremental mode and incremental mode with restart"""
|
| 271 |
+
nr_points = 20
|
| 272 |
+
dim = 3
|
| 273 |
+
points = np.random.random((nr_points, dim))
|
| 274 |
+
inc_hull = qhull.ConvexHull(points[:dim+1, :], incremental=True)
|
| 275 |
+
inc_restart_hull = qhull.ConvexHull(points[:dim+1, :], incremental=True)
|
| 276 |
+
for i in range(dim+1, nr_points):
|
| 277 |
+
hull = qhull.ConvexHull(points[:i+1, :])
|
| 278 |
+
inc_hull.add_points(points[i:i+1, :])
|
| 279 |
+
inc_restart_hull.add_points(points[i:i+1, :], restart=True)
|
| 280 |
+
assert_allclose(hull.volume, inc_hull.volume, rtol=1e-7)
|
| 281 |
+
assert_allclose(hull.volume, inc_restart_hull.volume, rtol=1e-7)
|
| 282 |
+
assert_allclose(hull.area, inc_hull.area, rtol=1e-7)
|
| 283 |
+
assert_allclose(hull.area, inc_restart_hull.area, rtol=1e-7)
|
| 284 |
+
|
| 285 |
+
def _check_barycentric_transforms(self, tri, err_msg="",
|
| 286 |
+
unit_cube=False,
|
| 287 |
+
unit_cube_tol=0):
|
| 288 |
+
"""Check that a triangulation has reasonable barycentric transforms"""
|
| 289 |
+
vertices = tri.points[tri.simplices]
|
| 290 |
+
sc = 1/(tri.ndim + 1.0)
|
| 291 |
+
centroids = vertices.sum(axis=1) * sc
|
| 292 |
+
|
| 293 |
+
# Either: (i) the simplex has a `nan` barycentric transform,
|
| 294 |
+
# or, (ii) the centroid is in the simplex
|
| 295 |
+
|
| 296 |
+
def barycentric_transform(tr, x):
|
| 297 |
+
r = tr[:,-1,:]
|
| 298 |
+
Tinv = tr[:,:-1,:]
|
| 299 |
+
return np.einsum('ijk,ik->ij', Tinv, x - r)
|
| 300 |
+
|
| 301 |
+
eps = np.finfo(float).eps
|
| 302 |
+
|
| 303 |
+
c = barycentric_transform(tri.transform, centroids)
|
| 304 |
+
with np.errstate(invalid="ignore"):
|
| 305 |
+
ok = np.isnan(c).all(axis=1) | (abs(c - sc)/sc < 0.1).all(axis=1)
|
| 306 |
+
|
| 307 |
+
assert_(ok.all(), f"{err_msg} {np.nonzero(~ok)}")
|
| 308 |
+
|
| 309 |
+
# Invalid simplices must be (nearly) zero volume
|
| 310 |
+
q = vertices[:,:-1,:] - vertices[:,-1,None,:]
|
| 311 |
+
volume = np.array([np.linalg.det(q[k,:,:])
|
| 312 |
+
for k in range(tri.nsimplex)])
|
| 313 |
+
ok = np.isfinite(tri.transform[:,0,0]) | (volume < np.sqrt(eps))
|
| 314 |
+
assert_(ok.all(), f"{err_msg} {np.nonzero(~ok)}")
|
| 315 |
+
|
| 316 |
+
# Also, find_simplex for the centroid should end up in some
|
| 317 |
+
# simplex for the non-degenerate cases
|
| 318 |
+
j = tri.find_simplex(centroids)
|
| 319 |
+
ok = (j != -1) | np.isnan(tri.transform[:,0,0])
|
| 320 |
+
assert_(ok.all(), f"{err_msg} {np.nonzero(~ok)}")
|
| 321 |
+
|
| 322 |
+
if unit_cube:
|
| 323 |
+
# If in unit cube, no interior point should be marked out of hull
|
| 324 |
+
at_boundary = (centroids <= unit_cube_tol).any(axis=1)
|
| 325 |
+
at_boundary |= (centroids >= 1 - unit_cube_tol).any(axis=1)
|
| 326 |
+
|
| 327 |
+
ok = (j != -1) | at_boundary
|
| 328 |
+
assert_(ok.all(), f"{err_msg} {np.nonzero(~ok)}")
|
| 329 |
+
|
| 330 |
+
@pytest.mark.fail_slow(10)
|
| 331 |
+
def test_degenerate_barycentric_transforms(self):
|
| 332 |
+
# The triangulation should not produce invalid barycentric
|
| 333 |
+
# transforms that stump the simplex finding
|
| 334 |
+
data = np.load(os.path.join(os.path.dirname(__file__), 'data',
|
| 335 |
+
'degenerate_pointset.npz'))
|
| 336 |
+
points = data['c']
|
| 337 |
+
data.close()
|
| 338 |
+
|
| 339 |
+
tri = qhull.Delaunay(points)
|
| 340 |
+
|
| 341 |
+
# Check that there are not too many invalid simplices
|
| 342 |
+
bad_count = np.isnan(tri.transform[:,0,0]).sum()
|
| 343 |
+
assert_(bad_count < 23, bad_count)
|
| 344 |
+
|
| 345 |
+
# Check the transforms
|
| 346 |
+
self._check_barycentric_transforms(tri)
|
| 347 |
+
|
| 348 |
+
@pytest.mark.slow
|
| 349 |
+
@pytest.mark.fail_slow(20)
|
| 350 |
+
# OK per https://github.com/scipy/scipy/pull/20487#discussion_r1572684869
|
| 351 |
+
def test_more_barycentric_transforms(self):
|
| 352 |
+
# Triangulate some "nasty" grids
|
| 353 |
+
|
| 354 |
+
eps = np.finfo(float).eps
|
| 355 |
+
|
| 356 |
+
npoints = {2: 70, 3: 11, 4: 5, 5: 3}
|
| 357 |
+
|
| 358 |
+
for ndim in range(2, 6):
|
| 359 |
+
# Generate an uniform grid in n-d unit cube
|
| 360 |
+
x = np.linspace(0, 1, npoints[ndim])
|
| 361 |
+
grid = np.c_[
|
| 362 |
+
list(map(np.ravel, np.broadcast_arrays(*np.ix_(*([x]*ndim)))))
|
| 363 |
+
].T
|
| 364 |
+
|
| 365 |
+
err_msg = f"ndim={ndim}"
|
| 366 |
+
|
| 367 |
+
# Check using regular grid
|
| 368 |
+
tri = qhull.Delaunay(grid)
|
| 369 |
+
self._check_barycentric_transforms(tri, err_msg=err_msg,
|
| 370 |
+
unit_cube=True)
|
| 371 |
+
|
| 372 |
+
# Check with eps-perturbations
|
| 373 |
+
np.random.seed(1234)
|
| 374 |
+
m = (np.random.rand(grid.shape[0]) < 0.2)
|
| 375 |
+
grid[m,:] += 2*eps*(np.random.rand(*grid[m,:].shape) - 0.5)
|
| 376 |
+
|
| 377 |
+
tri = qhull.Delaunay(grid)
|
| 378 |
+
self._check_barycentric_transforms(tri, err_msg=err_msg,
|
| 379 |
+
unit_cube=True,
|
| 380 |
+
unit_cube_tol=2*eps)
|
| 381 |
+
|
| 382 |
+
# Check with duplicated data
|
| 383 |
+
tri = qhull.Delaunay(np.r_[grid, grid])
|
| 384 |
+
self._check_barycentric_transforms(tri, err_msg=err_msg,
|
| 385 |
+
unit_cube=True,
|
| 386 |
+
unit_cube_tol=2*eps)
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
class TestVertexNeighborVertices:
|
| 390 |
+
def _check(self, tri):
|
| 391 |
+
expected = [set() for j in range(tri.points.shape[0])]
|
| 392 |
+
for s in tri.simplices:
|
| 393 |
+
for a in s:
|
| 394 |
+
for b in s:
|
| 395 |
+
if a != b:
|
| 396 |
+
expected[a].add(b)
|
| 397 |
+
|
| 398 |
+
indptr, indices = tri.vertex_neighbor_vertices
|
| 399 |
+
|
| 400 |
+
got = [set(map(int, indices[indptr[j]:indptr[j+1]]))
|
| 401 |
+
for j in range(tri.points.shape[0])]
|
| 402 |
+
|
| 403 |
+
assert_equal(got, expected, err_msg=f"{got!r} != {expected!r}")
|
| 404 |
+
|
| 405 |
+
def test_triangle(self):
|
| 406 |
+
points = np.array([(0,0), (0,1), (1,0)], dtype=np.float64)
|
| 407 |
+
tri = qhull.Delaunay(points)
|
| 408 |
+
self._check(tri)
|
| 409 |
+
|
| 410 |
+
def test_rectangle(self):
|
| 411 |
+
points = np.array([(0,0), (0,1), (1,1), (1,0)], dtype=np.float64)
|
| 412 |
+
tri = qhull.Delaunay(points)
|
| 413 |
+
self._check(tri)
|
| 414 |
+
|
| 415 |
+
def test_complicated(self):
|
| 416 |
+
points = np.array([(0,0), (0,1), (1,1), (1,0),
|
| 417 |
+
(0.5, 0.5), (0.9, 0.5)], dtype=np.float64)
|
| 418 |
+
tri = qhull.Delaunay(points)
|
| 419 |
+
self._check(tri)
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
class TestDelaunay:
|
| 423 |
+
"""
|
| 424 |
+
Check that triangulation works.
|
| 425 |
+
|
| 426 |
+
"""
|
| 427 |
+
def test_masked_array_fails(self):
|
| 428 |
+
masked_array = np.ma.masked_all(1)
|
| 429 |
+
assert_raises(ValueError, qhull.Delaunay, masked_array)
|
| 430 |
+
|
| 431 |
+
# Shouldn't be inherently unsafe; retry with cpython 3.14 once traceback
|
| 432 |
+
# thread safety issues are fixed (also goes for other test with same name
|
| 433 |
+
# further down)
|
| 434 |
+
def test_array_with_nans_fails(self):
|
| 435 |
+
points_with_nan = np.array([(0,0), (0,1), (1,1), (1,np.nan)], dtype=np.float64)
|
| 436 |
+
assert_raises(ValueError, qhull.Delaunay, points_with_nan)
|
| 437 |
+
|
| 438 |
+
def test_nd_simplex(self):
|
| 439 |
+
# simple smoke test: triangulate a n-dimensional simplex
|
| 440 |
+
for nd in range(2, 8):
|
| 441 |
+
points = np.zeros((nd+1, nd))
|
| 442 |
+
for j in range(nd):
|
| 443 |
+
points[j,j] = 1.0
|
| 444 |
+
points[-1,:] = 1.0
|
| 445 |
+
|
| 446 |
+
tri = qhull.Delaunay(points)
|
| 447 |
+
|
| 448 |
+
tri.simplices.sort()
|
| 449 |
+
|
| 450 |
+
assert_equal(tri.simplices, np.arange(nd+1, dtype=int)[None, :])
|
| 451 |
+
assert_equal(tri.neighbors, -1 + np.zeros((nd+1), dtype=int)[None,:])
|
| 452 |
+
|
| 453 |
+
def test_2d_square(self):
|
| 454 |
+
# simple smoke test: 2d square
|
| 455 |
+
points = np.array([(0,0), (0,1), (1,1), (1,0)], dtype=np.float64)
|
| 456 |
+
tri = qhull.Delaunay(points)
|
| 457 |
+
|
| 458 |
+
assert_equal(tri.simplices, [[1, 3, 2], [3, 1, 0]])
|
| 459 |
+
assert_equal(tri.neighbors, [[-1, -1, 1], [-1, -1, 0]])
|
| 460 |
+
|
| 461 |
+
def test_duplicate_points(self):
|
| 462 |
+
x = np.array([0, 1, 0, 1], dtype=np.float64)
|
| 463 |
+
y = np.array([0, 0, 1, 1], dtype=np.float64)
|
| 464 |
+
|
| 465 |
+
xp = np.r_[x, x]
|
| 466 |
+
yp = np.r_[y, y]
|
| 467 |
+
|
| 468 |
+
# shouldn't fail on duplicate points
|
| 469 |
+
qhull.Delaunay(np.c_[x, y])
|
| 470 |
+
qhull.Delaunay(np.c_[xp, yp])
|
| 471 |
+
|
| 472 |
+
def test_pathological(self):
|
| 473 |
+
# both should succeed
|
| 474 |
+
points = DATASETS['pathological-1']
|
| 475 |
+
tri = qhull.Delaunay(points)
|
| 476 |
+
assert_equal(tri.points[tri.simplices].max(), points.max())
|
| 477 |
+
assert_equal(tri.points[tri.simplices].min(), points.min())
|
| 478 |
+
|
| 479 |
+
points = DATASETS['pathological-2']
|
| 480 |
+
tri = qhull.Delaunay(points)
|
| 481 |
+
assert_equal(tri.points[tri.simplices].max(), points.max())
|
| 482 |
+
assert_equal(tri.points[tri.simplices].min(), points.min())
|
| 483 |
+
|
| 484 |
+
def test_joggle(self):
|
| 485 |
+
# Check that the option QJ indeed guarantees that all input points
|
| 486 |
+
# occur as vertices of the triangulation
|
| 487 |
+
|
| 488 |
+
points = np.random.rand(10, 2)
|
| 489 |
+
points = np.r_[points, points] # duplicate input data
|
| 490 |
+
|
| 491 |
+
tri = qhull.Delaunay(points, qhull_options="QJ Qbb Pp")
|
| 492 |
+
assert_array_equal(np.unique(tri.simplices.ravel()),
|
| 493 |
+
np.arange(len(points)))
|
| 494 |
+
|
| 495 |
+
def test_coplanar(self):
|
| 496 |
+
# Check that the coplanar point output option indeed works
|
| 497 |
+
points = np.random.rand(10, 2)
|
| 498 |
+
points = np.r_[points, points] # duplicate input data
|
| 499 |
+
|
| 500 |
+
tri = qhull.Delaunay(points)
|
| 501 |
+
|
| 502 |
+
assert_(len(np.unique(tri.simplices.ravel())) == len(points)//2)
|
| 503 |
+
assert_(len(tri.coplanar) == len(points)//2)
|
| 504 |
+
|
| 505 |
+
assert_(len(np.unique(tri.coplanar[:,2])) == len(points)//2)
|
| 506 |
+
|
| 507 |
+
assert_(np.all(tri.vertex_to_simplex >= 0))
|
| 508 |
+
|
| 509 |
+
def test_furthest_site(self):
|
| 510 |
+
points = [(0, 0), (0, 1), (1, 0), (0.5, 0.5), (1.1, 1.1)]
|
| 511 |
+
tri = qhull.Delaunay(points, furthest_site=True)
|
| 512 |
+
|
| 513 |
+
expected = np.array([(1, 4, 0), (4, 2, 0)]) # from Qhull
|
| 514 |
+
assert_array_equal(tri.simplices, expected)
|
| 515 |
+
|
| 516 |
+
@pytest.mark.parametrize("name", sorted(INCREMENTAL_DATASETS))
|
| 517 |
+
def test_incremental(self, name):
|
| 518 |
+
# Test incremental construction of the triangulation
|
| 519 |
+
|
| 520 |
+
chunks, opts = INCREMENTAL_DATASETS[name]
|
| 521 |
+
points = np.concatenate(chunks, axis=0)
|
| 522 |
+
|
| 523 |
+
obj = qhull.Delaunay(chunks[0], incremental=True,
|
| 524 |
+
qhull_options=opts)
|
| 525 |
+
for chunk in chunks[1:]:
|
| 526 |
+
obj.add_points(chunk)
|
| 527 |
+
|
| 528 |
+
obj2 = qhull.Delaunay(points)
|
| 529 |
+
|
| 530 |
+
obj3 = qhull.Delaunay(chunks[0], incremental=True,
|
| 531 |
+
qhull_options=opts)
|
| 532 |
+
if len(chunks) > 1:
|
| 533 |
+
obj3.add_points(np.concatenate(chunks[1:], axis=0),
|
| 534 |
+
restart=True)
|
| 535 |
+
|
| 536 |
+
# Check that the incremental mode agrees with upfront mode
|
| 537 |
+
if name.startswith('pathological'):
|
| 538 |
+
# XXX: These produce valid but different triangulations.
|
| 539 |
+
# They look OK when plotted, but how to check them?
|
| 540 |
+
|
| 541 |
+
assert_array_equal(np.unique(obj.simplices.ravel()),
|
| 542 |
+
np.arange(points.shape[0]))
|
| 543 |
+
assert_array_equal(np.unique(obj2.simplices.ravel()),
|
| 544 |
+
np.arange(points.shape[0]))
|
| 545 |
+
else:
|
| 546 |
+
assert_unordered_tuple_list_equal(obj.simplices, obj2.simplices,
|
| 547 |
+
tpl=sorted_tuple)
|
| 548 |
+
|
| 549 |
+
assert_unordered_tuple_list_equal(obj2.simplices, obj3.simplices,
|
| 550 |
+
tpl=sorted_tuple)
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
def assert_hulls_equal(points, facets_1, facets_2):
|
| 554 |
+
# Check that two convex hulls constructed from the same point set
|
| 555 |
+
# are equal
|
| 556 |
+
|
| 557 |
+
facets_1 = set(map(sorted_tuple, facets_1))
|
| 558 |
+
facets_2 = set(map(sorted_tuple, facets_2))
|
| 559 |
+
|
| 560 |
+
if facets_1 != facets_2 and points.shape[1] == 2:
|
| 561 |
+
# The direct check fails for the pathological cases
|
| 562 |
+
# --- then the convex hull from Delaunay differs (due
|
| 563 |
+
# to rounding error etc.) from the hull computed
|
| 564 |
+
# otherwise, by the question whether (tricoplanar)
|
| 565 |
+
# points that lie almost exactly on the hull are
|
| 566 |
+
# included as vertices of the hull or not.
|
| 567 |
+
#
|
| 568 |
+
# So we check the result, and accept it if the Delaunay
|
| 569 |
+
# hull line segments are a subset of the usual hull.
|
| 570 |
+
|
| 571 |
+
eps = 1000 * np.finfo(float).eps
|
| 572 |
+
|
| 573 |
+
for a, b in facets_1:
|
| 574 |
+
for ap, bp in facets_2:
|
| 575 |
+
t = points[bp] - points[ap]
|
| 576 |
+
t /= np.linalg.norm(t) # tangent
|
| 577 |
+
n = np.array([-t[1], t[0]]) # normal
|
| 578 |
+
|
| 579 |
+
# check that the two line segments are parallel
|
| 580 |
+
# to the same line
|
| 581 |
+
c1 = np.dot(n, points[b] - points[ap])
|
| 582 |
+
c2 = np.dot(n, points[a] - points[ap])
|
| 583 |
+
if not np.allclose(np.dot(c1, n), 0):
|
| 584 |
+
continue
|
| 585 |
+
if not np.allclose(np.dot(c2, n), 0):
|
| 586 |
+
continue
|
| 587 |
+
|
| 588 |
+
# Check that the segment (a, b) is contained in (ap, bp)
|
| 589 |
+
c1 = np.dot(t, points[a] - points[ap])
|
| 590 |
+
c2 = np.dot(t, points[b] - points[ap])
|
| 591 |
+
c3 = np.dot(t, points[bp] - points[ap])
|
| 592 |
+
if c1 < -eps or c1 > c3 + eps:
|
| 593 |
+
continue
|
| 594 |
+
if c2 < -eps or c2 > c3 + eps:
|
| 595 |
+
continue
|
| 596 |
+
|
| 597 |
+
# OK:
|
| 598 |
+
break
|
| 599 |
+
else:
|
| 600 |
+
raise AssertionError("comparison fails")
|
| 601 |
+
|
| 602 |
+
# it was OK
|
| 603 |
+
return
|
| 604 |
+
|
| 605 |
+
assert_equal(facets_1, facets_2)
|
| 606 |
+
|
| 607 |
+
|
| 608 |
+
class TestConvexHull:
|
| 609 |
+
def test_masked_array_fails(self):
|
| 610 |
+
masked_array = np.ma.masked_all(1)
|
| 611 |
+
assert_raises(ValueError, qhull.ConvexHull, masked_array)
|
| 612 |
+
|
| 613 |
+
def test_array_with_nans_fails(self):
|
| 614 |
+
points_with_nan = np.array([(0,0), (1,1), (2,np.nan)], dtype=np.float64)
|
| 615 |
+
assert_raises(ValueError, qhull.ConvexHull, points_with_nan)
|
| 616 |
+
|
| 617 |
+
@pytest.mark.parametrize("name", sorted(DATASETS))
|
| 618 |
+
def test_hull_consistency_tri(self, name):
|
| 619 |
+
# Check that a convex hull returned by qhull in ndim
|
| 620 |
+
# and the hull constructed from ndim delaunay agree
|
| 621 |
+
points = DATASETS[name]
|
| 622 |
+
|
| 623 |
+
tri = qhull.Delaunay(points)
|
| 624 |
+
hull = qhull.ConvexHull(points)
|
| 625 |
+
|
| 626 |
+
assert_hulls_equal(points, tri.convex_hull, hull.simplices)
|
| 627 |
+
|
| 628 |
+
# Check that the hull extremes are as expected
|
| 629 |
+
if points.shape[1] == 2:
|
| 630 |
+
assert_equal(np.unique(hull.simplices), np.sort(hull.vertices))
|
| 631 |
+
else:
|
| 632 |
+
assert_equal(np.unique(hull.simplices), hull.vertices)
|
| 633 |
+
|
| 634 |
+
@pytest.mark.parametrize("name", sorted(INCREMENTAL_DATASETS))
|
| 635 |
+
def test_incremental(self, name):
|
| 636 |
+
# Test incremental construction of the convex hull
|
| 637 |
+
chunks, _ = INCREMENTAL_DATASETS[name]
|
| 638 |
+
points = np.concatenate(chunks, axis=0)
|
| 639 |
+
|
| 640 |
+
obj = qhull.ConvexHull(chunks[0], incremental=True)
|
| 641 |
+
for chunk in chunks[1:]:
|
| 642 |
+
obj.add_points(chunk)
|
| 643 |
+
|
| 644 |
+
obj2 = qhull.ConvexHull(points)
|
| 645 |
+
|
| 646 |
+
obj3 = qhull.ConvexHull(chunks[0], incremental=True)
|
| 647 |
+
if len(chunks) > 1:
|
| 648 |
+
obj3.add_points(np.concatenate(chunks[1:], axis=0),
|
| 649 |
+
restart=True)
|
| 650 |
+
|
| 651 |
+
# Check that the incremental mode agrees with upfront mode
|
| 652 |
+
assert_hulls_equal(points, obj.simplices, obj2.simplices)
|
| 653 |
+
assert_hulls_equal(points, obj.simplices, obj3.simplices)
|
| 654 |
+
|
| 655 |
+
def test_vertices_2d(self):
|
| 656 |
+
# The vertices should be in counterclockwise order in 2-D
|
| 657 |
+
np.random.seed(1234)
|
| 658 |
+
points = np.random.rand(30, 2)
|
| 659 |
+
|
| 660 |
+
hull = qhull.ConvexHull(points)
|
| 661 |
+
assert_equal(np.unique(hull.simplices), np.sort(hull.vertices))
|
| 662 |
+
|
| 663 |
+
# Check counterclockwiseness
|
| 664 |
+
x, y = hull.points[hull.vertices].T
|
| 665 |
+
angle = np.arctan2(y - y.mean(), x - x.mean())
|
| 666 |
+
assert_(np.all(np.diff(np.unwrap(angle)) > 0))
|
| 667 |
+
|
| 668 |
+
def test_volume_area(self):
|
| 669 |
+
# Basic check that we get back the correct volume and area for a cube
|
| 670 |
+
points = np.array([(0, 0, 0), (0, 1, 0), (1, 0, 0), (1, 1, 0),
|
| 671 |
+
(0, 0, 1), (0, 1, 1), (1, 0, 1), (1, 1, 1)])
|
| 672 |
+
tri = qhull.ConvexHull(points)
|
| 673 |
+
|
| 674 |
+
assert_allclose(tri.volume, 1., rtol=1e-14)
|
| 675 |
+
assert_allclose(tri.area, 6., rtol=1e-14)
|
| 676 |
+
|
| 677 |
+
@pytest.mark.parametrize("incremental", [False, True])
|
| 678 |
+
def test_good2d(self, incremental):
|
| 679 |
+
# Make sure the QGn option gives the correct value of "good".
|
| 680 |
+
points = np.array([[0.2, 0.2],
|
| 681 |
+
[0.2, 0.4],
|
| 682 |
+
[0.4, 0.4],
|
| 683 |
+
[0.4, 0.2],
|
| 684 |
+
[0.3, 0.6]])
|
| 685 |
+
hull = qhull.ConvexHull(points=points,
|
| 686 |
+
incremental=incremental,
|
| 687 |
+
qhull_options='QG4')
|
| 688 |
+
expected = np.array([False, True, False, False], dtype=bool)
|
| 689 |
+
actual = hull.good
|
| 690 |
+
assert_equal(actual, expected)
|
| 691 |
+
|
| 692 |
+
@pytest.mark.parametrize("visibility", [
|
| 693 |
+
"QG4", # visible=True
|
| 694 |
+
"QG-4", # visible=False
|
| 695 |
+
])
|
| 696 |
+
@pytest.mark.parametrize("new_gen, expected", [
|
| 697 |
+
# add generator that places QG4 inside hull
|
| 698 |
+
# so all facets are invisible
|
| 699 |
+
(np.array([[0.3, 0.7]]),
|
| 700 |
+
np.array([False, False, False, False, False], dtype=bool)),
|
| 701 |
+
# adding a generator on the opposite side of the square
|
| 702 |
+
# should preserve the single visible facet & add one invisible
|
| 703 |
+
# facet
|
| 704 |
+
(np.array([[0.3, -0.7]]),
|
| 705 |
+
np.array([False, True, False, False, False], dtype=bool)),
|
| 706 |
+
# split the visible facet on top of the square into two
|
| 707 |
+
# visible facets, with visibility at the end of the array
|
| 708 |
+
# because add_points concatenates
|
| 709 |
+
(np.array([[0.3, 0.41]]),
|
| 710 |
+
np.array([False, False, False, True, True], dtype=bool)),
|
| 711 |
+
# with our current Qhull options, coplanarity will not count
|
| 712 |
+
# for visibility; this case shifts one visible & one invisible
|
| 713 |
+
# facet & adds a coplanar facet
|
| 714 |
+
# simplex at index position 2 is the shifted visible facet
|
| 715 |
+
# the final simplex is the coplanar facet
|
| 716 |
+
(np.array([[0.5, 0.6], [0.6, 0.6]]),
|
| 717 |
+
np.array([False, False, True, False, False], dtype=bool)),
|
| 718 |
+
# place the new generator such that it envelops the query
|
| 719 |
+
# point within the convex hull, but only just barely within
|
| 720 |
+
# the double precision limit
|
| 721 |
+
# NOTE: testing exact degeneracy is less predictable than this
|
| 722 |
+
# scenario, perhaps because of the default Qt option we have
|
| 723 |
+
# enabled for Qhull to handle precision matters
|
| 724 |
+
(np.array([[0.3, 0.6 + 1e-16]]),
|
| 725 |
+
np.array([False, False, False, False, False], dtype=bool)),
|
| 726 |
+
])
|
| 727 |
+
def test_good2d_incremental_changes(self, new_gen, expected,
|
| 728 |
+
visibility):
|
| 729 |
+
# use the usual square convex hull
|
| 730 |
+
# generators from test_good2d
|
| 731 |
+
points = np.array([[0.2, 0.2],
|
| 732 |
+
[0.2, 0.4],
|
| 733 |
+
[0.4, 0.4],
|
| 734 |
+
[0.4, 0.2],
|
| 735 |
+
[0.3, 0.6]])
|
| 736 |
+
hull = qhull.ConvexHull(points=points,
|
| 737 |
+
incremental=True,
|
| 738 |
+
qhull_options=visibility)
|
| 739 |
+
hull.add_points(new_gen)
|
| 740 |
+
actual = hull.good
|
| 741 |
+
if '-' in visibility:
|
| 742 |
+
expected = np.invert(expected)
|
| 743 |
+
assert_equal(actual, expected)
|
| 744 |
+
|
| 745 |
+
@pytest.mark.parametrize("incremental", [False, True])
|
| 746 |
+
def test_good2d_no_option(self, incremental):
|
| 747 |
+
# handle case where good attribute doesn't exist
|
| 748 |
+
# because Qgn or Qg-n wasn't specified
|
| 749 |
+
points = np.array([[0.2, 0.2],
|
| 750 |
+
[0.2, 0.4],
|
| 751 |
+
[0.4, 0.4],
|
| 752 |
+
[0.4, 0.2],
|
| 753 |
+
[0.3, 0.6]])
|
| 754 |
+
hull = qhull.ConvexHull(points=points,
|
| 755 |
+
incremental=incremental)
|
| 756 |
+
actual = hull.good
|
| 757 |
+
assert actual is None
|
| 758 |
+
# preserve None after incremental addition
|
| 759 |
+
if incremental:
|
| 760 |
+
hull.add_points(np.zeros((1, 2)))
|
| 761 |
+
actual = hull.good
|
| 762 |
+
assert actual is None
|
| 763 |
+
|
| 764 |
+
@pytest.mark.parametrize("incremental", [False, True])
|
| 765 |
+
def test_good2d_inside(self, incremental):
|
| 766 |
+
# Make sure the QGn option gives the correct value of "good".
|
| 767 |
+
# When point n is inside the convex hull of the rest, good is
|
| 768 |
+
# all False.
|
| 769 |
+
points = np.array([[0.2, 0.2],
|
| 770 |
+
[0.2, 0.4],
|
| 771 |
+
[0.4, 0.4],
|
| 772 |
+
[0.4, 0.2],
|
| 773 |
+
[0.3, 0.3]])
|
| 774 |
+
hull = qhull.ConvexHull(points=points,
|
| 775 |
+
incremental=incremental,
|
| 776 |
+
qhull_options='QG4')
|
| 777 |
+
expected = np.array([False, False, False, False], dtype=bool)
|
| 778 |
+
actual = hull.good
|
| 779 |
+
assert_equal(actual, expected)
|
| 780 |
+
|
| 781 |
+
@pytest.mark.parametrize("incremental", [False, True])
|
| 782 |
+
def test_good3d(self, incremental):
|
| 783 |
+
# Make sure the QGn option gives the correct value of "good"
|
| 784 |
+
# for a 3d figure
|
| 785 |
+
points = np.array([[0.0, 0.0, 0.0],
|
| 786 |
+
[0.90029516, -0.39187448, 0.18948093],
|
| 787 |
+
[0.48676420, -0.72627633, 0.48536925],
|
| 788 |
+
[0.57651530, -0.81179274, -0.09285832],
|
| 789 |
+
[0.67846893, -0.71119562, 0.18406710]])
|
| 790 |
+
hull = qhull.ConvexHull(points=points,
|
| 791 |
+
incremental=incremental,
|
| 792 |
+
qhull_options='QG0')
|
| 793 |
+
expected = np.array([True, False, False, False], dtype=bool)
|
| 794 |
+
assert_equal(hull.good, expected)
|
| 795 |
+
|
| 796 |
+
class TestVoronoi:
|
| 797 |
+
|
| 798 |
+
@pytest.mark.parametrize("qhull_opts, extra_pts", [
|
| 799 |
+
# option Qz (default for SciPy) will add
|
| 800 |
+
# an extra point at infinity
|
| 801 |
+
("Qbb Qc Qz", 1),
|
| 802 |
+
("Qbb Qc", 0),
|
| 803 |
+
])
|
| 804 |
+
@pytest.mark.parametrize("n_pts", [50, 100])
|
| 805 |
+
@pytest.mark.parametrize("ndim", [2, 3])
|
| 806 |
+
def test_point_region_structure(self,
|
| 807 |
+
qhull_opts,
|
| 808 |
+
n_pts,
|
| 809 |
+
extra_pts,
|
| 810 |
+
ndim):
|
| 811 |
+
# see gh-16773
|
| 812 |
+
rng = np.random.default_rng(7790)
|
| 813 |
+
points = rng.random((n_pts, ndim))
|
| 814 |
+
vor = Voronoi(points, qhull_options=qhull_opts)
|
| 815 |
+
pt_region = vor.point_region
|
| 816 |
+
assert pt_region.max() == n_pts - 1 + extra_pts
|
| 817 |
+
assert pt_region.size == len(vor.regions) - extra_pts
|
| 818 |
+
assert len(vor.regions) == n_pts + extra_pts
|
| 819 |
+
assert vor.points.shape[0] == n_pts
|
| 820 |
+
# if there is an empty sublist in the Voronoi
|
| 821 |
+
# regions data structure, it should never be
|
| 822 |
+
# indexed because it corresponds to an internally
|
| 823 |
+
# added point at infinity and is not a member of the
|
| 824 |
+
# generators (input points)
|
| 825 |
+
if extra_pts:
|
| 826 |
+
sublens = [len(x) for x in vor.regions]
|
| 827 |
+
# only one point at infinity (empty region)
|
| 828 |
+
# is allowed
|
| 829 |
+
assert sublens.count(0) == 1
|
| 830 |
+
assert sublens.index(0) not in pt_region
|
| 831 |
+
|
| 832 |
+
def test_masked_array_fails(self):
|
| 833 |
+
masked_array = np.ma.masked_all(1)
|
| 834 |
+
assert_raises(ValueError, qhull.Voronoi, masked_array)
|
| 835 |
+
|
| 836 |
+
def test_simple(self):
|
| 837 |
+
# Simple case with known Voronoi diagram
|
| 838 |
+
points = [(0, 0), (0, 1), (0, 2),
|
| 839 |
+
(1, 0), (1, 1), (1, 2),
|
| 840 |
+
(2, 0), (2, 1), (2, 2)]
|
| 841 |
+
|
| 842 |
+
# qhull v o Fv Qbb Qc Qz < dat
|
| 843 |
+
output = """
|
| 844 |
+
2
|
| 845 |
+
5 10 1
|
| 846 |
+
-10.101 -10.101
|
| 847 |
+
0.5 0.5
|
| 848 |
+
0.5 1.5
|
| 849 |
+
1.5 0.5
|
| 850 |
+
1.5 1.5
|
| 851 |
+
2 0 1
|
| 852 |
+
3 2 0 1
|
| 853 |
+
2 0 2
|
| 854 |
+
3 3 0 1
|
| 855 |
+
4 1 2 4 3
|
| 856 |
+
3 4 0 2
|
| 857 |
+
2 0 3
|
| 858 |
+
3 4 0 3
|
| 859 |
+
2 0 4
|
| 860 |
+
0
|
| 861 |
+
12
|
| 862 |
+
4 0 3 0 1
|
| 863 |
+
4 0 1 0 1
|
| 864 |
+
4 1 4 1 2
|
| 865 |
+
4 1 2 0 2
|
| 866 |
+
4 2 5 0 2
|
| 867 |
+
4 3 4 1 3
|
| 868 |
+
4 3 6 0 3
|
| 869 |
+
4 4 5 2 4
|
| 870 |
+
4 4 7 3 4
|
| 871 |
+
4 5 8 0 4
|
| 872 |
+
4 6 7 0 3
|
| 873 |
+
4 7 8 0 4
|
| 874 |
+
"""
|
| 875 |
+
self._compare_qvoronoi(points, output)
|
| 876 |
+
|
| 877 |
+
def _compare_qvoronoi(self, points, output, **kw):
|
| 878 |
+
"""Compare to output from 'qvoronoi o Fv < data' to Voronoi()"""
|
| 879 |
+
|
| 880 |
+
# Parse output
|
| 881 |
+
output = [list(map(float, x.split())) for x in output.strip().splitlines()]
|
| 882 |
+
nvertex = int(output[1][0])
|
| 883 |
+
vertices = list(map(tuple, output[3:2+nvertex])) # exclude inf
|
| 884 |
+
nregion = int(output[1][1])
|
| 885 |
+
regions = [[int(y)-1 for y in x[1:]]
|
| 886 |
+
for x in output[2+nvertex:2+nvertex+nregion]]
|
| 887 |
+
ridge_points = [[int(y) for y in x[1:3]]
|
| 888 |
+
for x in output[3+nvertex+nregion:]]
|
| 889 |
+
ridge_vertices = [[int(y)-1 for y in x[3:]]
|
| 890 |
+
for x in output[3+nvertex+nregion:]]
|
| 891 |
+
|
| 892 |
+
# Compare results
|
| 893 |
+
vor = qhull.Voronoi(points, **kw)
|
| 894 |
+
|
| 895 |
+
def sorttuple(x):
|
| 896 |
+
return tuple(sorted(x))
|
| 897 |
+
|
| 898 |
+
assert_allclose(vor.vertices, vertices)
|
| 899 |
+
assert_equal(set(map(tuple, vor.regions)),
|
| 900 |
+
set(map(tuple, regions)))
|
| 901 |
+
|
| 902 |
+
p1 = list(zip(list(map(sorttuple, ridge_points)),
|
| 903 |
+
list(map(sorttuple, ridge_vertices))))
|
| 904 |
+
p2 = list(zip(list(map(sorttuple, vor.ridge_points.tolist())),
|
| 905 |
+
list(map(sorttuple, vor.ridge_vertices))))
|
| 906 |
+
p1.sort()
|
| 907 |
+
p2.sort()
|
| 908 |
+
|
| 909 |
+
assert_equal(p1, p2)
|
| 910 |
+
|
| 911 |
+
@pytest.mark.parametrize("name", sorted(DATASETS))
|
| 912 |
+
def test_ridges(self, name):
|
| 913 |
+
# Check that the ridges computed by Voronoi indeed separate
|
| 914 |
+
# the regions of nearest neighborhood, by comparing the result
|
| 915 |
+
# to KDTree.
|
| 916 |
+
|
| 917 |
+
points = DATASETS[name]
|
| 918 |
+
|
| 919 |
+
tree = KDTree(points)
|
| 920 |
+
vor = qhull.Voronoi(points)
|
| 921 |
+
|
| 922 |
+
for p, v in vor.ridge_dict.items():
|
| 923 |
+
# consider only finite ridges
|
| 924 |
+
if not np.all(np.asarray(v) >= 0):
|
| 925 |
+
continue
|
| 926 |
+
|
| 927 |
+
ridge_midpoint = vor.vertices[v].mean(axis=0)
|
| 928 |
+
d = 1e-6 * (points[p[0]] - ridge_midpoint)
|
| 929 |
+
|
| 930 |
+
dist, k = tree.query(ridge_midpoint + d, k=1)
|
| 931 |
+
assert_equal(k, p[0])
|
| 932 |
+
|
| 933 |
+
dist, k = tree.query(ridge_midpoint - d, k=1)
|
| 934 |
+
assert_equal(k, p[1])
|
| 935 |
+
|
| 936 |
+
def test_furthest_site(self):
|
| 937 |
+
points = [(0, 0), (0, 1), (1, 0), (0.5, 0.5), (1.1, 1.1)]
|
| 938 |
+
|
| 939 |
+
# qhull v o Fv Qbb Qc Qu < dat
|
| 940 |
+
output = """
|
| 941 |
+
2
|
| 942 |
+
3 5 1
|
| 943 |
+
-10.101 -10.101
|
| 944 |
+
0.6000000000000001 0.5
|
| 945 |
+
0.5 0.6000000000000001
|
| 946 |
+
3 0 2 1
|
| 947 |
+
2 0 1
|
| 948 |
+
2 0 2
|
| 949 |
+
0
|
| 950 |
+
3 0 2 1
|
| 951 |
+
5
|
| 952 |
+
4 0 2 0 2
|
| 953 |
+
4 0 4 1 2
|
| 954 |
+
4 0 1 0 1
|
| 955 |
+
4 1 4 0 1
|
| 956 |
+
4 2 4 0 2
|
| 957 |
+
"""
|
| 958 |
+
self._compare_qvoronoi(points, output, furthest_site=True)
|
| 959 |
+
|
| 960 |
+
def test_furthest_site_flag(self):
|
| 961 |
+
points = [(0, 0), (0, 1), (1, 0), (0.5, 0.5), (1.1, 1.1)]
|
| 962 |
+
|
| 963 |
+
vor = Voronoi(points)
|
| 964 |
+
assert_equal(vor.furthest_site,False)
|
| 965 |
+
vor = Voronoi(points,furthest_site=True)
|
| 966 |
+
assert_equal(vor.furthest_site,True)
|
| 967 |
+
|
| 968 |
+
@pytest.mark.fail_slow(10)
|
| 969 |
+
@pytest.mark.parametrize("name", sorted(INCREMENTAL_DATASETS))
|
| 970 |
+
def test_incremental(self, name):
|
| 971 |
+
# Test incremental construction of the triangulation
|
| 972 |
+
|
| 973 |
+
if INCREMENTAL_DATASETS[name][0][0].shape[1] > 3:
|
| 974 |
+
# too slow (testing of the result --- qhull is still fast)
|
| 975 |
+
return
|
| 976 |
+
|
| 977 |
+
chunks, opts = INCREMENTAL_DATASETS[name]
|
| 978 |
+
points = np.concatenate(chunks, axis=0)
|
| 979 |
+
|
| 980 |
+
obj = qhull.Voronoi(chunks[0], incremental=True,
|
| 981 |
+
qhull_options=opts)
|
| 982 |
+
for chunk in chunks[1:]:
|
| 983 |
+
obj.add_points(chunk)
|
| 984 |
+
|
| 985 |
+
obj2 = qhull.Voronoi(points)
|
| 986 |
+
|
| 987 |
+
obj3 = qhull.Voronoi(chunks[0], incremental=True,
|
| 988 |
+
qhull_options=opts)
|
| 989 |
+
if len(chunks) > 1:
|
| 990 |
+
obj3.add_points(np.concatenate(chunks[1:], axis=0),
|
| 991 |
+
restart=True)
|
| 992 |
+
|
| 993 |
+
# -- Check that the incremental mode agrees with upfront mode
|
| 994 |
+
assert_equal(len(obj.point_region), len(obj2.point_region))
|
| 995 |
+
assert_equal(len(obj.point_region), len(obj3.point_region))
|
| 996 |
+
|
| 997 |
+
# The vertices may be in different order or duplicated in
|
| 998 |
+
# the incremental map
|
| 999 |
+
for objx in obj, obj3:
|
| 1000 |
+
vertex_map = {-1: -1}
|
| 1001 |
+
for i, v in enumerate(objx.vertices):
|
| 1002 |
+
for j, v2 in enumerate(obj2.vertices):
|
| 1003 |
+
if np.allclose(v, v2):
|
| 1004 |
+
vertex_map[i] = j
|
| 1005 |
+
|
| 1006 |
+
def remap(x):
|
| 1007 |
+
if hasattr(x, '__len__'):
|
| 1008 |
+
return tuple({remap(y) for y in x})
|
| 1009 |
+
try:
|
| 1010 |
+
return vertex_map[x]
|
| 1011 |
+
except KeyError as e:
|
| 1012 |
+
message = (f"incremental result has spurious vertex "
|
| 1013 |
+
f"at {objx.vertices[x]!r}")
|
| 1014 |
+
raise AssertionError(message) from e
|
| 1015 |
+
|
| 1016 |
+
def simplified(x):
|
| 1017 |
+
items = set(map(sorted_tuple, x))
|
| 1018 |
+
if () in items:
|
| 1019 |
+
items.remove(())
|
| 1020 |
+
items = [x for x in items if len(x) > 1]
|
| 1021 |
+
items.sort()
|
| 1022 |
+
return items
|
| 1023 |
+
|
| 1024 |
+
assert_equal(
|
| 1025 |
+
simplified(remap(objx.regions)),
|
| 1026 |
+
simplified(obj2.regions)
|
| 1027 |
+
)
|
| 1028 |
+
assert_equal(
|
| 1029 |
+
simplified(remap(objx.ridge_vertices)),
|
| 1030 |
+
simplified(obj2.ridge_vertices)
|
| 1031 |
+
)
|
| 1032 |
+
|
| 1033 |
+
# XXX: compare ridge_points --- not clear exactly how to do this
|
| 1034 |
+
|
| 1035 |
+
|
| 1036 |
+
class Test_HalfspaceIntersection:
|
| 1037 |
+
def assert_unordered_allclose(self, arr1, arr2, rtol=1e-7):
|
| 1038 |
+
"""Check that every line in arr1 is only once in arr2"""
|
| 1039 |
+
assert_equal(arr1.shape, arr2.shape)
|
| 1040 |
+
|
| 1041 |
+
truths = np.zeros((arr1.shape[0],), dtype=bool)
|
| 1042 |
+
for l1 in arr1:
|
| 1043 |
+
indexes = np.nonzero((abs(arr2 - l1) < rtol).all(axis=1))[0]
|
| 1044 |
+
assert_equal(indexes.shape, (1,))
|
| 1045 |
+
truths[indexes[0]] = True
|
| 1046 |
+
assert_(truths.all())
|
| 1047 |
+
|
| 1048 |
+
@pytest.mark.parametrize("dt", [np.float64, int])
|
| 1049 |
+
def test_cube_halfspace_intersection(self, dt):
|
| 1050 |
+
halfspaces = np.array([[-1, 0, 0],
|
| 1051 |
+
[0, -1, 0],
|
| 1052 |
+
[1, 0, -2],
|
| 1053 |
+
[0, 1, -2]], dtype=dt)
|
| 1054 |
+
feasible_point = np.array([1, 1], dtype=dt)
|
| 1055 |
+
|
| 1056 |
+
points = np.array([[0.0, 0.0], [2.0, 0.0], [0.0, 2.0], [2.0, 2.0]])
|
| 1057 |
+
|
| 1058 |
+
hull = qhull.HalfspaceIntersection(halfspaces, feasible_point)
|
| 1059 |
+
|
| 1060 |
+
assert_allclose(hull.intersections, points)
|
| 1061 |
+
|
| 1062 |
+
def test_self_dual_polytope_intersection(self):
|
| 1063 |
+
fname = os.path.join(os.path.dirname(__file__), 'data',
|
| 1064 |
+
'selfdual-4d-polytope.txt')
|
| 1065 |
+
ineqs = np.genfromtxt(fname)
|
| 1066 |
+
halfspaces = -np.hstack((ineqs[:, 1:], ineqs[:, :1]))
|
| 1067 |
+
|
| 1068 |
+
feas_point = np.array([0., 0., 0., 0.])
|
| 1069 |
+
hs = qhull.HalfspaceIntersection(halfspaces, feas_point)
|
| 1070 |
+
|
| 1071 |
+
assert_equal(hs.intersections.shape, (24, 4))
|
| 1072 |
+
|
| 1073 |
+
assert_almost_equal(hs.dual_volume, 32.0)
|
| 1074 |
+
assert_equal(len(hs.dual_facets), 24)
|
| 1075 |
+
for facet in hs.dual_facets:
|
| 1076 |
+
assert_equal(len(facet), 6)
|
| 1077 |
+
|
| 1078 |
+
dists = halfspaces[:, -1] + halfspaces[:, :-1].dot(feas_point)
|
| 1079 |
+
self.assert_unordered_allclose((halfspaces[:, :-1].T/dists).T, hs.dual_points)
|
| 1080 |
+
|
| 1081 |
+
points = itertools.permutations([0., 0., 0.5, -0.5])
|
| 1082 |
+
for point in points:
|
| 1083 |
+
assert_equal(np.sum((hs.intersections == point).all(axis=1)), 1)
|
| 1084 |
+
|
| 1085 |
+
def test_wrong_feasible_point(self):
|
| 1086 |
+
halfspaces = np.array([[-1.0, 0.0, 0.0],
|
| 1087 |
+
[0.0, -1.0, 0.0],
|
| 1088 |
+
[1.0, 0.0, -1.0],
|
| 1089 |
+
[0.0, 1.0, -1.0]])
|
| 1090 |
+
feasible_point = np.array([0.5, 0.5, 0.5])
|
| 1091 |
+
#Feasible point is (ndim,) instead of (ndim-1,)
|
| 1092 |
+
assert_raises(ValueError,
|
| 1093 |
+
qhull.HalfspaceIntersection, halfspaces, feasible_point)
|
| 1094 |
+
feasible_point = np.array([[0.5], [0.5]])
|
| 1095 |
+
#Feasible point is (ndim-1, 1) instead of (ndim-1,)
|
| 1096 |
+
assert_raises(ValueError,
|
| 1097 |
+
qhull.HalfspaceIntersection, halfspaces, feasible_point)
|
| 1098 |
+
feasible_point = np.array([[0.5, 0.5]])
|
| 1099 |
+
#Feasible point is (1, ndim-1) instead of (ndim-1,)
|
| 1100 |
+
assert_raises(ValueError,
|
| 1101 |
+
qhull.HalfspaceIntersection, halfspaces, feasible_point)
|
| 1102 |
+
|
| 1103 |
+
feasible_point = np.array([-0.5, -0.5])
|
| 1104 |
+
#Feasible point is outside feasible region
|
| 1105 |
+
assert_raises(qhull.QhullError,
|
| 1106 |
+
qhull.HalfspaceIntersection, halfspaces, feasible_point)
|
| 1107 |
+
|
| 1108 |
+
def test_incremental(self):
|
| 1109 |
+
#Cube
|
| 1110 |
+
halfspaces = np.array([[0., 0., -1., -0.5],
|
| 1111 |
+
[0., -1., 0., -0.5],
|
| 1112 |
+
[-1., 0., 0., -0.5],
|
| 1113 |
+
[1., 0., 0., -0.5],
|
| 1114 |
+
[0., 1., 0., -0.5],
|
| 1115 |
+
[0., 0., 1., -0.5]])
|
| 1116 |
+
#Cut each summit
|
| 1117 |
+
extra_normals = np.array([[1., 1., 1.],
|
| 1118 |
+
[1., 1., -1.],
|
| 1119 |
+
[1., -1., 1.],
|
| 1120 |
+
[1, -1., -1.]])
|
| 1121 |
+
offsets = np.array([[-1.]]*8)
|
| 1122 |
+
extra_halfspaces = np.hstack((np.vstack((extra_normals, -extra_normals)),
|
| 1123 |
+
offsets))
|
| 1124 |
+
|
| 1125 |
+
feas_point = np.array([0., 0., 0.])
|
| 1126 |
+
|
| 1127 |
+
inc_hs = qhull.HalfspaceIntersection(halfspaces, feas_point, incremental=True)
|
| 1128 |
+
|
| 1129 |
+
inc_res_hs = qhull.HalfspaceIntersection(halfspaces, feas_point,
|
| 1130 |
+
incremental=True)
|
| 1131 |
+
|
| 1132 |
+
for i, ehs in enumerate(extra_halfspaces):
|
| 1133 |
+
inc_hs.add_halfspaces(ehs[np.newaxis, :])
|
| 1134 |
+
|
| 1135 |
+
inc_res_hs.add_halfspaces(ehs[np.newaxis, :], restart=True)
|
| 1136 |
+
|
| 1137 |
+
total = np.vstack((halfspaces, extra_halfspaces[:i+1, :]))
|
| 1138 |
+
|
| 1139 |
+
hs = qhull.HalfspaceIntersection(total, feas_point)
|
| 1140 |
+
|
| 1141 |
+
assert_allclose(inc_hs.halfspaces, inc_res_hs.halfspaces)
|
| 1142 |
+
assert_allclose(inc_hs.halfspaces, hs.halfspaces)
|
| 1143 |
+
|
| 1144 |
+
#Direct computation and restart should have points in same order
|
| 1145 |
+
assert_allclose(hs.intersections, inc_res_hs.intersections)
|
| 1146 |
+
#Incremental will have points in different order than direct computation
|
| 1147 |
+
self.assert_unordered_allclose(inc_hs.intersections, hs.intersections)
|
| 1148 |
+
|
| 1149 |
+
inc_hs.close()
|
| 1150 |
+
|
| 1151 |
+
def test_cube(self):
|
| 1152 |
+
# Halfspaces of the cube:
|
| 1153 |
+
halfspaces = np.array([[-1., 0., 0., 0.], # x >= 0
|
| 1154 |
+
[1., 0., 0., -1.], # x <= 1
|
| 1155 |
+
[0., -1., 0., 0.], # y >= 0
|
| 1156 |
+
[0., 1., 0., -1.], # y <= 1
|
| 1157 |
+
[0., 0., -1., 0.], # z >= 0
|
| 1158 |
+
[0., 0., 1., -1.]]) # z <= 1
|
| 1159 |
+
point = np.array([0.5, 0.5, 0.5])
|
| 1160 |
+
|
| 1161 |
+
hs = qhull.HalfspaceIntersection(halfspaces, point)
|
| 1162 |
+
|
| 1163 |
+
# qhalf H0.5,0.5,0.5 o < input.txt
|
| 1164 |
+
qhalf_points = np.array([
|
| 1165 |
+
[-2, 0, 0],
|
| 1166 |
+
[2, 0, 0],
|
| 1167 |
+
[0, -2, 0],
|
| 1168 |
+
[0, 2, 0],
|
| 1169 |
+
[0, 0, -2],
|
| 1170 |
+
[0, 0, 2]])
|
| 1171 |
+
qhalf_facets = [
|
| 1172 |
+
[2, 4, 0],
|
| 1173 |
+
[4, 2, 1],
|
| 1174 |
+
[5, 2, 0],
|
| 1175 |
+
[2, 5, 1],
|
| 1176 |
+
[3, 4, 1],
|
| 1177 |
+
[4, 3, 0],
|
| 1178 |
+
[5, 3, 1],
|
| 1179 |
+
[3, 5, 0]]
|
| 1180 |
+
|
| 1181 |
+
assert len(qhalf_facets) == len(hs.dual_facets)
|
| 1182 |
+
for a, b in zip(qhalf_facets, hs.dual_facets):
|
| 1183 |
+
assert set(a) == set(b) # facet orientation can differ
|
| 1184 |
+
|
| 1185 |
+
assert_allclose(hs.dual_points, qhalf_points)
|
| 1186 |
+
|
| 1187 |
+
@pytest.mark.parametrize("k", range(1,4))
|
| 1188 |
+
def test_halfspace_batch(self, k):
|
| 1189 |
+
# Test that we can add halfspaces a few at a time
|
| 1190 |
+
big_square = np.array([[ 1., 0., -2.],
|
| 1191 |
+
[-1., 0., -2.],
|
| 1192 |
+
[ 0., 1., -2.],
|
| 1193 |
+
[ 0., -1., -2.]])
|
| 1194 |
+
|
| 1195 |
+
small_square = np.array([[ 1., 0., -1.],
|
| 1196 |
+
[-1., 0., -1.],
|
| 1197 |
+
[ 0., 1., -1.],
|
| 1198 |
+
[ 0., -1., -1.]])
|
| 1199 |
+
|
| 1200 |
+
hs = qhull.HalfspaceIntersection(big_square,
|
| 1201 |
+
np.array([0.3141, 0.2718]),
|
| 1202 |
+
incremental=True)
|
| 1203 |
+
|
| 1204 |
+
hs.add_halfspaces(small_square[0:k,:])
|
| 1205 |
+
hs.add_halfspaces(small_square[k:4,:])
|
| 1206 |
+
hs.close()
|
| 1207 |
+
|
| 1208 |
+
# Check the intersections are correct (they are the corners of the small square)
|
| 1209 |
+
expected_intersections = np.array([[1., 1.],
|
| 1210 |
+
[1., -1.],
|
| 1211 |
+
[-1., 1.],
|
| 1212 |
+
[-1., -1.]])
|
| 1213 |
+
actual_intersections = hs.intersections
|
| 1214 |
+
# They may be in any order, so just check that under some permutation
|
| 1215 |
+
# expected=actual.
|
| 1216 |
+
|
| 1217 |
+
ind1 = np.lexsort((actual_intersections[:, 1], actual_intersections[:, 0]))
|
| 1218 |
+
ind2 = np.lexsort((expected_intersections[:, 1], expected_intersections[:, 0]))
|
| 1219 |
+
assert_allclose(actual_intersections[ind1], expected_intersections[ind2])
|
| 1220 |
+
|
| 1221 |
+
|
| 1222 |
+
@pytest.mark.parametrize("halfspaces", [
|
| 1223 |
+
(np.array([-0.70613882, -0.45589431, 0.04178256])),
|
| 1224 |
+
(np.array([[-0.70613882, -0.45589431, 0.04178256],
|
| 1225 |
+
[0.70807342, -0.45464871, -0.45969769],
|
| 1226 |
+
[0., 0.76515026, -0.35614825]])),
|
| 1227 |
+
])
|
| 1228 |
+
def test_gh_19865(self, halfspaces):
|
| 1229 |
+
# starting off with a feasible interior point and
|
| 1230 |
+
# adding halfspaces for which it is no longer feasible
|
| 1231 |
+
# should result in an error rather than a problematic
|
| 1232 |
+
# intersection polytope
|
| 1233 |
+
initial_square = np.array(
|
| 1234 |
+
[[1, 0, -1], [0, 1, -1], [-1, 0, -1], [0, -1, -1]]
|
| 1235 |
+
)
|
| 1236 |
+
incremental_intersector = qhull.HalfspaceIntersection(initial_square,
|
| 1237 |
+
np.zeros(2),
|
| 1238 |
+
incremental=True)
|
| 1239 |
+
with pytest.raises(qhull.QhullError, match="feasible.*-0.706.*"):
|
| 1240 |
+
incremental_intersector.add_halfspaces(halfspaces)
|
| 1241 |
+
|
| 1242 |
+
|
| 1243 |
+
def test_gh_19865_3d(self):
|
| 1244 |
+
# 3d case where closed half space is enforced for
|
| 1245 |
+
# feasibility
|
| 1246 |
+
halfspaces = np.array([[1, 1, 1, -1], # doesn't exclude origin
|
| 1247 |
+
[-1, -1, -1, -1], # doesn't exclude origin
|
| 1248 |
+
[1, 0, 0, 0]]) # the origin is on the line
|
| 1249 |
+
initial_cube = np.array([[1, 0, 0, -1],
|
| 1250 |
+
[-1, 0, 0, -1],
|
| 1251 |
+
[0, 1, 0, -1],
|
| 1252 |
+
[0, -1, 0, -1],
|
| 1253 |
+
[0, 0, 1, -1],
|
| 1254 |
+
[0, 0, -1, -1]])
|
| 1255 |
+
incremental_intersector = qhull.HalfspaceIntersection(initial_cube,
|
| 1256 |
+
np.zeros(3),
|
| 1257 |
+
incremental=True)
|
| 1258 |
+
with pytest.raises(qhull.QhullError, match="feasible.*[1 0 0 0]"):
|
| 1259 |
+
incremental_intersector.add_halfspaces(halfspaces)
|
| 1260 |
+
|
| 1261 |
+
|
| 1262 |
+
def test_2d_add_halfspace_input(self):
|
| 1263 |
+
# incrementally added halfspaces should respect the 2D
|
| 1264 |
+
# array shape requirement
|
| 1265 |
+
initial_square = np.array(
|
| 1266 |
+
[[1, 0, -1], [0, 1, -1], [-1, 0, -1], [0, -1, -1]]
|
| 1267 |
+
)
|
| 1268 |
+
incremental_intersector = qhull.HalfspaceIntersection(initial_square,
|
| 1269 |
+
np.zeros(2),
|
| 1270 |
+
incremental=True)
|
| 1271 |
+
with pytest.raises(ValueError, match="2D array"):
|
| 1272 |
+
incremental_intersector.add_halfspaces(np.ones((4, 4, 4)))
|
| 1273 |
+
|
| 1274 |
+
def test_1d_add_halfspace_input(self):
|
| 1275 |
+
# we do allow 1D `halfspaces` input to add_halfspaces()
|
| 1276 |
+
initial_square = np.array(
|
| 1277 |
+
[[1, 0, -1], [0, 1, -1], [-1, 0, -1], [0, -1, -1]]
|
| 1278 |
+
)
|
| 1279 |
+
incremental_intersector = qhull.HalfspaceIntersection(initial_square,
|
| 1280 |
+
np.zeros(2),
|
| 1281 |
+
incremental=True)
|
| 1282 |
+
assert_allclose(incremental_intersector.dual_vertices, np.arange(4))
|
| 1283 |
+
incremental_intersector.add_halfspaces(np.array([2, 2, -1]))
|
| 1284 |
+
assert_allclose(incremental_intersector.dual_vertices, np.arange(5))
|
| 1285 |
+
|
| 1286 |
+
|
| 1287 |
+
@pytest.mark.parametrize("diagram_type", [Voronoi, qhull.Delaunay])
|
| 1288 |
+
def test_gh_20623(diagram_type):
|
| 1289 |
+
rng = np.random.default_rng(123)
|
| 1290 |
+
invalid_data = rng.random((4, 10, 3))
|
| 1291 |
+
with pytest.raises(ValueError, match="dimensions"):
|
| 1292 |
+
diagram_type(invalid_data)
|
| 1293 |
+
|
| 1294 |
+
|
| 1295 |
+
def test_gh_21286():
|
| 1296 |
+
generators = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]])
|
| 1297 |
+
tri = qhull.Delaunay(generators)
|
| 1298 |
+
# verify absence of segfault reported in ticket:
|
| 1299 |
+
with pytest.raises(IndexError):
|
| 1300 |
+
tri.find_simplex(1)
|
| 1301 |
+
with pytest.raises(IndexError):
|
| 1302 |
+
# strikingly, Delaunay object has shape
|
| 1303 |
+
# () just like np.asanyarray(1) above
|
| 1304 |
+
tri.find_simplex(tri)
|
| 1305 |
+
|
| 1306 |
+
|
| 1307 |
+
def test_find_simplex_ndim_err():
|
| 1308 |
+
generators = np.array([[0, 0], [0, 1.1], [1, 0], [1, 1]])
|
| 1309 |
+
tri = qhull.Delaunay(generators)
|
| 1310 |
+
with pytest.raises(ValueError):
|
| 1311 |
+
tri.find_simplex([2, 2, 2])
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_slerp.py
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
import warnings
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
from numpy.testing import assert_allclose
|
| 6 |
+
|
| 7 |
+
import pytest
|
| 8 |
+
from scipy.spatial import geometric_slerp
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def _generate_spherical_points(ndim=3, n_pts=2):
|
| 12 |
+
# generate uniform points on sphere
|
| 13 |
+
# see: https://stackoverflow.com/a/23785326
|
| 14 |
+
# tentatively extended to arbitrary dims
|
| 15 |
+
# for 0-sphere it will always produce antipodes
|
| 16 |
+
np.random.seed(123)
|
| 17 |
+
points = np.random.normal(size=(n_pts, ndim))
|
| 18 |
+
points /= np.linalg.norm(points, axis=1)[:, np.newaxis]
|
| 19 |
+
return points[0], points[1]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class TestGeometricSlerp:
|
| 23 |
+
# Test various properties of the geometric slerp code
|
| 24 |
+
|
| 25 |
+
@pytest.mark.parametrize("n_dims", [2, 3, 5, 7, 9])
|
| 26 |
+
@pytest.mark.parametrize("n_pts", [0, 3, 17])
|
| 27 |
+
def test_shape_property(self, n_dims, n_pts):
|
| 28 |
+
# geometric_slerp output shape should match
|
| 29 |
+
# input dimensionality & requested number
|
| 30 |
+
# of interpolation points
|
| 31 |
+
start, end = _generate_spherical_points(n_dims, 2)
|
| 32 |
+
|
| 33 |
+
actual = geometric_slerp(start=start,
|
| 34 |
+
end=end,
|
| 35 |
+
t=np.linspace(0, 1, n_pts))
|
| 36 |
+
|
| 37 |
+
assert actual.shape == (n_pts, n_dims)
|
| 38 |
+
|
| 39 |
+
@pytest.mark.parametrize("n_dims", [2, 3, 5, 7, 9])
|
| 40 |
+
@pytest.mark.parametrize("n_pts", [3, 17])
|
| 41 |
+
def test_include_ends(self, n_dims, n_pts):
|
| 42 |
+
# geometric_slerp should return a data structure
|
| 43 |
+
# that includes the start and end coordinates
|
| 44 |
+
# when t includes 0 and 1 ends
|
| 45 |
+
# this is convenient for plotting surfaces represented
|
| 46 |
+
# by interpolations for example
|
| 47 |
+
|
| 48 |
+
# the generator doesn't work so well for the unit
|
| 49 |
+
# sphere (it always produces antipodes), so use
|
| 50 |
+
# custom values there
|
| 51 |
+
start, end = _generate_spherical_points(n_dims, 2)
|
| 52 |
+
|
| 53 |
+
actual = geometric_slerp(start=start,
|
| 54 |
+
end=end,
|
| 55 |
+
t=np.linspace(0, 1, n_pts))
|
| 56 |
+
|
| 57 |
+
assert_allclose(actual[0], start)
|
| 58 |
+
assert_allclose(actual[-1], end)
|
| 59 |
+
|
| 60 |
+
@pytest.mark.parametrize("start, end", [
|
| 61 |
+
# both arrays are not flat
|
| 62 |
+
(np.zeros((1, 3)), np.ones((1, 3))),
|
| 63 |
+
# only start array is not flat
|
| 64 |
+
(np.zeros((1, 3)), np.ones(3)),
|
| 65 |
+
# only end array is not flat
|
| 66 |
+
(np.zeros(1), np.ones((3, 1))),
|
| 67 |
+
])
|
| 68 |
+
def test_input_shape_flat(self, start, end):
|
| 69 |
+
# geometric_slerp should handle input arrays that are
|
| 70 |
+
# not flat appropriately
|
| 71 |
+
with pytest.raises(ValueError, match='one-dimensional'):
|
| 72 |
+
geometric_slerp(start=start,
|
| 73 |
+
end=end,
|
| 74 |
+
t=np.linspace(0, 1, 10))
|
| 75 |
+
|
| 76 |
+
@pytest.mark.parametrize("start, end", [
|
| 77 |
+
# 7-D and 3-D ends
|
| 78 |
+
(np.zeros(7), np.ones(3)),
|
| 79 |
+
# 2-D and 1-D ends
|
| 80 |
+
(np.zeros(2), np.ones(1)),
|
| 81 |
+
# empty, "3D" will also get caught this way
|
| 82 |
+
(np.array([]), np.ones(3)),
|
| 83 |
+
])
|
| 84 |
+
def test_input_dim_mismatch(self, start, end):
|
| 85 |
+
# geometric_slerp must appropriately handle cases where
|
| 86 |
+
# an interpolation is attempted across two different
|
| 87 |
+
# dimensionalities
|
| 88 |
+
with pytest.raises(ValueError, match='dimensions'):
|
| 89 |
+
geometric_slerp(start=start,
|
| 90 |
+
end=end,
|
| 91 |
+
t=np.linspace(0, 1, 10))
|
| 92 |
+
|
| 93 |
+
@pytest.mark.parametrize("start, end", [
|
| 94 |
+
# both empty
|
| 95 |
+
(np.array([]), np.array([])),
|
| 96 |
+
])
|
| 97 |
+
def test_input_at_least1d(self, start, end):
|
| 98 |
+
# empty inputs to geometric_slerp must
|
| 99 |
+
# be handled appropriately when not detected
|
| 100 |
+
# by mismatch
|
| 101 |
+
with pytest.raises(ValueError, match='at least two-dim'):
|
| 102 |
+
geometric_slerp(start=start,
|
| 103 |
+
end=end,
|
| 104 |
+
t=np.linspace(0, 1, 10))
|
| 105 |
+
|
| 106 |
+
@pytest.mark.parametrize("start, end, expected", [
|
| 107 |
+
# North and South Poles are definitely antipodes
|
| 108 |
+
# but should be handled gracefully now
|
| 109 |
+
(np.array([0, 0, 1.0]), np.array([0, 0, -1.0]), "warning"),
|
| 110 |
+
# this case will issue a warning & be handled
|
| 111 |
+
# gracefully as well;
|
| 112 |
+
# North Pole was rotated very slightly
|
| 113 |
+
# using r = R.from_euler('x', 0.035, degrees=True)
|
| 114 |
+
# to achieve Euclidean distance offset from diameter by
|
| 115 |
+
# 9.328908379124812e-08, within the default tol
|
| 116 |
+
(np.array([0.00000000e+00,
|
| 117 |
+
-6.10865200e-04,
|
| 118 |
+
9.99999813e-01]), np.array([0, 0, -1.0]), "warning"),
|
| 119 |
+
# this case should succeed without warning because a
|
| 120 |
+
# sufficiently large
|
| 121 |
+
# rotation was applied to North Pole point to shift it
|
| 122 |
+
# to a Euclidean distance of 2.3036691931821451e-07
|
| 123 |
+
# from South Pole, which is larger than tol
|
| 124 |
+
(np.array([0.00000000e+00,
|
| 125 |
+
-9.59930941e-04,
|
| 126 |
+
9.99999539e-01]), np.array([0, 0, -1.0]), "success"),
|
| 127 |
+
])
|
| 128 |
+
def test_handle_antipodes(self, start, end, expected):
|
| 129 |
+
# antipodal points must be handled appropriately;
|
| 130 |
+
# there are an infinite number of possible geodesic
|
| 131 |
+
# interpolations between them in higher dims
|
| 132 |
+
if expected == "warning":
|
| 133 |
+
with pytest.warns(UserWarning, match='antipodes'):
|
| 134 |
+
res = geometric_slerp(start=start,
|
| 135 |
+
end=end,
|
| 136 |
+
t=np.linspace(0, 1, 10))
|
| 137 |
+
else:
|
| 138 |
+
res = geometric_slerp(start=start,
|
| 139 |
+
end=end,
|
| 140 |
+
t=np.linspace(0, 1, 10))
|
| 141 |
+
|
| 142 |
+
# antipodes or near-antipodes should still produce
|
| 143 |
+
# slerp paths on the surface of the sphere (but they
|
| 144 |
+
# may be ambiguous):
|
| 145 |
+
assert_allclose(np.linalg.norm(res, axis=1), 1.0)
|
| 146 |
+
|
| 147 |
+
@pytest.mark.parametrize("start, end, expected", [
|
| 148 |
+
# 2-D with n_pts=4 (two new interpolation points)
|
| 149 |
+
# this is an actual circle
|
| 150 |
+
(np.array([1, 0]),
|
| 151 |
+
np.array([0, 1]),
|
| 152 |
+
np.array([[1, 0],
|
| 153 |
+
[np.sqrt(3) / 2, 0.5], # 30 deg on unit circle
|
| 154 |
+
[0.5, np.sqrt(3) / 2], # 60 deg on unit circle
|
| 155 |
+
[0, 1]])),
|
| 156 |
+
# likewise for 3-D (add z = 0 plane)
|
| 157 |
+
# this is an ordinary sphere
|
| 158 |
+
(np.array([1, 0, 0]),
|
| 159 |
+
np.array([0, 1, 0]),
|
| 160 |
+
np.array([[1, 0, 0],
|
| 161 |
+
[np.sqrt(3) / 2, 0.5, 0],
|
| 162 |
+
[0.5, np.sqrt(3) / 2, 0],
|
| 163 |
+
[0, 1, 0]])),
|
| 164 |
+
# for 5-D, pad more columns with constants
|
| 165 |
+
# zeros are easiest--non-zero values on unit
|
| 166 |
+
# circle are more difficult to reason about
|
| 167 |
+
# at higher dims
|
| 168 |
+
(np.array([1, 0, 0, 0, 0]),
|
| 169 |
+
np.array([0, 1, 0, 0, 0]),
|
| 170 |
+
np.array([[1, 0, 0, 0, 0],
|
| 171 |
+
[np.sqrt(3) / 2, 0.5, 0, 0, 0],
|
| 172 |
+
[0.5, np.sqrt(3) / 2, 0, 0, 0],
|
| 173 |
+
[0, 1, 0, 0, 0]])),
|
| 174 |
+
|
| 175 |
+
])
|
| 176 |
+
def test_straightforward_examples(self, start, end, expected):
|
| 177 |
+
# some straightforward interpolation tests, sufficiently
|
| 178 |
+
# simple to use the unit circle to deduce expected values;
|
| 179 |
+
# for larger dimensions, pad with constants so that the
|
| 180 |
+
# data is N-D but simpler to reason about
|
| 181 |
+
actual = geometric_slerp(start=start,
|
| 182 |
+
end=end,
|
| 183 |
+
t=np.linspace(0, 1, 4))
|
| 184 |
+
assert_allclose(actual, expected, atol=1e-16)
|
| 185 |
+
|
| 186 |
+
@pytest.mark.parametrize("start, end", [
|
| 187 |
+
(np.array([1]),
|
| 188 |
+
np.array([0])),
|
| 189 |
+
(np.array([0]),
|
| 190 |
+
np.array([1])),
|
| 191 |
+
(np.array([-17.7]),
|
| 192 |
+
np.array([165.9])),
|
| 193 |
+
])
|
| 194 |
+
def test_0_sphere_handling(self, start, end):
|
| 195 |
+
# it does not make sense to interpolate the set of
|
| 196 |
+
# two points that is the 0-sphere
|
| 197 |
+
with pytest.raises(ValueError, match='at least two-dim'):
|
| 198 |
+
_ = geometric_slerp(start=start,
|
| 199 |
+
end=end,
|
| 200 |
+
t=np.linspace(0, 1, 4))
|
| 201 |
+
|
| 202 |
+
@pytest.mark.parametrize("tol", [
|
| 203 |
+
# an integer currently raises
|
| 204 |
+
5,
|
| 205 |
+
# string raises
|
| 206 |
+
"7",
|
| 207 |
+
# list and arrays also raise
|
| 208 |
+
[5, 6, 7], np.array(9.0),
|
| 209 |
+
])
|
| 210 |
+
def test_tol_type(self, tol):
|
| 211 |
+
# geometric_slerp() should raise if tol is not
|
| 212 |
+
# a suitable float type
|
| 213 |
+
with pytest.raises(ValueError, match='must be a float'):
|
| 214 |
+
_ = geometric_slerp(start=np.array([1, 0]),
|
| 215 |
+
end=np.array([0, 1]),
|
| 216 |
+
t=np.linspace(0, 1, 5),
|
| 217 |
+
tol=tol)
|
| 218 |
+
|
| 219 |
+
@pytest.mark.parametrize("tol", [
|
| 220 |
+
-5e-6,
|
| 221 |
+
-7e-10,
|
| 222 |
+
])
|
| 223 |
+
def test_tol_sign(self, tol):
|
| 224 |
+
# geometric_slerp() currently handles negative
|
| 225 |
+
# tol values, as long as they are floats
|
| 226 |
+
_ = geometric_slerp(start=np.array([1, 0]),
|
| 227 |
+
end=np.array([0, 1]),
|
| 228 |
+
t=np.linspace(0, 1, 5),
|
| 229 |
+
tol=tol)
|
| 230 |
+
|
| 231 |
+
@pytest.mark.parametrize("start, end", [
|
| 232 |
+
# 1-sphere (circle) with one point at origin
|
| 233 |
+
# and the other on the circle
|
| 234 |
+
(np.array([1, 0]), np.array([0, 0])),
|
| 235 |
+
# 2-sphere (normal sphere) with both points
|
| 236 |
+
# just slightly off sphere by the same amount
|
| 237 |
+
# in different directions
|
| 238 |
+
(np.array([1 + 1e-6, 0, 0]),
|
| 239 |
+
np.array([0, 1 - 1e-6, 0])),
|
| 240 |
+
# same thing in 4-D
|
| 241 |
+
(np.array([1 + 1e-6, 0, 0, 0]),
|
| 242 |
+
np.array([0, 1 - 1e-6, 0, 0])),
|
| 243 |
+
])
|
| 244 |
+
def test_unit_sphere_enforcement(self, start, end):
|
| 245 |
+
# geometric_slerp() should raise on input that clearly
|
| 246 |
+
# cannot be on an n-sphere of radius 1
|
| 247 |
+
with pytest.raises(ValueError, match='unit n-sphere'):
|
| 248 |
+
geometric_slerp(start=start,
|
| 249 |
+
end=end,
|
| 250 |
+
t=np.linspace(0, 1, 5))
|
| 251 |
+
|
| 252 |
+
@pytest.mark.parametrize("start, end", [
|
| 253 |
+
# 1-sphere 45 degree case
|
| 254 |
+
(np.array([1, 0]),
|
| 255 |
+
np.array([np.sqrt(2) / 2.,
|
| 256 |
+
np.sqrt(2) / 2.])),
|
| 257 |
+
# 2-sphere 135 degree case
|
| 258 |
+
(np.array([1, 0]),
|
| 259 |
+
np.array([-np.sqrt(2) / 2.,
|
| 260 |
+
np.sqrt(2) / 2.])),
|
| 261 |
+
])
|
| 262 |
+
@pytest.mark.parametrize("t_func", [
|
| 263 |
+
np.linspace, np.logspace])
|
| 264 |
+
def test_order_handling(self, start, end, t_func):
|
| 265 |
+
# geometric_slerp() should handle scenarios with
|
| 266 |
+
# ascending and descending t value arrays gracefully;
|
| 267 |
+
# results should simply be reversed
|
| 268 |
+
|
| 269 |
+
# for scrambled / unsorted parameters, the same values
|
| 270 |
+
# should be returned, just in scrambled order
|
| 271 |
+
|
| 272 |
+
num_t_vals = 20
|
| 273 |
+
np.random.seed(789)
|
| 274 |
+
forward_t_vals = t_func(0, 10, num_t_vals)
|
| 275 |
+
# normalize to max of 1
|
| 276 |
+
forward_t_vals /= forward_t_vals.max()
|
| 277 |
+
reverse_t_vals = np.flipud(forward_t_vals)
|
| 278 |
+
shuffled_indices = np.arange(num_t_vals)
|
| 279 |
+
np.random.shuffle(shuffled_indices)
|
| 280 |
+
scramble_t_vals = forward_t_vals.copy()[shuffled_indices]
|
| 281 |
+
|
| 282 |
+
forward_results = geometric_slerp(start=start,
|
| 283 |
+
end=end,
|
| 284 |
+
t=forward_t_vals)
|
| 285 |
+
reverse_results = geometric_slerp(start=start,
|
| 286 |
+
end=end,
|
| 287 |
+
t=reverse_t_vals)
|
| 288 |
+
scrambled_results = geometric_slerp(start=start,
|
| 289 |
+
end=end,
|
| 290 |
+
t=scramble_t_vals)
|
| 291 |
+
|
| 292 |
+
# check fidelity to input order
|
| 293 |
+
assert_allclose(forward_results, np.flipud(reverse_results))
|
| 294 |
+
assert_allclose(forward_results[shuffled_indices],
|
| 295 |
+
scrambled_results)
|
| 296 |
+
|
| 297 |
+
@pytest.mark.parametrize("t", [
|
| 298 |
+
# string:
|
| 299 |
+
"15, 5, 7",
|
| 300 |
+
# complex numbers currently produce a warning
|
| 301 |
+
# but not sure we need to worry about it too much:
|
| 302 |
+
# [3 + 1j, 5 + 2j],
|
| 303 |
+
])
|
| 304 |
+
def test_t_values_conversion(self, t):
|
| 305 |
+
with pytest.raises(ValueError):
|
| 306 |
+
_ = geometric_slerp(start=np.array([1]),
|
| 307 |
+
end=np.array([0]),
|
| 308 |
+
t=t)
|
| 309 |
+
|
| 310 |
+
def test_accept_arraylike(self):
|
| 311 |
+
# array-like support requested by reviewer
|
| 312 |
+
# in gh-10380
|
| 313 |
+
actual = geometric_slerp([1, 0], [0, 1], [0, 1/3, 0.5, 2/3, 1])
|
| 314 |
+
|
| 315 |
+
# expected values are based on visual inspection
|
| 316 |
+
# of the unit circle for the progressions along
|
| 317 |
+
# the circumference provided in t
|
| 318 |
+
expected = np.array([[1, 0],
|
| 319 |
+
[np.sqrt(3) / 2, 0.5],
|
| 320 |
+
[np.sqrt(2) / 2,
|
| 321 |
+
np.sqrt(2) / 2],
|
| 322 |
+
[0.5, np.sqrt(3) / 2],
|
| 323 |
+
[0, 1]], dtype=np.float64)
|
| 324 |
+
# Tyler's original Cython implementation of geometric_slerp
|
| 325 |
+
# can pass at atol=0 here, but on balance we will accept
|
| 326 |
+
# 1e-16 for an implementation that avoids Cython and
|
| 327 |
+
# makes up accuracy ground elsewhere
|
| 328 |
+
assert_allclose(actual, expected, atol=1e-16)
|
| 329 |
+
|
| 330 |
+
def test_scalar_t(self):
|
| 331 |
+
# when t is a scalar, return value is a single
|
| 332 |
+
# interpolated point of the appropriate dimensionality
|
| 333 |
+
# requested by reviewer in gh-10380
|
| 334 |
+
actual = geometric_slerp([1, 0], [0, 1], 0.5)
|
| 335 |
+
expected = np.array([np.sqrt(2) / 2,
|
| 336 |
+
np.sqrt(2) / 2], dtype=np.float64)
|
| 337 |
+
assert actual.shape == (2,)
|
| 338 |
+
assert_allclose(actual, expected)
|
| 339 |
+
|
| 340 |
+
@pytest.mark.parametrize('start', [
|
| 341 |
+
np.array([1, 0, 0]),
|
| 342 |
+
np.array([0, 1]),
|
| 343 |
+
])
|
| 344 |
+
@pytest.mark.parametrize('t', [
|
| 345 |
+
np.array(1),
|
| 346 |
+
np.array([1]),
|
| 347 |
+
np.array([[1]]),
|
| 348 |
+
np.array([[[1]]]),
|
| 349 |
+
np.array([]),
|
| 350 |
+
np.linspace(0, 1, 5),
|
| 351 |
+
])
|
| 352 |
+
def test_degenerate_input(self, start, t):
|
| 353 |
+
if np.asarray(t).ndim > 1:
|
| 354 |
+
with pytest.raises(ValueError):
|
| 355 |
+
geometric_slerp(start=start, end=start, t=t)
|
| 356 |
+
else:
|
| 357 |
+
|
| 358 |
+
shape = (t.size,) + start.shape
|
| 359 |
+
expected = np.full(shape, start)
|
| 360 |
+
|
| 361 |
+
actual = geometric_slerp(start=start, end=start, t=t)
|
| 362 |
+
assert_allclose(actual, expected)
|
| 363 |
+
|
| 364 |
+
# Check that degenerate and non-degenerate
|
| 365 |
+
# inputs yield the same size
|
| 366 |
+
non_degenerate = geometric_slerp(start=start, end=start[::-1], t=t)
|
| 367 |
+
assert actual.size == non_degenerate.size
|
| 368 |
+
|
| 369 |
+
@pytest.mark.parametrize('k', np.logspace(-10, -1, 10))
|
| 370 |
+
def test_numerical_stability_pi(self, k):
|
| 371 |
+
# geometric_slerp should have excellent numerical
|
| 372 |
+
# stability for angles approaching pi between
|
| 373 |
+
# the start and end points
|
| 374 |
+
angle = np.pi - k
|
| 375 |
+
ts = np.linspace(0, 1, 100)
|
| 376 |
+
P = np.array([1, 0, 0, 0])
|
| 377 |
+
Q = np.array([np.cos(angle), np.sin(angle), 0, 0])
|
| 378 |
+
# the test should only be enforced for cases where
|
| 379 |
+
# geometric_slerp determines that the input is actually
|
| 380 |
+
# on the unit sphere
|
| 381 |
+
with warnings.catch_warnings():
|
| 382 |
+
warnings.simplefilter("ignore", UserWarning)
|
| 383 |
+
result = geometric_slerp(P, Q, ts, 1e-18)
|
| 384 |
+
norms = np.linalg.norm(result, axis=1)
|
| 385 |
+
error = np.max(np.abs(norms - 1))
|
| 386 |
+
assert error < 4e-15
|
| 387 |
+
|
| 388 |
+
@pytest.mark.parametrize('t', [
|
| 389 |
+
[[0, 0.5]],
|
| 390 |
+
[[[[[[[[[0, 0.5]]]]]]]]],
|
| 391 |
+
])
|
| 392 |
+
def test_interpolation_param_ndim(self, t):
|
| 393 |
+
# regression test for gh-14465
|
| 394 |
+
arr1 = np.array([0, 1])
|
| 395 |
+
arr2 = np.array([1, 0])
|
| 396 |
+
|
| 397 |
+
with pytest.raises(ValueError):
|
| 398 |
+
geometric_slerp(start=arr1,
|
| 399 |
+
end=arr2,
|
| 400 |
+
t=t)
|
| 401 |
+
|
| 402 |
+
with pytest.raises(ValueError):
|
| 403 |
+
geometric_slerp(start=arr1,
|
| 404 |
+
end=arr1,
|
| 405 |
+
t=t)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
@pytest.mark.parametrize("start, end, t, expected", [
|
| 409 |
+
# verify intuitive cases for t > 1 or < 0 (extrapolation)
|
| 410 |
+
|
| 411 |
+
# quarter way around the unit circle, doubling to
|
| 412 |
+
# half way around (allowed antipode since non-ambiguous
|
| 413 |
+
# geodesic):
|
| 414 |
+
([0, 1], [1, 0], 2, [0, -1]),
|
| 415 |
+
# 1/8 way around the unit circle, quadrupling to half way
|
| 416 |
+
# (another allowed non-ambiguous antipode)
|
| 417 |
+
([0, 1], [math.sqrt(2)/2, math.sqrt(2)/2], 4, [0, -1]),
|
| 418 |
+
# 1/8 way around the unit circle, 6x to 3/4 way around (270 deg)
|
| 419 |
+
([0, 1], [math.sqrt(2)/2, math.sqrt(2)/2], 6, [-1, 0]),
|
| 420 |
+
# 1/8 way around the unit circle, 7x to 315 deg
|
| 421 |
+
([0, 1], [math.sqrt(2)/2, math.sqrt(2)/2], 7,
|
| 422 |
+
[-math.sqrt(2)/2, math.sqrt(2)/2]),
|
| 423 |
+
# the above three extrapolations in reverse order should be returned
|
| 424 |
+
# in that same order:
|
| 425 |
+
([0, 1],
|
| 426 |
+
[math.sqrt(2)/2, math.sqrt(2)/2],
|
| 427 |
+
[7, 6, 4],
|
| 428 |
+
[[-math.sqrt(2)/2, math.sqrt(2)/2],
|
| 429 |
+
[-1, 0],
|
| 430 |
+
[0, -1]]),
|
| 431 |
+
# same case in 3d (sphere), in the xy plane:
|
| 432 |
+
([0, 1, 0],
|
| 433 |
+
[math.sqrt(2)/2, math.sqrt(2)/2, 0],
|
| 434 |
+
[7, 6, 4],
|
| 435 |
+
[[-math.sqrt(2)/2, math.sqrt(2)/2, 0],
|
| 436 |
+
[-1, 0, 0],
|
| 437 |
+
[0, -1, 0]]),
|
| 438 |
+
# 1/8 way around the unit circle, moving 300 deg backwards
|
| 439 |
+
# should end up at pi/6 (since there is no forward travel with
|
| 440 |
+
# negative extrapolation)
|
| 441 |
+
([0, 1], [math.sqrt(2)/2, math.sqrt(2)/2], (-300/45), [math.sqrt(3)/2, 0.5]),
|
| 442 |
+
])
|
| 443 |
+
def test_extrapolation_basic(self, start, end, t, expected):
|
| 444 |
+
actual_path = geometric_slerp(start=start,
|
| 445 |
+
end=end,
|
| 446 |
+
t=t)
|
| 447 |
+
assert_allclose(actual_path, expected, atol=2e-16)
|
| 448 |
+
|
| 449 |
+
@pytest.mark.parametrize("start, end, t, expected", [
|
| 450 |
+
# cases where start and end proper are antipodes
|
| 451 |
+
# and t > 1 or < 0; these cases should issue a warning due to
|
| 452 |
+
# geodesic ambiguity
|
| 453 |
+
|
| 454 |
+
# North to South on unit sphere, then back to North again;
|
| 455 |
+
# there are an infinite number of possible routes, but they all
|
| 456 |
+
# return back to North
|
| 457 |
+
([0, 0, 1], [0, 0, -1], -2, [0, 0, 1]),
|
| 458 |
+
# move "backwards" to South pole via an infinite number
|
| 459 |
+
# of possible routes
|
| 460 |
+
([0, 0, 1], [0, 0, -1], -1, [0, 0, -1]),
|
| 461 |
+
])
|
| 462 |
+
def test_extrapolation_antipodes(self, start, end, t, expected):
|
| 463 |
+
with pytest.warns(UserWarning, match='antipodes'):
|
| 464 |
+
actual_path = geometric_slerp(start=start, end=end, t=t)
|
| 465 |
+
assert_allclose(actual_path, expected, atol=2.8e-16)
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/tests/test_spherical_voronoi.py
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import itertools
|
| 3 |
+
from numpy.testing import (assert_equal,
|
| 4 |
+
assert_almost_equal,
|
| 5 |
+
assert_array_equal,
|
| 6 |
+
assert_array_almost_equal)
|
| 7 |
+
import pytest
|
| 8 |
+
from pytest import raises as assert_raises
|
| 9 |
+
from scipy.spatial import SphericalVoronoi, distance
|
| 10 |
+
from scipy.optimize import linear_sum_assignment
|
| 11 |
+
from scipy.constants import golden as phi
|
| 12 |
+
from scipy.special import gamma
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
TOL = 1E-10
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def _generate_tetrahedron():
|
| 19 |
+
return np.array([[1, 1, 1], [1, -1, -1], [-1, 1, -1], [-1, -1, 1]])
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def _generate_cube():
|
| 23 |
+
return np.array(list(itertools.product([-1, 1.], repeat=3)))
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _generate_octahedron():
|
| 27 |
+
return np.array([[-1, 0, 0], [+1, 0, 0], [0, -1, 0],
|
| 28 |
+
[0, +1, 0], [0, 0, -1], [0, 0, +1]])
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _generate_dodecahedron():
|
| 32 |
+
|
| 33 |
+
x1 = _generate_cube()
|
| 34 |
+
x2 = np.array([[0, -phi, -1 / phi],
|
| 35 |
+
[0, -phi, +1 / phi],
|
| 36 |
+
[0, +phi, -1 / phi],
|
| 37 |
+
[0, +phi, +1 / phi]])
|
| 38 |
+
x3 = np.array([[-1 / phi, 0, -phi],
|
| 39 |
+
[+1 / phi, 0, -phi],
|
| 40 |
+
[-1 / phi, 0, +phi],
|
| 41 |
+
[+1 / phi, 0, +phi]])
|
| 42 |
+
x4 = np.array([[-phi, -1 / phi, 0],
|
| 43 |
+
[-phi, +1 / phi, 0],
|
| 44 |
+
[+phi, -1 / phi, 0],
|
| 45 |
+
[+phi, +1 / phi, 0]])
|
| 46 |
+
return np.concatenate((x1, x2, x3, x4))
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _generate_icosahedron():
|
| 50 |
+
x = np.array([[0, -1, -phi],
|
| 51 |
+
[0, -1, +phi],
|
| 52 |
+
[0, +1, -phi],
|
| 53 |
+
[0, +1, +phi]])
|
| 54 |
+
return np.concatenate([np.roll(x, i, axis=1) for i in range(3)])
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _generate_polytope(name):
|
| 58 |
+
polygons = ["triangle", "square", "pentagon", "hexagon", "heptagon",
|
| 59 |
+
"octagon", "nonagon", "decagon", "undecagon", "dodecagon"]
|
| 60 |
+
polyhedra = ["tetrahedron", "cube", "octahedron", "dodecahedron",
|
| 61 |
+
"icosahedron"]
|
| 62 |
+
if name not in polygons and name not in polyhedra:
|
| 63 |
+
raise ValueError("unrecognized polytope")
|
| 64 |
+
|
| 65 |
+
if name in polygons:
|
| 66 |
+
n = polygons.index(name) + 3
|
| 67 |
+
thetas = np.linspace(0, 2 * np.pi, n, endpoint=False)
|
| 68 |
+
p = np.vstack([np.cos(thetas), np.sin(thetas)]).T
|
| 69 |
+
elif name == "tetrahedron":
|
| 70 |
+
p = _generate_tetrahedron()
|
| 71 |
+
elif name == "cube":
|
| 72 |
+
p = _generate_cube()
|
| 73 |
+
elif name == "octahedron":
|
| 74 |
+
p = _generate_octahedron()
|
| 75 |
+
elif name == "dodecahedron":
|
| 76 |
+
p = _generate_dodecahedron()
|
| 77 |
+
elif name == "icosahedron":
|
| 78 |
+
p = _generate_icosahedron()
|
| 79 |
+
|
| 80 |
+
return p / np.linalg.norm(p, axis=1, keepdims=True)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def _hypersphere_area(dim, radius):
|
| 84 |
+
# https://en.wikipedia.org/wiki/N-sphere#Closed_forms
|
| 85 |
+
return 2 * np.pi**(dim / 2) / gamma(dim / 2) * radius**(dim - 1)
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _sample_sphere(n, dim, seed=None):
|
| 89 |
+
# Sample points uniformly at random from the hypersphere
|
| 90 |
+
rng = np.random.RandomState(seed=seed)
|
| 91 |
+
points = rng.randn(n, dim)
|
| 92 |
+
points /= np.linalg.norm(points, axis=1, keepdims=True)
|
| 93 |
+
return points
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
class TestSphericalVoronoi:
|
| 97 |
+
|
| 98 |
+
def setup_method(self):
|
| 99 |
+
self.points = np.array([
|
| 100 |
+
[-0.78928481, -0.16341094, 0.59188373],
|
| 101 |
+
[-0.66839141, 0.73309634, 0.12578818],
|
| 102 |
+
[0.32535778, -0.92476944, -0.19734181],
|
| 103 |
+
[-0.90177102, -0.03785291, -0.43055335],
|
| 104 |
+
[0.71781344, 0.68428936, 0.12842096],
|
| 105 |
+
[-0.96064876, 0.23492353, -0.14820556],
|
| 106 |
+
[0.73181537, -0.22025898, -0.6449281],
|
| 107 |
+
[0.79979205, 0.54555747, 0.25039913]]
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
def test_constructor(self):
|
| 111 |
+
center = np.array([1, 2, 3])
|
| 112 |
+
radius = 2
|
| 113 |
+
s1 = SphericalVoronoi(self.points)
|
| 114 |
+
# user input checks in SphericalVoronoi now require
|
| 115 |
+
# the radius / center to match the generators so adjust
|
| 116 |
+
# accordingly here
|
| 117 |
+
s2 = SphericalVoronoi(self.points * radius, radius)
|
| 118 |
+
s3 = SphericalVoronoi(self.points + center, center=center)
|
| 119 |
+
s4 = SphericalVoronoi(self.points * radius + center, radius, center)
|
| 120 |
+
assert_array_equal(s1.center, np.array([0, 0, 0]))
|
| 121 |
+
assert_equal(s1.radius, 1)
|
| 122 |
+
assert_array_equal(s2.center, np.array([0, 0, 0]))
|
| 123 |
+
assert_equal(s2.radius, 2)
|
| 124 |
+
assert_array_equal(s3.center, center)
|
| 125 |
+
assert_equal(s3.radius, 1)
|
| 126 |
+
assert_array_equal(s4.center, center)
|
| 127 |
+
assert_equal(s4.radius, radius)
|
| 128 |
+
|
| 129 |
+
# Test a non-sequence/-ndarray based array-like
|
| 130 |
+
s5 = SphericalVoronoi(memoryview(self.points)) # type: ignore[arg-type]
|
| 131 |
+
assert_array_equal(s5.center, np.array([0, 0, 0]))
|
| 132 |
+
assert_equal(s5.radius, 1)
|
| 133 |
+
|
| 134 |
+
def test_vertices_regions_translation_invariance(self):
|
| 135 |
+
sv_origin = SphericalVoronoi(self.points)
|
| 136 |
+
center = np.array([1, 1, 1])
|
| 137 |
+
sv_translated = SphericalVoronoi(self.points + center, center=center)
|
| 138 |
+
assert_equal(sv_origin.regions, sv_translated.regions)
|
| 139 |
+
assert_array_almost_equal(sv_origin.vertices + center,
|
| 140 |
+
sv_translated.vertices)
|
| 141 |
+
|
| 142 |
+
def test_vertices_regions_scaling_invariance(self):
|
| 143 |
+
sv_unit = SphericalVoronoi(self.points)
|
| 144 |
+
sv_scaled = SphericalVoronoi(self.points * 2, 2)
|
| 145 |
+
assert_equal(sv_unit.regions, sv_scaled.regions)
|
| 146 |
+
assert_array_almost_equal(sv_unit.vertices * 2,
|
| 147 |
+
sv_scaled.vertices)
|
| 148 |
+
|
| 149 |
+
def test_old_radius_api_error(self):
|
| 150 |
+
with pytest.raises(ValueError, match='`radius` is `None`. *'):
|
| 151 |
+
SphericalVoronoi(self.points, radius=None)
|
| 152 |
+
|
| 153 |
+
def test_sort_vertices_of_regions(self):
|
| 154 |
+
sv = SphericalVoronoi(self.points)
|
| 155 |
+
unsorted_regions = sv.regions
|
| 156 |
+
sv.sort_vertices_of_regions()
|
| 157 |
+
assert_equal(sorted(sv.regions), sorted(unsorted_regions))
|
| 158 |
+
|
| 159 |
+
def test_sort_vertices_of_regions_flattened(self):
|
| 160 |
+
expected = sorted([[0, 6, 5, 2, 3], [2, 3, 10, 11, 8, 7], [0, 6, 4, 1],
|
| 161 |
+
[4, 8, 7, 5, 6], [9, 11, 10], [2, 7, 5],
|
| 162 |
+
[1, 4, 8, 11, 9], [0, 3, 10, 9, 1]])
|
| 163 |
+
expected = list(itertools.chain(*sorted(expected))) # type: ignore
|
| 164 |
+
sv = SphericalVoronoi(self.points)
|
| 165 |
+
sv.sort_vertices_of_regions()
|
| 166 |
+
actual = list(itertools.chain(*sorted(sv.regions)))
|
| 167 |
+
assert_array_equal(actual, expected)
|
| 168 |
+
|
| 169 |
+
def test_sort_vertices_of_regions_dimensionality(self):
|
| 170 |
+
points = np.array([[1, 0, 0, 0],
|
| 171 |
+
[0, 1, 0, 0],
|
| 172 |
+
[0, 0, 1, 0],
|
| 173 |
+
[0, 0, 0, 1],
|
| 174 |
+
[0.5, 0.5, 0.5, 0.5]])
|
| 175 |
+
with pytest.raises(TypeError, match="three-dimensional"):
|
| 176 |
+
sv = SphericalVoronoi(points)
|
| 177 |
+
sv.sort_vertices_of_regions()
|
| 178 |
+
|
| 179 |
+
def test_num_vertices(self):
|
| 180 |
+
# for any n >= 3, a spherical Voronoi diagram has 2n - 4
|
| 181 |
+
# vertices; this is a direct consequence of Euler's formula
|
| 182 |
+
# as explained by Dinis and Mamede (2010) Proceedings of the
|
| 183 |
+
# 2010 International Symposium on Voronoi Diagrams in Science
|
| 184 |
+
# and Engineering
|
| 185 |
+
sv = SphericalVoronoi(self.points)
|
| 186 |
+
expected = self.points.shape[0] * 2 - 4
|
| 187 |
+
actual = sv.vertices.shape[0]
|
| 188 |
+
assert_equal(actual, expected)
|
| 189 |
+
|
| 190 |
+
def test_voronoi_circles(self):
|
| 191 |
+
sv = SphericalVoronoi(self.points)
|
| 192 |
+
for vertex in sv.vertices:
|
| 193 |
+
distances = distance.cdist(sv.points, np.array([vertex]))
|
| 194 |
+
closest = np.array(sorted(distances)[0:3])
|
| 195 |
+
assert_almost_equal(closest[0], closest[1], 7, str(vertex))
|
| 196 |
+
assert_almost_equal(closest[0], closest[2], 7, str(vertex))
|
| 197 |
+
|
| 198 |
+
def test_duplicate_point_handling(self):
|
| 199 |
+
# an exception should be raised for degenerate generators
|
| 200 |
+
# related to Issue# 7046
|
| 201 |
+
self.degenerate = np.concatenate((self.points, self.points))
|
| 202 |
+
with assert_raises(ValueError):
|
| 203 |
+
SphericalVoronoi(self.degenerate)
|
| 204 |
+
|
| 205 |
+
def test_incorrect_radius_handling(self):
|
| 206 |
+
# an exception should be raised if the radius provided
|
| 207 |
+
# cannot possibly match the input generators
|
| 208 |
+
with assert_raises(ValueError):
|
| 209 |
+
SphericalVoronoi(self.points, radius=0.98)
|
| 210 |
+
|
| 211 |
+
def test_incorrect_center_handling(self):
|
| 212 |
+
# an exception should be raised if the center provided
|
| 213 |
+
# cannot possibly match the input generators
|
| 214 |
+
with assert_raises(ValueError):
|
| 215 |
+
SphericalVoronoi(self.points, center=[0.1, 0, 0])
|
| 216 |
+
|
| 217 |
+
@pytest.mark.parametrize("dim", range(2, 6))
|
| 218 |
+
@pytest.mark.parametrize("shift", [False, True])
|
| 219 |
+
def test_single_hemisphere_handling(self, dim, shift):
|
| 220 |
+
n = 10
|
| 221 |
+
points = _sample_sphere(n, dim, seed=0)
|
| 222 |
+
points[:, 0] = np.abs(points[:, 0])
|
| 223 |
+
center = (np.arange(dim) + 1) * shift
|
| 224 |
+
sv = SphericalVoronoi(points + center, center=center)
|
| 225 |
+
dots = np.einsum('ij,ij->i', sv.vertices - center,
|
| 226 |
+
sv.points[sv._simplices[:, 0]] - center)
|
| 227 |
+
circumradii = np.arccos(np.clip(dots, -1, 1))
|
| 228 |
+
assert np.max(circumradii) > np.pi / 2
|
| 229 |
+
|
| 230 |
+
@pytest.mark.parametrize("n", [1, 2, 10])
|
| 231 |
+
@pytest.mark.parametrize("dim", range(2, 6))
|
| 232 |
+
@pytest.mark.parametrize("shift", [False, True])
|
| 233 |
+
def test_rank_deficient(self, n, dim, shift):
|
| 234 |
+
center = (np.arange(dim) + 1) * shift
|
| 235 |
+
points = _sample_sphere(n, dim - 1, seed=0)
|
| 236 |
+
points = np.hstack([points, np.zeros((n, 1))])
|
| 237 |
+
with pytest.raises(ValueError, match="Rank of input points"):
|
| 238 |
+
SphericalVoronoi(points + center, center=center)
|
| 239 |
+
|
| 240 |
+
@pytest.mark.parametrize("dim", range(2, 6))
|
| 241 |
+
def test_higher_dimensions(self, dim):
|
| 242 |
+
n = 100
|
| 243 |
+
points = _sample_sphere(n, dim, seed=0)
|
| 244 |
+
sv = SphericalVoronoi(points)
|
| 245 |
+
assert sv.vertices.shape[1] == dim
|
| 246 |
+
assert len(sv.regions) == n
|
| 247 |
+
|
| 248 |
+
# verify Euler characteristic
|
| 249 |
+
cell_counts = []
|
| 250 |
+
simplices = np.sort(sv._simplices)
|
| 251 |
+
for i in range(1, dim + 1):
|
| 252 |
+
cells = []
|
| 253 |
+
for indices in itertools.combinations(range(dim), i):
|
| 254 |
+
cells.append(simplices[:, list(indices)])
|
| 255 |
+
cells = np.unique(np.concatenate(cells), axis=0)
|
| 256 |
+
cell_counts.append(len(cells))
|
| 257 |
+
expected_euler = 1 + (-1)**(dim-1)
|
| 258 |
+
actual_euler = sum([(-1)**i * e for i, e in enumerate(cell_counts)])
|
| 259 |
+
assert expected_euler == actual_euler
|
| 260 |
+
|
| 261 |
+
@pytest.mark.parametrize("dim", range(2, 6))
|
| 262 |
+
def test_cross_polytope_regions(self, dim):
|
| 263 |
+
# The hypercube is the dual of the cross-polytope, so the voronoi
|
| 264 |
+
# vertices of the cross-polytope lie on the points of the hypercube.
|
| 265 |
+
|
| 266 |
+
# generate points of the cross-polytope
|
| 267 |
+
points = np.concatenate((-np.eye(dim), np.eye(dim)))
|
| 268 |
+
sv = SphericalVoronoi(points)
|
| 269 |
+
assert all([len(e) == 2**(dim - 1) for e in sv.regions])
|
| 270 |
+
|
| 271 |
+
# generate points of the hypercube
|
| 272 |
+
expected = np.vstack(list(itertools.product([-1, 1], repeat=dim)))
|
| 273 |
+
expected = expected.astype(np.float64) / np.sqrt(dim)
|
| 274 |
+
|
| 275 |
+
# test that Voronoi vertices are correctly placed
|
| 276 |
+
dist = distance.cdist(sv.vertices, expected)
|
| 277 |
+
res = linear_sum_assignment(dist)
|
| 278 |
+
assert dist[res].sum() < TOL
|
| 279 |
+
|
| 280 |
+
@pytest.mark.parametrize("dim", range(2, 6))
|
| 281 |
+
def test_hypercube_regions(self, dim):
|
| 282 |
+
# The cross-polytope is the dual of the hypercube, so the voronoi
|
| 283 |
+
# vertices of the hypercube lie on the points of the cross-polytope.
|
| 284 |
+
|
| 285 |
+
# generate points of the hypercube
|
| 286 |
+
points = np.vstack(list(itertools.product([-1, 1], repeat=dim)))
|
| 287 |
+
points = points.astype(np.float64) / np.sqrt(dim)
|
| 288 |
+
sv = SphericalVoronoi(points)
|
| 289 |
+
|
| 290 |
+
# generate points of the cross-polytope
|
| 291 |
+
expected = np.concatenate((-np.eye(dim), np.eye(dim)))
|
| 292 |
+
|
| 293 |
+
# test that Voronoi vertices are correctly placed
|
| 294 |
+
dist = distance.cdist(sv.vertices, expected)
|
| 295 |
+
res = linear_sum_assignment(dist)
|
| 296 |
+
assert dist[res].sum() < TOL
|
| 297 |
+
|
| 298 |
+
@pytest.mark.parametrize("n", [10, 500])
|
| 299 |
+
@pytest.mark.parametrize("dim", [2, 3])
|
| 300 |
+
@pytest.mark.parametrize("radius", [0.5, 1, 2])
|
| 301 |
+
@pytest.mark.parametrize("shift", [False, True])
|
| 302 |
+
@pytest.mark.parametrize("single_hemisphere", [False, True])
|
| 303 |
+
def test_area_reconstitution(self, n, dim, radius, shift,
|
| 304 |
+
single_hemisphere):
|
| 305 |
+
points = _sample_sphere(n, dim, seed=0)
|
| 306 |
+
|
| 307 |
+
# move all points to one side of the sphere for single-hemisphere test
|
| 308 |
+
if single_hemisphere:
|
| 309 |
+
points[:, 0] = np.abs(points[:, 0])
|
| 310 |
+
|
| 311 |
+
center = (np.arange(dim) + 1) * shift
|
| 312 |
+
points = radius * points + center
|
| 313 |
+
|
| 314 |
+
sv = SphericalVoronoi(points, radius=radius, center=center)
|
| 315 |
+
areas = sv.calculate_areas()
|
| 316 |
+
assert_almost_equal(areas.sum(), _hypersphere_area(dim, radius))
|
| 317 |
+
|
| 318 |
+
@pytest.mark.parametrize("poly", ["triangle", "dodecagon",
|
| 319 |
+
"tetrahedron", "cube", "octahedron",
|
| 320 |
+
"dodecahedron", "icosahedron"])
|
| 321 |
+
def test_equal_area_reconstitution(self, poly):
|
| 322 |
+
points = _generate_polytope(poly)
|
| 323 |
+
n, dim = points.shape
|
| 324 |
+
sv = SphericalVoronoi(points)
|
| 325 |
+
areas = sv.calculate_areas()
|
| 326 |
+
assert_almost_equal(areas, _hypersphere_area(dim, 1) / n)
|
| 327 |
+
|
| 328 |
+
def test_area_unsupported_dimension(self):
|
| 329 |
+
dim = 4
|
| 330 |
+
points = np.concatenate((-np.eye(dim), np.eye(dim)))
|
| 331 |
+
sv = SphericalVoronoi(points)
|
| 332 |
+
with pytest.raises(TypeError, match="Only supported"):
|
| 333 |
+
sv.calculate_areas()
|
| 334 |
+
|
| 335 |
+
@pytest.mark.parametrize("radius", [1, 1.])
|
| 336 |
+
@pytest.mark.parametrize("center", [None, (1, 2, 3), (1., 2., 3.)])
|
| 337 |
+
def test_attribute_types(self, radius, center):
|
| 338 |
+
points = radius * self.points
|
| 339 |
+
if center is not None:
|
| 340 |
+
points += center
|
| 341 |
+
|
| 342 |
+
sv = SphericalVoronoi(points, radius=radius, center=center)
|
| 343 |
+
assert sv.points.dtype is np.dtype(np.float64)
|
| 344 |
+
assert sv.center.dtype is np.dtype(np.float64)
|
| 345 |
+
assert isinstance(sv.radius, float)
|
| 346 |
+
|
| 347 |
+
def test_region_types(self):
|
| 348 |
+
# Tests that region integer type does not change
|
| 349 |
+
# See Issue #13412
|
| 350 |
+
sv = SphericalVoronoi(self.points)
|
| 351 |
+
dtype = type(sv.regions[0][0])
|
| 352 |
+
# also enforce nested list type per gh-19177
|
| 353 |
+
for region in sv.regions:
|
| 354 |
+
assert isinstance(region, list)
|
| 355 |
+
sv.sort_vertices_of_regions()
|
| 356 |
+
assert isinstance(sv.regions[0][0], dtype)
|
| 357 |
+
sv.sort_vertices_of_regions()
|
| 358 |
+
assert isinstance(sv.regions[0][0], dtype)
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__init__.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Spatial Transformations (:mod:`scipy.spatial.transform`)
|
| 3 |
+
========================================================
|
| 4 |
+
|
| 5 |
+
.. currentmodule:: scipy.spatial.transform
|
| 6 |
+
|
| 7 |
+
This package implements various spatial transformations. For now, rotations
|
| 8 |
+
and rigid transforms (rotations and translations) are supported.
|
| 9 |
+
|
| 10 |
+
Rotations in 3 dimensions
|
| 11 |
+
-------------------------
|
| 12 |
+
.. autosummary::
|
| 13 |
+
:toctree: generated/
|
| 14 |
+
|
| 15 |
+
RigidTransform
|
| 16 |
+
Rotation
|
| 17 |
+
Slerp
|
| 18 |
+
RotationSpline
|
| 19 |
+
"""
|
| 20 |
+
from ._rotation import Rotation, Slerp
|
| 21 |
+
from ._rigid_transform import RigidTransform
|
| 22 |
+
from ._rotation_spline import RotationSpline
|
| 23 |
+
|
| 24 |
+
# Deprecated namespaces, to be removed in v2.0.0
|
| 25 |
+
from . import rotation
|
| 26 |
+
|
| 27 |
+
__all__ = ['Rotation', 'Slerp', 'RotationSpline', 'RigidTransform']
|
| 28 |
+
|
| 29 |
+
from scipy._lib._testutils import PytestTester
|
| 30 |
+
test = PytestTester(__name__)
|
| 31 |
+
del PytestTester
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (1.04 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rigid_transform.cpython-312.pyc
ADDED
|
Binary file (76.6 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rigid_transform_xp.cpython-312.pyc
ADDED
|
Binary file (22.7 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation.cpython-312.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f843476bb37cb1042f870063088da4a51e599772661d7992ad4d5be425ab1d58
|
| 3 |
+
size 112922
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_groups.cpython-312.pyc
ADDED
|
Binary file (7.04 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_spline.cpython-312.pyc
ADDED
|
Binary file (19.1 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/_rotation_xp.cpython-312.pyc
ADDED
|
Binary file (50.4 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/__pycache__/rotation.cpython-312.py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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
from collections.abc import Iterable, Iterator
|
| 4 |
+
from types import EllipsisType, ModuleType, NotImplementedType
|
| 5 |
+
from collections.abc import Callable
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
from scipy._lib._array_api import (
|
| 10 |
+
array_namespace,
|
| 11 |
+
is_numpy,
|
| 12 |
+
ArrayLike,
|
| 13 |
+
Array,
|
| 14 |
+
xp_capabilities,
|
| 15 |
+
)
|
| 16 |
+
from scipy.spatial.transform import Rotation
|
| 17 |
+
from scipy.spatial.transform._rotation import _promote
|
| 18 |
+
import scipy.spatial.transform._rigid_transform_cy as cython_backend
|
| 19 |
+
import scipy.spatial.transform._rigid_transform_xp as xp_backend
|
| 20 |
+
import scipy._lib.array_api_extra as xpx
|
| 21 |
+
from scipy._lib.array_api_compat import device
|
| 22 |
+
from scipy._lib._array_api import xp_promote
|
| 23 |
+
from scipy._lib._util import broadcastable
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
__all__ = ["RigidTransform"]
|
| 27 |
+
|
| 28 |
+
backend_registry = {array_namespace(np.empty(0)): cython_backend}
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def select_backend(xp: ModuleType, cython_compatible: bool):
|
| 32 |
+
"""Select the backend for the given array library.
|
| 33 |
+
|
| 34 |
+
We need this selection function because the Cython backend for numpy does not
|
| 35 |
+
support quaternions of arbitrary dimensions. We therefore only use the Array API
|
| 36 |
+
backend for numpy if we are dealing with rotations of more than one leading
|
| 37 |
+
dimension.
|
| 38 |
+
"""
|
| 39 |
+
if is_numpy(xp) and not cython_compatible:
|
| 40 |
+
return xp_backend
|
| 41 |
+
return backend_registry.get(xp, xp_backend)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@xp_capabilities()
|
| 45 |
+
def normalize_dual_quaternion(dual_quat: ArrayLike) -> Array:
|
| 46 |
+
"""Normalize dual quaternion."""
|
| 47 |
+
xp = array_namespace(dual_quat)
|
| 48 |
+
dual_quat = _promote(dual_quat, xp=xp)
|
| 49 |
+
single = dual_quat.ndim == 1 and is_numpy(xp)
|
| 50 |
+
if single:
|
| 51 |
+
dual_quat = xpx.atleast_nd(dual_quat, ndim=2, xp=xp)
|
| 52 |
+
cython_compatible = dual_quat.ndim < 3
|
| 53 |
+
dq = select_backend(xp, cython_compatible).normalize_dual_quaternion(dual_quat)
|
| 54 |
+
if single:
|
| 55 |
+
return dq[0]
|
| 56 |
+
return dq
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
class RigidTransform:
|
| 60 |
+
"""Rigid transform in 3 dimensions.
|
| 61 |
+
|
| 62 |
+
This class provides an interface to initialize from and represent rigid
|
| 63 |
+
transforms (rotation and translation) in 3D space. In different fields,
|
| 64 |
+
this type of transform may be referred to as "*pose*" (especially in
|
| 65 |
+
robotics), "*extrinsic parameters*", or the "*model matrix*" (especially in
|
| 66 |
+
computer graphics), but the core concept is the same: a rotation and
|
| 67 |
+
translation describing the orientation of one 3D coordinate frame relative
|
| 68 |
+
to another. Mathematically, these transforms belong to the Special
|
| 69 |
+
Euclidean group SE(3), which encodes rotation (SO(3)) plus translation.
|
| 70 |
+
|
| 71 |
+
The following operations on rigid transforms are supported:
|
| 72 |
+
|
| 73 |
+
- Application on vectors
|
| 74 |
+
- Transformation composition
|
| 75 |
+
- Transformation inversion
|
| 76 |
+
- Transformation indexing
|
| 77 |
+
|
| 78 |
+
Note that coordinate systems must be right-handed. Because of this, this
|
| 79 |
+
class more precisely represents *proper* rigid transformations in SE(3)
|
| 80 |
+
rather than rigid transforms in E(3) more generally [1]_.
|
| 81 |
+
|
| 82 |
+
Indexing within a transform is supported since multiple transforms can be
|
| 83 |
+
stored within a single `RigidTransform` instance.
|
| 84 |
+
|
| 85 |
+
Multiple transforms can be stored in a single `RigidTransform` object, which can be
|
| 86 |
+
initialized using N-dimensional arrays and supports broadcasting for all
|
| 87 |
+
operations.
|
| 88 |
+
|
| 89 |
+
To create `RigidTransform` objects use ``from_...`` methods (see examples
|
| 90 |
+
below). ``RigidTransform(...)`` is not supposed to be instantiated directly.
|
| 91 |
+
|
| 92 |
+
For rigorous introductions to rigid transforms, see [2]_, [3]_, and [4]_.
|
| 93 |
+
|
| 94 |
+
Attributes
|
| 95 |
+
----------
|
| 96 |
+
single
|
| 97 |
+
rotation
|
| 98 |
+
translation
|
| 99 |
+
|
| 100 |
+
Methods
|
| 101 |
+
-------
|
| 102 |
+
__len__
|
| 103 |
+
__getitem__
|
| 104 |
+
__mul__
|
| 105 |
+
__pow__
|
| 106 |
+
from_matrix
|
| 107 |
+
from_rotation
|
| 108 |
+
from_translation
|
| 109 |
+
from_components
|
| 110 |
+
from_exp_coords
|
| 111 |
+
from_dual_quat
|
| 112 |
+
as_matrix
|
| 113 |
+
as_components
|
| 114 |
+
as_exp_coords
|
| 115 |
+
as_dual_quat
|
| 116 |
+
concatenate
|
| 117 |
+
mean
|
| 118 |
+
apply
|
| 119 |
+
inv
|
| 120 |
+
identity
|
| 121 |
+
|
| 122 |
+
References
|
| 123 |
+
----------
|
| 124 |
+
.. [1] https://en.wikipedia.org/wiki/Rigid_transformation
|
| 125 |
+
.. [2] https://motion.cs.illinois.edu/RoboticSystems/CoordinateTransformations.html
|
| 126 |
+
.. [3] https://www.brainvoyager.com/bv/doc/UsersGuide/CoordsAndTransforms/SpatialTransformationMatrices.html
|
| 127 |
+
.. [4] Kevin M. Lynch and Frank C. Park, "Modern Robotics: Mechanics,
|
| 128 |
+
Planning, and Control" Chapter 3.3, 2017, Cambridge University Press.
|
| 129 |
+
https://hades.mech.northwestern.edu/images/2/25/MR-v2.pdf#page=107.31
|
| 130 |
+
.. [5] Paul Furgale, "Representing Robot Pose: The good, the bad, and the
|
| 131 |
+
ugly", June 9, 2014.
|
| 132 |
+
https://rpg.ifi.uzh.ch/docs/teaching/2024/FurgaleTutorial.pdf
|
| 133 |
+
|
| 134 |
+
Notes
|
| 135 |
+
-----
|
| 136 |
+
.. versionadded:: 1.16.0
|
| 137 |
+
|
| 138 |
+
Examples
|
| 139 |
+
--------
|
| 140 |
+
A `RigidTransform` instance can be initialized in any of the above formats
|
| 141 |
+
and converted to any of the others. The underlying object is independent of
|
| 142 |
+
the representation used for initialization.
|
| 143 |
+
|
| 144 |
+
**Notation Conventions and Composition**
|
| 145 |
+
|
| 146 |
+
The notation here largely follows the convention defined in [5]_. When we
|
| 147 |
+
name transforms, we read the subscripts from right to left. So ``tf_A_B``
|
| 148 |
+
represents a transform A <- B and can be interpreted as:
|
| 149 |
+
|
| 150 |
+
- the coordinates and orientation of B relative to A
|
| 151 |
+
- the transformation of points from B to A
|
| 152 |
+
- the pose of B described in A's coordinate system
|
| 153 |
+
|
| 154 |
+
.. parsed-literal::
|
| 155 |
+
:class: highlight-none
|
| 156 |
+
|
| 157 |
+
tf_A_B
|
| 158 |
+
^ ^
|
| 159 |
+
| |
|
| 160 |
+
| --- from B
|
| 161 |
+
|
|
| 162 |
+
----- to A
|
| 163 |
+
|
| 164 |
+
When composing transforms, the order is important. Transforms are not
|
| 165 |
+
commutative, so in general ``tf_A_B * tf_B_C`` is not the same as
|
| 166 |
+
``tf_B_C * tf_A_B``. Transforms are composed and applied to vectors
|
| 167 |
+
right-to-left. So ``(tf_A_B * tf_B_C).apply(p_C)`` is the same as
|
| 168 |
+
``tf_A_B.apply(tf_B_C.apply(p_C))``.
|
| 169 |
+
|
| 170 |
+
When composed, transforms should be ordered such that the multiplication
|
| 171 |
+
operator is surrounded by a single frame, so the frame "cancels out" and
|
| 172 |
+
the outside frames are left. In the example below, B cancels out and the
|
| 173 |
+
outside frames A and C are left. Or to put it another way, A <- C is the
|
| 174 |
+
same as A <- B <- C.
|
| 175 |
+
|
| 176 |
+
.. parsed-literal::
|
| 177 |
+
:class: highlight-none
|
| 178 |
+
|
| 179 |
+
----------- B cancels out
|
| 180 |
+
| |
|
| 181 |
+
v v
|
| 182 |
+
tf_A_C = tf_A_B * tf_B_C
|
| 183 |
+
^ ^
|
| 184 |
+
| |
|
| 185 |
+
------------ to A, from C are left
|
| 186 |
+
|
| 187 |
+
When we notate vectors, we write the subscript of the frame that the vector
|
| 188 |
+
is defined in. So ``p_B`` means the point ``p`` defined in frame B. To
|
| 189 |
+
transform this point from frame B to coordinates in frame A, we apply the
|
| 190 |
+
transform ``tf_A_B`` to the vector, lining things up such that the notated
|
| 191 |
+
B frames are next to each other and "cancel out".
|
| 192 |
+
|
| 193 |
+
.. parsed-literal::
|
| 194 |
+
:class: highlight-none
|
| 195 |
+
|
| 196 |
+
------------ B cancels out
|
| 197 |
+
| |
|
| 198 |
+
v v
|
| 199 |
+
p_A = tf_A_B.apply(p_B)
|
| 200 |
+
^
|
| 201 |
+
|
|
| 202 |
+
-------------- A is left
|
| 203 |
+
|
| 204 |
+
**Visualization**
|
| 205 |
+
|
| 206 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 207 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 208 |
+
>>> import numpy as np
|
| 209 |
+
|
| 210 |
+
The following function can be used to plot transforms with Matplotlib
|
| 211 |
+
by showing how they transform the standard x, y, z coordinate axes:
|
| 212 |
+
|
| 213 |
+
>>> import matplotlib.pyplot as plt
|
| 214 |
+
>>> colors = ("#FF6666", "#005533", "#1199EE") # Colorblind-safe RGB
|
| 215 |
+
>>> def plot_transformed_axes(ax, tf, name=None, scale=1):
|
| 216 |
+
... r = tf.rotation
|
| 217 |
+
... t = tf.translation
|
| 218 |
+
... loc = np.array([t, t])
|
| 219 |
+
... for i, (axis, c) in enumerate(zip((ax.xaxis, ax.yaxis, ax.zaxis),
|
| 220 |
+
... colors)):
|
| 221 |
+
... axlabel = axis.axis_name
|
| 222 |
+
... axis.set_label_text(axlabel)
|
| 223 |
+
... axis.label.set_color(c)
|
| 224 |
+
... axis.line.set_color(c)
|
| 225 |
+
... axis.set_tick_params(colors=c)
|
| 226 |
+
... line = np.zeros((2, 3))
|
| 227 |
+
... line[1, i] = scale
|
| 228 |
+
... line_rot = r.apply(line)
|
| 229 |
+
... line_plot = line_rot + loc
|
| 230 |
+
... ax.plot(line_plot[:, 0], line_plot[:, 1], line_plot[:, 2], c)
|
| 231 |
+
... text_loc = line[1]*1.2
|
| 232 |
+
... text_loc_rot = r.apply(text_loc)
|
| 233 |
+
... text_plot = text_loc_rot + t
|
| 234 |
+
... ax.text(*text_plot, axlabel.upper(), color=c,
|
| 235 |
+
... va="center", ha="center")
|
| 236 |
+
... ax.text(*tf.translation, name, color="k", va="center", ha="center",
|
| 237 |
+
... bbox={"fc": "w", "alpha": 0.8, "boxstyle": "circle"})
|
| 238 |
+
|
| 239 |
+
**Defining Frames**
|
| 240 |
+
|
| 241 |
+
Let's work through an example.
|
| 242 |
+
|
| 243 |
+
First, define the "world frame" A, also called the "base frame".
|
| 244 |
+
All frames are the identity transform from their own perspective.
|
| 245 |
+
|
| 246 |
+
>>> tf_A = Tf.identity()
|
| 247 |
+
|
| 248 |
+
We will visualize a new frame B in A's coordinate system. So we need to
|
| 249 |
+
define the transform that converts coordinates from frame B to frame A
|
| 250 |
+
(A <- B).
|
| 251 |
+
|
| 252 |
+
Physically, let's imagine constructing B from A by:
|
| 253 |
+
|
| 254 |
+
1) Rotating A by +90 degrees around its x-axis.
|
| 255 |
+
2) Translating the rotated frame 2 units in A's -x direction.
|
| 256 |
+
|
| 257 |
+
From A's perspective, B is at [-2, 0, 0] and rotated +90 degrees about the
|
| 258 |
+
x-axis, which is exactly the transform A <- B.
|
| 259 |
+
|
| 260 |
+
>>> t_A_B = np.array([-2, 0, 0])
|
| 261 |
+
>>> r_A_B = R.from_euler('xyz', [90, 0, 0], degrees=True)
|
| 262 |
+
>>> tf_A_B = Tf.from_components(t_A_B, r_A_B)
|
| 263 |
+
|
| 264 |
+
Let's plot these frames.
|
| 265 |
+
|
| 266 |
+
>>> fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
|
| 267 |
+
>>> plot_transformed_axes(ax, tf_A, name="tfA") # A plotted in A
|
| 268 |
+
>>> plot_transformed_axes(ax, tf_A_B, name="tfAB") # B plotted in A
|
| 269 |
+
>>> ax.set_title("A, B frames with respect to A")
|
| 270 |
+
>>> ax.set_aspect("equal")
|
| 271 |
+
>>> ax.figure.set_size_inches(6, 5)
|
| 272 |
+
>>> plt.show()
|
| 273 |
+
|
| 274 |
+
Now let's visualize a new frame C in B's coordinate system.
|
| 275 |
+
Let's imagine constructing C from B by:
|
| 276 |
+
|
| 277 |
+
1) Translating B by 2 units in its +z direction.
|
| 278 |
+
2) Rotating B by +30 degrees around its z-axis.
|
| 279 |
+
|
| 280 |
+
>>> t_B_C = np.array([0, 0, 2])
|
| 281 |
+
>>> r_B_C = R.from_euler('xyz', [0, 0, 30], degrees=True)
|
| 282 |
+
>>> tf_B_C = Tf.from_components(t_B_C, r_B_C)
|
| 283 |
+
|
| 284 |
+
In order to plot these frames from a consistent perspective, we need to
|
| 285 |
+
calculate the transform between A and C. Note that we do not make this
|
| 286 |
+
transform directly, but instead compose intermediate transforms that let us
|
| 287 |
+
get from C to A:
|
| 288 |
+
|
| 289 |
+
>>> tf_A_C = tf_A_B * tf_B_C # A <- B <- C
|
| 290 |
+
|
| 291 |
+
Now we can plot these three frames from A's perspective.
|
| 292 |
+
|
| 293 |
+
>>> fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
|
| 294 |
+
>>> plot_transformed_axes(ax, tf_A, name="tfA") # A plotted in A
|
| 295 |
+
>>> plot_transformed_axes(ax, tf_A_B, name="tfAB") # B plotted in A
|
| 296 |
+
>>> plot_transformed_axes(ax, tf_A_C, name="tfAC") # C plotted in A
|
| 297 |
+
>>> ax.set_title("A, B, C frames with respect to A")
|
| 298 |
+
>>> ax.set_aspect("equal")
|
| 299 |
+
>>> ax.figure.set_size_inches(6, 5)
|
| 300 |
+
>>> plt.show()
|
| 301 |
+
|
| 302 |
+
**Transforming Vectors**
|
| 303 |
+
|
| 304 |
+
Let's transform a vector from A, to B and C. To do this, we will first
|
| 305 |
+
invert the transforms we already have from B and C, to A.
|
| 306 |
+
|
| 307 |
+
>>> tf_B_A = tf_A_B.inv() # B <- A
|
| 308 |
+
>>> tf_C_A = tf_A_C.inv() # C <- A
|
| 309 |
+
|
| 310 |
+
Now we can define a point in A and use the above transforms to get its
|
| 311 |
+
coordinates in B and C:
|
| 312 |
+
|
| 313 |
+
>>> p1_A = np.array([1, 0, 0]) # +1 in x_A direction
|
| 314 |
+
>>> p1_B = tf_B_A.apply(p1_A)
|
| 315 |
+
>>> p1_C = tf_C_A.apply(p1_A)
|
| 316 |
+
>>> print(p1_A) # Original point 1 in A
|
| 317 |
+
[1 0 0]
|
| 318 |
+
>>> print(p1_B) # Point 1 in B
|
| 319 |
+
[3. 0. 0.]
|
| 320 |
+
>>> print(p1_C) # Point 1 in C
|
| 321 |
+
[ 2.59807621 -1.5 -2. ]
|
| 322 |
+
|
| 323 |
+
We can also do the reverse. We define a point in C and transform it to A:
|
| 324 |
+
|
| 325 |
+
>>> p2_C = np.array([0, 1, 0]) # +1 in y_C direction
|
| 326 |
+
>>> p2_A = tf_A_C.apply(p2_C)
|
| 327 |
+
>>> print(p2_C) # Original point 2 in C
|
| 328 |
+
[0 1 0]
|
| 329 |
+
>>> print(p2_A) # Point 2 in A
|
| 330 |
+
[-2.5 -2. 0.8660254]
|
| 331 |
+
|
| 332 |
+
Plot the frames with respect to A again, but also plot these two points:
|
| 333 |
+
|
| 334 |
+
>>> fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
|
| 335 |
+
>>> plot_transformed_axes(ax, tf_A, name="tfA") # A plotted in A
|
| 336 |
+
>>> plot_transformed_axes(ax, tf_A_B, name="tfAB") # B plotted in A
|
| 337 |
+
>>> plot_transformed_axes(ax, tf_A_C, name="tfAC") # C plotted in A
|
| 338 |
+
>>> ax.scatter(p1_A[0], p1_A[1], p1_A[2], color=colors[0]) # +1 x_A
|
| 339 |
+
>>> ax.scatter(p2_A[0], p2_A[1], p2_A[2], color=colors[1]) # +1 y_C
|
| 340 |
+
>>> ax.set_title("A, B, C frames and points with respect to A")
|
| 341 |
+
>>> ax.set_aspect("equal")
|
| 342 |
+
>>> ax.figure.set_size_inches(6, 5)
|
| 343 |
+
>>> plt.show()
|
| 344 |
+
|
| 345 |
+
**Switching Base Frames**
|
| 346 |
+
|
| 347 |
+
Up to this point, we have been visualizing frames from A's perspective.
|
| 348 |
+
Let's use the transforms we defined to visualize the frames from C's
|
| 349 |
+
perspective.
|
| 350 |
+
|
| 351 |
+
Now C is the "base frame" or "world frame". All frames are the identity
|
| 352 |
+
transform from their own perspective.
|
| 353 |
+
|
| 354 |
+
>>> tf_C = Tf.identity()
|
| 355 |
+
|
| 356 |
+
We've already defined the transform C <- A, and can obtain C <- B by
|
| 357 |
+
inverting the existing transform B <- C.
|
| 358 |
+
|
| 359 |
+
>>> tf_C_B = tf_B_C.inv() # C <- B
|
| 360 |
+
|
| 361 |
+
This lets us plot everything from C's perspective:
|
| 362 |
+
|
| 363 |
+
>>> fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
|
| 364 |
+
>>> plot_transformed_axes(ax, tf_C, name="tfC") # C plotted in C
|
| 365 |
+
>>> plot_transformed_axes(ax, tf_C_B, name="tfCB") # B plotted in C
|
| 366 |
+
>>> plot_transformed_axes(ax, tf_C_A, name="tfCA") # A plotted in C
|
| 367 |
+
>>> ax.scatter(p1_C[0], p1_C[1], p1_C[2], color=colors[0])
|
| 368 |
+
>>> ax.scatter(p2_C[0], p2_C[1], p2_C[2], color=colors[1])
|
| 369 |
+
>>> ax.set_title("A, B, C frames and points with respect to C")
|
| 370 |
+
>>> ax.set_aspect("equal")
|
| 371 |
+
>>> ax.figure.set_size_inches(6, 5)
|
| 372 |
+
>>> plt.show()
|
| 373 |
+
"""
|
| 374 |
+
|
| 375 |
+
def __init__(self, matrix: ArrayLike, normalize: bool = True, copy: bool = True):
|
| 376 |
+
"""Initialize from a 4x4 transformation matrix.
|
| 377 |
+
|
| 378 |
+
Rotations are not meant to be initialized directly. Please use one of
|
| 379 |
+
the `from_...` methods instead.
|
| 380 |
+
|
| 381 |
+
Parameters
|
| 382 |
+
----------
|
| 383 |
+
matrix : array_like, shape (..., 4, 4)
|
| 384 |
+
A single transformation matrix or a stack of transformation
|
| 385 |
+
matrices.
|
| 386 |
+
normalize : bool, optional
|
| 387 |
+
If True, orthonormalize the rotation matrix using singular value
|
| 388 |
+
decomposition. If False, the rotation matrix is not checked for
|
| 389 |
+
orthogonality or right-handedness.
|
| 390 |
+
copy : bool, optional
|
| 391 |
+
If True, copy the input matrix. If False, a reference to the input
|
| 392 |
+
matrix is used. If normalize is True, the input matrix is always
|
| 393 |
+
copied regardless of the value of copy.
|
| 394 |
+
|
| 395 |
+
Returns
|
| 396 |
+
-------
|
| 397 |
+
transform : `RigidTransform` instance
|
| 398 |
+
"""
|
| 399 |
+
xp = array_namespace(matrix)
|
| 400 |
+
self._xp = xp
|
| 401 |
+
matrix = _promote(matrix, xp=xp)
|
| 402 |
+
if matrix.shape[-2:] != (4, 4):
|
| 403 |
+
raise ValueError(
|
| 404 |
+
f"Expected `matrix` to have shape (..., 4, 4), got {matrix.shape}."
|
| 405 |
+
)
|
| 406 |
+
# We only need the _single flag for the cython backend. The Array API backend
|
| 407 |
+
# uses broadcasting by default and hence returns the correct shape without
|
| 408 |
+
# additional _single logic
|
| 409 |
+
self._single = matrix.ndim == 2 and is_numpy(xp)
|
| 410 |
+
if self._single:
|
| 411 |
+
matrix = xpx.atleast_nd(matrix, ndim=3, xp=xp)
|
| 412 |
+
|
| 413 |
+
self._backend = select_backend(xp, matrix.ndim < 4)
|
| 414 |
+
self._matrix = self._backend.from_matrix(matrix, normalize, copy)
|
| 415 |
+
|
| 416 |
+
def __repr__(self):
|
| 417 |
+
m = f"{self.as_matrix()!r}".splitlines()
|
| 418 |
+
# bump indent (+27 characters)
|
| 419 |
+
m[1:] = [" " * 27 + m[i] for i in range(1, len(m))]
|
| 420 |
+
return "RigidTransform.from_matrix(" + "\n".join(m) + ")"
|
| 421 |
+
|
| 422 |
+
@staticmethod
|
| 423 |
+
@xp_capabilities(
|
| 424 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 425 |
+
)
|
| 426 |
+
def from_matrix(matrix: ArrayLike) -> RigidTransform:
|
| 427 |
+
"""Initialize from a 4x4 transformation matrix.
|
| 428 |
+
|
| 429 |
+
Parameters
|
| 430 |
+
----------
|
| 431 |
+
matrix : array_like, shape (..., 4, 4)
|
| 432 |
+
Transformation matrices. Each matrix[..., :, :] represents a 4x4
|
| 433 |
+
transformation matrix.
|
| 434 |
+
|
| 435 |
+
Returns
|
| 436 |
+
-------
|
| 437 |
+
transform : `RigidTransform` instance
|
| 438 |
+
|
| 439 |
+
Notes
|
| 440 |
+
-----
|
| 441 |
+
4x4 rigid transformation matrices are of the form::
|
| 442 |
+
|
| 443 |
+
[ tx]
|
| 444 |
+
[ R ty]
|
| 445 |
+
[ tz]
|
| 446 |
+
[ 0 0 0 1]
|
| 447 |
+
|
| 448 |
+
where ``R`` is a 3x3 rotation matrix and ``t = [tx, ty, tz]`` is a 3x1
|
| 449 |
+
translation vector. As rotation matrices must be proper orthogonal, the
|
| 450 |
+
rotation component is orthonormalized using singular value decomposition
|
| 451 |
+
before initialization.
|
| 452 |
+
|
| 453 |
+
Examples
|
| 454 |
+
--------
|
| 455 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 456 |
+
>>> import numpy as np
|
| 457 |
+
|
| 458 |
+
Creating a transform from a single matrix:
|
| 459 |
+
|
| 460 |
+
>>> m = np.array([[0, 1, 0, 2],
|
| 461 |
+
... [0, 0, 1, 3],
|
| 462 |
+
... [1, 0, 0, 4],
|
| 463 |
+
... [0, 0, 0, 1]])
|
| 464 |
+
>>> tf = Tf.from_matrix(m)
|
| 465 |
+
>>> tf.as_matrix()
|
| 466 |
+
array([[0., 1., 0., 2.],
|
| 467 |
+
[0., 0., 1., 3.],
|
| 468 |
+
[1., 0., 0., 4.],
|
| 469 |
+
[0., 0., 0., 1.]])
|
| 470 |
+
>>> tf.single
|
| 471 |
+
True
|
| 472 |
+
|
| 473 |
+
Creating a transform from an N-dimensional array of matrices:
|
| 474 |
+
|
| 475 |
+
>>> m = np.tile(np.eye(4), (2, 5, 1, 1)) # Shape (2, 5, 4, 4)
|
| 476 |
+
>>> tf = Tf.from_matrix(m)
|
| 477 |
+
>>> tf.shape
|
| 478 |
+
(2, 5)
|
| 479 |
+
>>> tf.single
|
| 480 |
+
False
|
| 481 |
+
>>> len(tf)
|
| 482 |
+
2
|
| 483 |
+
|
| 484 |
+
Matrices with a rotation component that is not proper orthogonal are
|
| 485 |
+
orthogonalized using singular value decomposition before initialization:
|
| 486 |
+
|
| 487 |
+
>>> tf = Tf.from_matrix(np.diag([2, 2, 2, 1]))
|
| 488 |
+
>>> tf.as_matrix()
|
| 489 |
+
array([[1., 0., 0., 0.],
|
| 490 |
+
[0., 1., 0., 0.],
|
| 491 |
+
[0., 0., 1., 0.],
|
| 492 |
+
[0., 0., 0., 1.]])
|
| 493 |
+
"""
|
| 494 |
+
return RigidTransform(matrix, normalize=True, copy=True)
|
| 495 |
+
|
| 496 |
+
@staticmethod
|
| 497 |
+
@xp_capabilities(
|
| 498 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 499 |
+
)
|
| 500 |
+
def from_rotation(rotation: Rotation) -> RigidTransform:
|
| 501 |
+
"""Initialize from a rotation, without a translation.
|
| 502 |
+
|
| 503 |
+
When applying this transform to a vector ``v``, the result is the
|
| 504 |
+
same as if the rotation was applied to the vector.
|
| 505 |
+
``Tf.from_rotation(r).apply(v) == r.apply(v)``
|
| 506 |
+
|
| 507 |
+
Parameters
|
| 508 |
+
----------
|
| 509 |
+
rotation : `Rotation` instance
|
| 510 |
+
A single rotation or a rotation with N leading dimensions.
|
| 511 |
+
|
| 512 |
+
Returns
|
| 513 |
+
-------
|
| 514 |
+
transform : `RigidTransform` instance
|
| 515 |
+
|
| 516 |
+
Examples
|
| 517 |
+
--------
|
| 518 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 519 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 520 |
+
>>> import numpy as np
|
| 521 |
+
|
| 522 |
+
Creating a transform from a single rotation:
|
| 523 |
+
|
| 524 |
+
>>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
|
| 525 |
+
>>> r.apply([1, 0, 0])
|
| 526 |
+
array([0. , 0.8660254, -0.5 ])
|
| 527 |
+
>>> tf = Tf.from_rotation(r)
|
| 528 |
+
>>> tf.apply([1, 0, 0])
|
| 529 |
+
array([0. , 0.8660254, -0.5 ])
|
| 530 |
+
>>> tf.single
|
| 531 |
+
True
|
| 532 |
+
|
| 533 |
+
The upper 3x3 submatrix of the transformation matrix is the rotation
|
| 534 |
+
matrix:
|
| 535 |
+
|
| 536 |
+
>>> np.allclose(tf.as_matrix()[:3, :3], r.as_matrix(), atol=1e-12)
|
| 537 |
+
True
|
| 538 |
+
|
| 539 |
+
Creating multiple transforms from a rotation with N leading dimensions:
|
| 540 |
+
|
| 541 |
+
>>> r = R.from_euler("ZYX", [[90, 30, 0], [45, 30, 60]], degrees=True)
|
| 542 |
+
>>> r.apply([1, 0, 0])
|
| 543 |
+
array([[0. , 0.8660254 , -0.5 ],
|
| 544 |
+
[0.61237244, 0.61237244, -0.5 ]])
|
| 545 |
+
>>> tf = Tf.from_rotation(r)
|
| 546 |
+
>>> tf.apply([1, 0, 0])
|
| 547 |
+
array([[0. , 0.8660254 , -0.5 ],
|
| 548 |
+
[0.61237244, 0.61237244, -0.5 ]])
|
| 549 |
+
>>> tf.single
|
| 550 |
+
False
|
| 551 |
+
>>> len(tf)
|
| 552 |
+
2
|
| 553 |
+
"""
|
| 554 |
+
if not isinstance(rotation, Rotation):
|
| 555 |
+
raise TypeError(
|
| 556 |
+
"Expected `rotation` to be a `Rotation` instance, "
|
| 557 |
+
f"got {type(rotation)}."
|
| 558 |
+
)
|
| 559 |
+
quat = rotation.as_quat()
|
| 560 |
+
xp = array_namespace(quat)
|
| 561 |
+
backend = select_backend(xp, quat.ndim < 3)
|
| 562 |
+
matrix = backend.from_rotation(quat)
|
| 563 |
+
return RigidTransform._from_raw_matrix(matrix, xp, backend)
|
| 564 |
+
|
| 565 |
+
@staticmethod
|
| 566 |
+
@xp_capabilities(
|
| 567 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 568 |
+
)
|
| 569 |
+
def from_translation(translation: ArrayLike) -> RigidTransform:
|
| 570 |
+
"""Initialize from a translation numpy array, without a rotation.
|
| 571 |
+
|
| 572 |
+
When applying this transform to a vector ``v``, the result is the same
|
| 573 |
+
as if the translation and vector were added together. If ``t`` is the
|
| 574 |
+
displacement vector of the translation, then:
|
| 575 |
+
|
| 576 |
+
``Tf.from_translation(t).apply(v) == t + v``
|
| 577 |
+
|
| 578 |
+
Parameters
|
| 579 |
+
----------
|
| 580 |
+
translation : array_like, shape (..., 3)
|
| 581 |
+
Translation vectors. Each translation[..., :] represents a 3D
|
| 582 |
+
translation vector.
|
| 583 |
+
|
| 584 |
+
Returns
|
| 585 |
+
-------
|
| 586 |
+
transform : `RigidTransform` instance
|
| 587 |
+
|
| 588 |
+
Examples
|
| 589 |
+
--------
|
| 590 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 591 |
+
>>> import numpy as np
|
| 592 |
+
|
| 593 |
+
Creating a transform from a single translation vector:
|
| 594 |
+
|
| 595 |
+
>>> t = np.array([2, 3, 4])
|
| 596 |
+
>>> t + np.array([1, 0, 0])
|
| 597 |
+
array([3, 3, 4])
|
| 598 |
+
>>> tf = Tf.from_translation(t)
|
| 599 |
+
>>> tf.apply([1, 0, 0])
|
| 600 |
+
array([3., 3., 4.])
|
| 601 |
+
>>> tf.single
|
| 602 |
+
True
|
| 603 |
+
|
| 604 |
+
The top 3x1 points in the rightmost column of the transformation matrix
|
| 605 |
+
is the translation vector:
|
| 606 |
+
|
| 607 |
+
>>> tf.as_matrix()
|
| 608 |
+
array([[1., 0., 0., 2.],
|
| 609 |
+
[0., 1., 0., 3.],
|
| 610 |
+
[0., 0., 1., 4.],
|
| 611 |
+
[0., 0., 0., 1.]])
|
| 612 |
+
>>> np.allclose(tf.as_matrix()[:3, 3], t)
|
| 613 |
+
True
|
| 614 |
+
|
| 615 |
+
Creating multiple transforms from an N-dimensional array of translation
|
| 616 |
+
vectors:
|
| 617 |
+
|
| 618 |
+
>>> t = np.array([[2, 3, 4], [1, 0, 0]])
|
| 619 |
+
>>> t + np.array([1, 0, 0])
|
| 620 |
+
array([[3, 3, 4],
|
| 621 |
+
[2, 0, 0]])
|
| 622 |
+
>>> tf = Tf.from_translation(t)
|
| 623 |
+
>>> tf.apply([1, 0, 0])
|
| 624 |
+
array([[3., 3., 4.],
|
| 625 |
+
[2., 0., 0.]])
|
| 626 |
+
>>> np.allclose(tf.as_matrix()[:, :3, 3], t)
|
| 627 |
+
True
|
| 628 |
+
>>> tf.single
|
| 629 |
+
False
|
| 630 |
+
>>> len(tf)
|
| 631 |
+
2
|
| 632 |
+
"""
|
| 633 |
+
xp = array_namespace(translation)
|
| 634 |
+
translation = _promote(translation, xp=xp)
|
| 635 |
+
backend = select_backend(xp, translation.ndim < 3)
|
| 636 |
+
matrix = backend.from_translation(translation)
|
| 637 |
+
return RigidTransform._from_raw_matrix(matrix, xp, backend)
|
| 638 |
+
|
| 639 |
+
@staticmethod
|
| 640 |
+
@xp_capabilities(
|
| 641 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 642 |
+
)
|
| 643 |
+
def from_components(translation: ArrayLike, rotation: Rotation) -> RigidTransform:
|
| 644 |
+
"""Initialize a rigid transform from translation and rotation
|
| 645 |
+
components.
|
| 646 |
+
|
| 647 |
+
When creating a rigid transform from a translation and rotation, the
|
| 648 |
+
translation is applied after the rotation, such that
|
| 649 |
+
``tf = Tf.from_components(translation, rotation)``
|
| 650 |
+
is equivalent to
|
| 651 |
+
``tf = Tf.from_translation(translation) * Tf.from_rotation(rotation)``.
|
| 652 |
+
|
| 653 |
+
When applying a transform to a vector ``v``, the result is the
|
| 654 |
+
same as if the transform was applied to the vector in the
|
| 655 |
+
following way: ``tf.apply(v) == translation + rotation.apply(v)``
|
| 656 |
+
|
| 657 |
+
Parameters
|
| 658 |
+
----------
|
| 659 |
+
translation : array_like, shape (..., 3)
|
| 660 |
+
Translation vectors. Each translation[..., :] represents a 3D
|
| 661 |
+
translation vector.
|
| 662 |
+
rotation : `Rotation` instance
|
| 663 |
+
Rotation objects. The shape must be broadcastable with the
|
| 664 |
+
translation shape.
|
| 665 |
+
|
| 666 |
+
Returns
|
| 667 |
+
-------
|
| 668 |
+
transform : `RigidTransform` instance
|
| 669 |
+
Rigid transform objects. The shape is determined by broadcasting
|
| 670 |
+
the translation and rotation shapes together.
|
| 671 |
+
|
| 672 |
+
Examples
|
| 673 |
+
--------
|
| 674 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 675 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 676 |
+
>>> import numpy as np
|
| 677 |
+
|
| 678 |
+
Creating from a single rotation and translation:
|
| 679 |
+
|
| 680 |
+
>>> t = np.array([2, 3, 4])
|
| 681 |
+
>>> r = R.from_euler("ZYX", [90, 30, 0], degrees=True)
|
| 682 |
+
>>> r.as_matrix()
|
| 683 |
+
array([[ 0. , -1., 0. ],
|
| 684 |
+
[ 0.8660254, 0., 0.5 ],
|
| 685 |
+
[-0.5 , 0., 0.8660254 ]])
|
| 686 |
+
>>> tf = Tf.from_components(t, r)
|
| 687 |
+
>>> tf.rotation.as_matrix()
|
| 688 |
+
array([[ 0. , -1., 0. ],
|
| 689 |
+
[ 0.8660254, 0., 0.5 ],
|
| 690 |
+
[-0.5 , 0., 0.8660254 ]])
|
| 691 |
+
>>> tf.translation
|
| 692 |
+
array([2., 3., 4.])
|
| 693 |
+
>>> tf.single
|
| 694 |
+
True
|
| 695 |
+
|
| 696 |
+
When applying a transform to a vector ``v``, the result is the same as
|
| 697 |
+
if the transform was applied to the vector in the following way:
|
| 698 |
+
``tf.apply(v) == translation + rotation.apply(v)``
|
| 699 |
+
|
| 700 |
+
>>> r.apply([1, 0, 0])
|
| 701 |
+
array([0. , 0.8660254, -0.5 ])
|
| 702 |
+
>>> t + r.apply([1, 0, 0])
|
| 703 |
+
array([2. , 3.8660254, 3.5 ])
|
| 704 |
+
>>> tf.apply([1, 0, 0])
|
| 705 |
+
array([2. , 3.8660254, 3.5 ])
|
| 706 |
+
"""
|
| 707 |
+
rotation_tf = RigidTransform.from_rotation(rotation)
|
| 708 |
+
return RigidTransform.from_translation(translation) * rotation_tf
|
| 709 |
+
|
| 710 |
+
@staticmethod
|
| 711 |
+
@xp_capabilities(
|
| 712 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 713 |
+
)
|
| 714 |
+
def from_exp_coords(exp_coords: ArrayLike) -> RigidTransform:
|
| 715 |
+
r"""Initialize from exponential coordinates of transform.
|
| 716 |
+
|
| 717 |
+
This implements the exponential map that converts 6-dimensional real
|
| 718 |
+
vectors to SE(3).
|
| 719 |
+
|
| 720 |
+
An exponential coordinate vector consists of 6 elements
|
| 721 |
+
``[rx, ry, rz, vx, vy, vz]``. The first 3 encode rotation (and form a
|
| 722 |
+
rotation vector used in `Rotation.from_rotvec`) and the last 3 encode
|
| 723 |
+
translation (and form a translation vector for pure translations).
|
| 724 |
+
The exponential mapping can be expressed as matrix exponential
|
| 725 |
+
``T = exp(tau)``, where ``T`` is a 4x4 matrix representing a rigid
|
| 726 |
+
transform and ``tau`` is a 4x4 matrix formed from the elements of an
|
| 727 |
+
exponential coordinate vector::
|
| 728 |
+
|
| 729 |
+
tau = [ 0 -rz ry vx]
|
| 730 |
+
[ rz 0 -rx vy]
|
| 731 |
+
[-ry rx 0 vz]
|
| 732 |
+
[ 0 0 0 1]
|
| 733 |
+
|
| 734 |
+
Parameters
|
| 735 |
+
----------
|
| 736 |
+
exp_coords : array_like, shape (..., 6)
|
| 737 |
+
Exponential coordinate vectors. Each exp_coords[..., :] represents
|
| 738 |
+
a 6D exponential coordinate vector with the expected order of
|
| 739 |
+
components ``[rx, ry, rz, vx, vy, vz]``. The first 3 components
|
| 740 |
+
encode rotation and the last 3 encode translation.
|
| 741 |
+
|
| 742 |
+
Returns
|
| 743 |
+
-------
|
| 744 |
+
transform : `RigidTransform` instance
|
| 745 |
+
Rigid transform objects with the same leading dimensions as the input.
|
| 746 |
+
|
| 747 |
+
Examples
|
| 748 |
+
--------
|
| 749 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 750 |
+
>>> import numpy as np
|
| 751 |
+
|
| 752 |
+
Creating from a single 6d vector of exponential coordinates:
|
| 753 |
+
|
| 754 |
+
>>> tf = Tf.from_exp_coords([
|
| 755 |
+
... -2.01041204, -0.52983629, 0.65773501,
|
| 756 |
+
... 0.10386614, 0.05855009, 0.54959179])
|
| 757 |
+
>>> tf.as_matrix()
|
| 758 |
+
array([[0.76406621, 0.10504613, -0.63652819, -0.10209961],
|
| 759 |
+
[0.59956454, -0.47987325, 0.64050295, 0.40158789],
|
| 760 |
+
[-0.2381705, -0.87102639, -0.42963687, 0.19637636],
|
| 761 |
+
[0., 0., 0., 1.]])
|
| 762 |
+
>>> tf.single
|
| 763 |
+
True
|
| 764 |
+
|
| 765 |
+
A vector of zeros represents the identity transform:
|
| 766 |
+
|
| 767 |
+
>>> tf = Tf.from_exp_coords(np.zeros(6))
|
| 768 |
+
>>> tf.as_matrix()
|
| 769 |
+
array([[1., 0., 0., 0.],
|
| 770 |
+
[0., 1., 0., 0.],
|
| 771 |
+
[0., 0., 1., 0.],
|
| 772 |
+
[0., 0., 0., 1.]])
|
| 773 |
+
|
| 774 |
+
The last three numbers encode translation. If the first three numbers
|
| 775 |
+
are zero, the last three components can be interpreted as the
|
| 776 |
+
translation:
|
| 777 |
+
|
| 778 |
+
>>> tf_trans = Tf.from_exp_coords([0, 0, 0, 4.3, -2, 3.4])
|
| 779 |
+
>>> tf_trans.translation
|
| 780 |
+
array([4.3, -2., 3.4])
|
| 781 |
+
|
| 782 |
+
The first three numbers encode rotation as a rotation vector:
|
| 783 |
+
|
| 784 |
+
>>> tf_rot = Tf.from_exp_coords([0.5, 0.3, 0.1, 0, 0, 0])
|
| 785 |
+
>>> tf_rot.rotation.as_rotvec()
|
| 786 |
+
array([0.5, 0.3, 0.1])
|
| 787 |
+
|
| 788 |
+
Combining translation and rotation preserves the rotation vector,
|
| 789 |
+
but changes the last three components as they encode translation and
|
| 790 |
+
rotation:
|
| 791 |
+
|
| 792 |
+
>>> (tf_trans * tf_rot).as_exp_coords()
|
| 793 |
+
array([0.5, 0.3, 0.1, 3.64305882, -1.25879559, 4.46109265])
|
| 794 |
+
"""
|
| 795 |
+
xp = array_namespace(exp_coords)
|
| 796 |
+
exp_coords = xp_promote(exp_coords, force_floating=True, xp=xp)
|
| 797 |
+
if exp_coords.shape[-1] != 6:
|
| 798 |
+
raise ValueError(
|
| 799 |
+
f"Expected `exp_coords` to have shape (..., 6), got {exp_coords.shape}."
|
| 800 |
+
)
|
| 801 |
+
backend = select_backend(xp, cython_compatible=exp_coords.ndim < 3)
|
| 802 |
+
matrix = backend.from_exp_coords(exp_coords)
|
| 803 |
+
return RigidTransform._from_raw_matrix(matrix, xp, backend)
|
| 804 |
+
|
| 805 |
+
@staticmethod
|
| 806 |
+
@xp_capabilities(
|
| 807 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 808 |
+
)
|
| 809 |
+
def from_dual_quat(
|
| 810 |
+
dual_quat: ArrayLike, *, scalar_first: bool = False
|
| 811 |
+
) -> RigidTransform:
|
| 812 |
+
"""Initialize from a unit dual quaternion.
|
| 813 |
+
|
| 814 |
+
Unit dual quaternions encode orientation in a real unit quaternion
|
| 815 |
+
and translation in a dual quaternion. There is a double cover, i.e.,
|
| 816 |
+
the unit dual quaternions q and -q represent the same transform.
|
| 817 |
+
|
| 818 |
+
Unit dual quaternions must have a real quaternion with unit norm and
|
| 819 |
+
a dual quaternion that is orthogonal to the real quaternion to satisfy
|
| 820 |
+
the unit norm constraint. This function will enforce both properties
|
| 821 |
+
through normalization.
|
| 822 |
+
|
| 823 |
+
Parameters
|
| 824 |
+
----------
|
| 825 |
+
dual_quat : array_like, shape (..., 8)
|
| 826 |
+
Unit dual quaternions. Each dual_quat[..., :] represents a unit
|
| 827 |
+
dual quaternion. The real part is stored in the first four
|
| 828 |
+
components and the dual part in the last four components.
|
| 829 |
+
scalar_first : bool, optional
|
| 830 |
+
Whether the scalar component goes first or last in the two
|
| 831 |
+
individual quaternions that represent the real and the dual part.
|
| 832 |
+
Default is False, i.e. the scalar-last order is used.
|
| 833 |
+
|
| 834 |
+
Returns
|
| 835 |
+
-------
|
| 836 |
+
transform : `RigidTransform` instance
|
| 837 |
+
Rigid transform objects with the same leading dimensions as the input.
|
| 838 |
+
|
| 839 |
+
Examples
|
| 840 |
+
--------
|
| 841 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 842 |
+
>>> import numpy as np
|
| 843 |
+
|
| 844 |
+
Creating from a single unit dual quaternion:
|
| 845 |
+
|
| 846 |
+
>>> tf = Tf.from_dual_quat([
|
| 847 |
+
... 0.0617101, -0.06483886, 0.31432811, 0.94508498,
|
| 848 |
+
... 0.04985168, -0.26119618, 0.1691491, -0.07743254])
|
| 849 |
+
>>> tf.as_matrix()
|
| 850 |
+
array([[0.79398752, -0.60213598, -0.08376202, 0.24605262],
|
| 851 |
+
[0.58613113, 0.79477941, -0.15740392, -0.4932833],
|
| 852 |
+
[0.16135089, 0.07588122, 0.98397557, 0.34262676],
|
| 853 |
+
[0., 0., 0., 1.]])
|
| 854 |
+
>>> tf.single
|
| 855 |
+
True
|
| 856 |
+
"""
|
| 857 |
+
xp = array_namespace(dual_quat)
|
| 858 |
+
dual_quat = _promote(dual_quat, xp=xp)
|
| 859 |
+
backend = select_backend(xp, dual_quat.ndim < 3)
|
| 860 |
+
matrix = backend.from_dual_quat(dual_quat, scalar_first=scalar_first)
|
| 861 |
+
return RigidTransform._from_raw_matrix(matrix, xp, backend)
|
| 862 |
+
|
| 863 |
+
@staticmethod
|
| 864 |
+
@xp_capabilities(
|
| 865 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 866 |
+
)
|
| 867 |
+
def identity(
|
| 868 |
+
num: int | None = None, *, shape: int | tuple[int, ...] | None = None
|
| 869 |
+
) -> RigidTransform:
|
| 870 |
+
"""Initialize an identity transform.
|
| 871 |
+
|
| 872 |
+
Composition with the identity transform has no effect, and
|
| 873 |
+
applying the identity transform to a vector has no effect.
|
| 874 |
+
|
| 875 |
+
Parameters
|
| 876 |
+
----------
|
| 877 |
+
num : int, optional
|
| 878 |
+
Number of identity transforms to generate. If None (default),
|
| 879 |
+
then a single transform is generated.
|
| 880 |
+
shape : int or tuple of ints, optional
|
| 881 |
+
Shape of the identity transforms. If specified, `num` must
|
| 882 |
+
be None.
|
| 883 |
+
|
| 884 |
+
Returns
|
| 885 |
+
-------
|
| 886 |
+
transform : `RigidTransform` instance
|
| 887 |
+
The identity transform.
|
| 888 |
+
|
| 889 |
+
Examples
|
| 890 |
+
--------
|
| 891 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 892 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 893 |
+
>>> import numpy as np
|
| 894 |
+
|
| 895 |
+
Creating a single identity transform:
|
| 896 |
+
|
| 897 |
+
>>> tf = Tf.identity()
|
| 898 |
+
>>> tf.as_matrix()
|
| 899 |
+
array([[1., 0., 0., 0.],
|
| 900 |
+
[0., 1., 0., 0.],
|
| 901 |
+
[0., 0., 1., 0.],
|
| 902 |
+
[0., 0., 0., 1.]])
|
| 903 |
+
>>> tf.single
|
| 904 |
+
True
|
| 905 |
+
|
| 906 |
+
The identity transform can be applied to a vector without effect:
|
| 907 |
+
|
| 908 |
+
>>> tf.apply([1, 2, 3])
|
| 909 |
+
array([1., 2., 3.])
|
| 910 |
+
|
| 911 |
+
The identity transform when composed with another transform has no
|
| 912 |
+
effect:
|
| 913 |
+
|
| 914 |
+
>>> rng = np.random.default_rng(123)
|
| 915 |
+
>>> t = rng.random(3)
|
| 916 |
+
>>> r = R.random(rng=rng)
|
| 917 |
+
>>> tf = Tf.from_components(t, r)
|
| 918 |
+
>>> np.allclose((Tf.identity() * tf).as_matrix(),
|
| 919 |
+
... tf.as_matrix(), atol=1e-12)
|
| 920 |
+
True
|
| 921 |
+
|
| 922 |
+
Multiple identity transforms can be generated at once:
|
| 923 |
+
|
| 924 |
+
>>> tf = Tf.identity(2)
|
| 925 |
+
>>> tf.as_matrix()
|
| 926 |
+
array([[[1., 0., 0., 0.],
|
| 927 |
+
[0., 1., 0., 0.],
|
| 928 |
+
[0., 0., 1., 0.],
|
| 929 |
+
[0., 0., 0., 1.]],
|
| 930 |
+
[[1., 0., 0., 0.],
|
| 931 |
+
[0., 1., 0., 0.],
|
| 932 |
+
[0., 0., 1., 0.],
|
| 933 |
+
[0., 0., 0., 1.]]])
|
| 934 |
+
>>> tf.single
|
| 935 |
+
False
|
| 936 |
+
>>> len(tf)
|
| 937 |
+
2
|
| 938 |
+
"""
|
| 939 |
+
if num is not None and shape is not None:
|
| 940 |
+
raise ValueError("Only one of `num` and `shape` can be specified.")
|
| 941 |
+
if num is None and shape is None:
|
| 942 |
+
shape = ()
|
| 943 |
+
elif num is not None:
|
| 944 |
+
shape = (num,)
|
| 945 |
+
elif isinstance(shape, int):
|
| 946 |
+
shape = (shape,)
|
| 947 |
+
elif not isinstance(shape, tuple):
|
| 948 |
+
raise ValueError("`shape` must be an int or a tuple of ints or None.")
|
| 949 |
+
matrix = np.tile(np.eye(4), shape + (1, 1))
|
| 950 |
+
# No need for a backend call here since identity is easy to construct and we are
|
| 951 |
+
# currently not offering a backend-specific identity matrix
|
| 952 |
+
return RigidTransform._from_raw_matrix(matrix, array_namespace(matrix))
|
| 953 |
+
|
| 954 |
+
@staticmethod
|
| 955 |
+
@xp_capabilities(
|
| 956 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 957 |
+
)
|
| 958 |
+
def concatenate(
|
| 959 |
+
transforms: RigidTransform | Iterable[RigidTransform],
|
| 960 |
+
) -> RigidTransform:
|
| 961 |
+
"""
|
| 962 |
+
Concatenate a sequence of `RigidTransform` objects into a
|
| 963 |
+
single object.
|
| 964 |
+
|
| 965 |
+
Parameters
|
| 966 |
+
----------
|
| 967 |
+
transforms : sequence of `RigidTransform`
|
| 968 |
+
If a single `RigidTransform` instance is passed in, a copy of
|
| 969 |
+
it is returned.
|
| 970 |
+
|
| 971 |
+
Returns
|
| 972 |
+
-------
|
| 973 |
+
transform : `RigidTransform` instance
|
| 974 |
+
The concatenated transform.
|
| 975 |
+
|
| 976 |
+
Examples
|
| 977 |
+
--------
|
| 978 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 979 |
+
>>> tf1 = Tf.from_translation([1, 0, 0])
|
| 980 |
+
>>> tf2 = Tf.from_translation([[2, 0, 0], [3, 0, 0]])
|
| 981 |
+
>>> Tf.concatenate([tf1, tf2]).translation
|
| 982 |
+
array([[1., 0., 0.],
|
| 983 |
+
[2., 0., 0.],
|
| 984 |
+
[3., 0., 0.]])
|
| 985 |
+
"""
|
| 986 |
+
if isinstance(transforms, RigidTransform):
|
| 987 |
+
return RigidTransform._from_raw_matrix(
|
| 988 |
+
transforms.as_matrix(), transforms._xp
|
| 989 |
+
)
|
| 990 |
+
if not all(isinstance(x, RigidTransform) for x in transforms):
|
| 991 |
+
raise TypeError("input must contain RigidTransform objects only")
|
| 992 |
+
|
| 993 |
+
xp = array_namespace(transforms[0].as_matrix())
|
| 994 |
+
matrix = xp.concat(
|
| 995 |
+
[xpx.atleast_nd(x.as_matrix(), ndim=3, xp=xp) for x in transforms]
|
| 996 |
+
)
|
| 997 |
+
return RigidTransform._from_raw_matrix(matrix, xp, None)
|
| 998 |
+
|
| 999 |
+
@xp_capabilities(
|
| 1000 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1001 |
+
)
|
| 1002 |
+
def mean(self,
|
| 1003 |
+
weights: ArrayLike | None = None,
|
| 1004 |
+
axis: None | int | tuple[int, ...] = None
|
| 1005 |
+
) -> RigidTransform:
|
| 1006 |
+
"""Get the mean of the transforms.
|
| 1007 |
+
|
| 1008 |
+
The mean of a set of transforms is the same as the mean of its
|
| 1009 |
+
rotation and translation components.
|
| 1010 |
+
|
| 1011 |
+
The mean used for the rotation component is the chordal L2 mean (also
|
| 1012 |
+
called the projected or induced arithmetic mean) [1]_. If ``A`` is a
|
| 1013 |
+
set of rotation matrices, then the mean ``M`` is the rotation matrix
|
| 1014 |
+
that minimizes the following loss function:
|
| 1015 |
+
|
| 1016 |
+
.. math::
|
| 1017 |
+
|
| 1018 |
+
L(M) = \\sum_{i = 1}^{n} w_i \\lVert \\mathbf{A}_i -
|
| 1019 |
+
\\mathbf{M} \\rVert^2 ,
|
| 1020 |
+
|
| 1021 |
+
where :math:`w_i`'s are the `weights` corresponding to each matrix.
|
| 1022 |
+
|
| 1023 |
+
Parameters
|
| 1024 |
+
----------
|
| 1025 |
+
weights : array_like shape (..., N), optional
|
| 1026 |
+
Weights describing the relative importance of the transforms. If
|
| 1027 |
+
None (default), then all values in `weights` are assumed to be
|
| 1028 |
+
equal. If given, the shape of `weights` must be broadcastable to
|
| 1029 |
+
the transform shape. Weights must be non-negative.
|
| 1030 |
+
axis : None, int, or tuple of ints, optional
|
| 1031 |
+
Axis or axes along which the means are computed. The default is to
|
| 1032 |
+
compute the mean of all transforms.
|
| 1033 |
+
|
| 1034 |
+
Returns
|
| 1035 |
+
-------
|
| 1036 |
+
mean : `RigidTransform` instance
|
| 1037 |
+
Single transform containing the mean of the transforms in the
|
| 1038 |
+
current instance.
|
| 1039 |
+
|
| 1040 |
+
References
|
| 1041 |
+
----------
|
| 1042 |
+
.. [1] Hartley, Richard, et al.,
|
| 1043 |
+
"Rotation Averaging", International Journal of Computer Vision
|
| 1044 |
+
103, 2013, pp. 267-305.
|
| 1045 |
+
|
| 1046 |
+
Examples
|
| 1047 |
+
--------
|
| 1048 |
+
>>> import numpy as np
|
| 1049 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1050 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1051 |
+
>>> rng = np.random.default_rng(seed=123)
|
| 1052 |
+
|
| 1053 |
+
The mean of a set of transforms is the same as the mean of the
|
| 1054 |
+
translation and rotation components:
|
| 1055 |
+
|
| 1056 |
+
>>> t = rng.random((4, 3))
|
| 1057 |
+
>>> r = R.random(4, rng=rng)
|
| 1058 |
+
>>> tf = Tf.from_components(t, r)
|
| 1059 |
+
>>> tf.mean().as_matrix()
|
| 1060 |
+
array([[ 0.61593485, -0.74508342, 0.25588075, 0.66999034],
|
| 1061 |
+
[-0.59353615, -0.65246765, -0.47116962, 0.25481794],
|
| 1062 |
+
[ 0.51801458, 0.13833531, -0.84411151, 0.52429339],
|
| 1063 |
+
[0., 0., 0., 1.]])
|
| 1064 |
+
>>> Tf.from_components(t.mean(axis=0), r.mean()).as_matrix()
|
| 1065 |
+
array([[ 0.61593485, -0.74508342, 0.25588075, 0.66999034],
|
| 1066 |
+
[-0.59353615, -0.65246765, -0.47116962, 0.25481794],
|
| 1067 |
+
[ 0.51801458, 0.13833531, -0.84411151, 0.52429339],
|
| 1068 |
+
[0., 0., 0., 1.]])
|
| 1069 |
+
"""
|
| 1070 |
+
mean = self._backend.mean(self._matrix, weights=weights, axis=axis)
|
| 1071 |
+
return RigidTransform._from_raw_matrix(mean, xp=self._xp,
|
| 1072 |
+
backend=self._backend)
|
| 1073 |
+
|
| 1074 |
+
@xp_capabilities(
|
| 1075 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1076 |
+
)
|
| 1077 |
+
def as_matrix(self) -> Array:
|
| 1078 |
+
"""Return a copy of the matrix representation of the transform.
|
| 1079 |
+
|
| 1080 |
+
4x4 rigid transformation matrices are of the form::
|
| 1081 |
+
|
| 1082 |
+
[ tx]
|
| 1083 |
+
[ R ty]
|
| 1084 |
+
[ tz]
|
| 1085 |
+
[ 0 0 0 1]
|
| 1086 |
+
|
| 1087 |
+
where ``R`` is a 3x3 orthonormal rotation matrix and
|
| 1088 |
+
``t = [tx, ty, tz]`` is a 3x1 translation vector.
|
| 1089 |
+
|
| 1090 |
+
Returns
|
| 1091 |
+
-------
|
| 1092 |
+
matrix : numpy.ndarray, shape (..., 4, 4)
|
| 1093 |
+
Transformation matrices with the same leading dimensions as the transform.
|
| 1094 |
+
|
| 1095 |
+
Examples
|
| 1096 |
+
--------
|
| 1097 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1098 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1099 |
+
>>> import numpy as np
|
| 1100 |
+
|
| 1101 |
+
A transformation matrix is a 4x4 matrix formed from a 3x3 rotation
|
| 1102 |
+
matrix and a 3x1 translation vector:
|
| 1103 |
+
|
| 1104 |
+
>>> t = np.array([2, 3, 4])
|
| 1105 |
+
>>> r = R.from_matrix([[0, 0, 1],
|
| 1106 |
+
... [1, 0, 0],
|
| 1107 |
+
... [0, 1, 0]])
|
| 1108 |
+
>>> tf = Tf.from_components(t, r)
|
| 1109 |
+
>>> tf.as_matrix()
|
| 1110 |
+
array([[ 0., 0., 1., 2.],
|
| 1111 |
+
[ 1., 0., 0., 3.],
|
| 1112 |
+
[ 0., 1., 0., 4.],
|
| 1113 |
+
[ 0., 0., 0., 1.]])
|
| 1114 |
+
|
| 1115 |
+
>>> Tf.identity(2).as_matrix()
|
| 1116 |
+
array([[[1., 0., 0., 0.],
|
| 1117 |
+
[0., 1., 0., 0.],
|
| 1118 |
+
[0., 0., 1., 0.],
|
| 1119 |
+
[0., 0., 0., 1.]],
|
| 1120 |
+
[[1., 0., 0., 0.],
|
| 1121 |
+
[0., 1., 0., 0.],
|
| 1122 |
+
[0., 0., 1., 0.],
|
| 1123 |
+
[0., 0., 0., 1.]]])
|
| 1124 |
+
"""
|
| 1125 |
+
matrix = self._xp.asarray(self._matrix, copy=True)
|
| 1126 |
+
if self._single:
|
| 1127 |
+
return matrix[0, ...]
|
| 1128 |
+
return matrix
|
| 1129 |
+
|
| 1130 |
+
@xp_capabilities(
|
| 1131 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1132 |
+
)
|
| 1133 |
+
def as_components(self) -> tuple[Array, Rotation]:
|
| 1134 |
+
"""Return the translation and rotation components of the transform,
|
| 1135 |
+
where the rotation is applied first, followed by the translation.
|
| 1136 |
+
|
| 1137 |
+
4x4 rigid transformation matrices are of the form::
|
| 1138 |
+
|
| 1139 |
+
[ tx]
|
| 1140 |
+
[ R ty]
|
| 1141 |
+
[ tz]
|
| 1142 |
+
[ 0 0 0 1]
|
| 1143 |
+
|
| 1144 |
+
Where ``R`` is a 3x3 orthonormal rotation matrix and
|
| 1145 |
+
``t = [tx, ty, tz]`` is a 3x1 translation vector. This function
|
| 1146 |
+
returns the rotation corresponding to this rotation matrix
|
| 1147 |
+
``r = Rotation.from_matrix(R)`` and the translation vector ``t``.
|
| 1148 |
+
|
| 1149 |
+
When applying a transform ``tf`` to a vector ``v``, the result is the same
|
| 1150 |
+
as if the rotation and translation components were applied to the vector
|
| 1151 |
+
with the following operation:
|
| 1152 |
+
``tf.apply(v) == translation + rotation.apply(v)``.
|
| 1153 |
+
|
| 1154 |
+
Returns
|
| 1155 |
+
-------
|
| 1156 |
+
translation : numpy.ndarray, shape (..., 3)
|
| 1157 |
+
The translation of the transform.
|
| 1158 |
+
rotation : `Rotation` instance
|
| 1159 |
+
The rotation of the transform.
|
| 1160 |
+
|
| 1161 |
+
Examples
|
| 1162 |
+
--------
|
| 1163 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1164 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1165 |
+
>>> import numpy as np
|
| 1166 |
+
|
| 1167 |
+
Recover the rotation and translation from a transform:
|
| 1168 |
+
|
| 1169 |
+
>>> t = np.array([2, 3, 4])
|
| 1170 |
+
>>> r = R.from_matrix([[0, 0, 1],
|
| 1171 |
+
... [1, 0, 0],
|
| 1172 |
+
... [0, 1, 0]])
|
| 1173 |
+
>>> tf = Tf.from_components(t, r)
|
| 1174 |
+
>>> t, r = tf.as_components()
|
| 1175 |
+
>>> t
|
| 1176 |
+
array([2., 3., 4.])
|
| 1177 |
+
>>> r.as_matrix()
|
| 1178 |
+
array([[0., 0., 1.],
|
| 1179 |
+
[1., 0., 0.],
|
| 1180 |
+
[0., 1., 0.]])
|
| 1181 |
+
|
| 1182 |
+
The transform applied to a vector is equivalent to the rotation applied
|
| 1183 |
+
to the vector, followed by the translation:
|
| 1184 |
+
|
| 1185 |
+
>>> t + r.apply([1, 0, 0])
|
| 1186 |
+
array([2., 4., 4.])
|
| 1187 |
+
>>> tf.apply([1, 0, 0])
|
| 1188 |
+
array([2., 4., 4.])
|
| 1189 |
+
"""
|
| 1190 |
+
return self.translation, self.rotation
|
| 1191 |
+
|
| 1192 |
+
@xp_capabilities(
|
| 1193 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1194 |
+
)
|
| 1195 |
+
def as_exp_coords(self) -> Array:
|
| 1196 |
+
"""Return the exponential coordinates of the transform.
|
| 1197 |
+
|
| 1198 |
+
This implements the logarithmic map that converts SE(3) to 6-dimensional
|
| 1199 |
+
real vectors.
|
| 1200 |
+
|
| 1201 |
+
This is an inverse of `from_exp_coords` where details on the mapping can
|
| 1202 |
+
be found.
|
| 1203 |
+
|
| 1204 |
+
Returns
|
| 1205 |
+
-------
|
| 1206 |
+
exp_coords : numpy.ndarray, shape (..., 6)
|
| 1207 |
+
Exponential coordinate vectors with the same leading dimensions as the
|
| 1208 |
+
transform. The first three components define the rotation and the last
|
| 1209 |
+
three components define the translation.
|
| 1210 |
+
|
| 1211 |
+
Examples
|
| 1212 |
+
--------
|
| 1213 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1214 |
+
>>> import numpy as np
|
| 1215 |
+
|
| 1216 |
+
Get exponential coordinates of the identity matrix:
|
| 1217 |
+
|
| 1218 |
+
>>> Tf.identity().as_exp_coords()
|
| 1219 |
+
array([0., 0., 0., 0., 0., 0.])
|
| 1220 |
+
"""
|
| 1221 |
+
exp_coords = self._backend.as_exp_coords(self._matrix)
|
| 1222 |
+
if self._single:
|
| 1223 |
+
exp_coords = exp_coords[0, ...]
|
| 1224 |
+
return exp_coords
|
| 1225 |
+
|
| 1226 |
+
@xp_capabilities(
|
| 1227 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1228 |
+
)
|
| 1229 |
+
def as_dual_quat(self, *, scalar_first: bool = False) -> Array:
|
| 1230 |
+
"""Return the dual quaternion representation of the transform.
|
| 1231 |
+
|
| 1232 |
+
Unit dual quaternions encode orientation in a real unit quaternion
|
| 1233 |
+
and translation in a dual quaternion. There is a double cover, i.e.,
|
| 1234 |
+
the unit dual quaternions q and -q represent the same transform.
|
| 1235 |
+
|
| 1236 |
+
Parameters
|
| 1237 |
+
----------
|
| 1238 |
+
scalar_first : bool, optional
|
| 1239 |
+
Whether the scalar component goes first or last in the two
|
| 1240 |
+
individual quaternions that represent the real and the dual part.
|
| 1241 |
+
Default is False, i.e. the scalar-last order is used.
|
| 1242 |
+
|
| 1243 |
+
Returns
|
| 1244 |
+
-------
|
| 1245 |
+
dual_quat : numpy.ndarray, shape (..., 8)
|
| 1246 |
+
Unit dual quaternion vectors with the same leading dimensions as the
|
| 1247 |
+
transform. The real part is stored in the first four components and the
|
| 1248 |
+
dual part in the last four components.
|
| 1249 |
+
|
| 1250 |
+
Examples
|
| 1251 |
+
--------
|
| 1252 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1253 |
+
>>> import numpy as np
|
| 1254 |
+
|
| 1255 |
+
Get identity dual quaternion (we use scalar-last by default):
|
| 1256 |
+
|
| 1257 |
+
>>> Tf.identity().as_dual_quat()
|
| 1258 |
+
array([0., 0., 0., 1., 0., 0., 0., 0.])
|
| 1259 |
+
|
| 1260 |
+
When we want to use the scalar-first convention, we use the argument:
|
| 1261 |
+
|
| 1262 |
+
>>> Tf.identity().as_dual_quat(scalar_first=True)
|
| 1263 |
+
array([1., 0., 0., 0., 0., 0., 0., 0.])
|
| 1264 |
+
"""
|
| 1265 |
+
dual_quat = self._backend.as_dual_quat(self._matrix, scalar_first=scalar_first)
|
| 1266 |
+
if self._single:
|
| 1267 |
+
dual_quat = dual_quat[0]
|
| 1268 |
+
return dual_quat
|
| 1269 |
+
|
| 1270 |
+
def __len__(self) -> int:
|
| 1271 |
+
"""Return the length of the leading transform dimension.
|
| 1272 |
+
|
| 1273 |
+
A transform can store an N-dimensional array of transforms. The length is the
|
| 1274 |
+
size of the first dimension of this array. If the transform is a single
|
| 1275 |
+
transform, the length is not defined and an error is raised.
|
| 1276 |
+
|
| 1277 |
+
Returns
|
| 1278 |
+
-------
|
| 1279 |
+
length : int
|
| 1280 |
+
The number of transforms in this object.
|
| 1281 |
+
|
| 1282 |
+
Raises
|
| 1283 |
+
------
|
| 1284 |
+
TypeError
|
| 1285 |
+
If the transform is a single transform.
|
| 1286 |
+
|
| 1287 |
+
Examples
|
| 1288 |
+
--------
|
| 1289 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1290 |
+
>>> import numpy as np
|
| 1291 |
+
>>> tf = Tf.identity(3)
|
| 1292 |
+
>>> len(tf)
|
| 1293 |
+
3
|
| 1294 |
+
|
| 1295 |
+
An N-dimensional array of transforms returns its first dimension size:
|
| 1296 |
+
|
| 1297 |
+
>>> t = np.ones((5, 2, 3, 1, 3))
|
| 1298 |
+
>>> tf = Tf.from_translation(t)
|
| 1299 |
+
>>> len(tf)
|
| 1300 |
+
5
|
| 1301 |
+
|
| 1302 |
+
A single transform has no length:
|
| 1303 |
+
|
| 1304 |
+
>>> tf = Tf.from_translation([1, 0, 0])
|
| 1305 |
+
>>> len(tf) # doctest: +IGNORE_EXCEPTION_DETAIL
|
| 1306 |
+
Traceback (most recent call last):
|
| 1307 |
+
...
|
| 1308 |
+
TypeError: Single transform has no len().
|
| 1309 |
+
"""
|
| 1310 |
+
# We don't use self._single here because we also want to raise an error for
|
| 1311 |
+
# Array API backends that call len() on single RigidTransform objects.
|
| 1312 |
+
if self.single:
|
| 1313 |
+
raise TypeError("Single transform has no len")
|
| 1314 |
+
return self._matrix.shape[0]
|
| 1315 |
+
|
| 1316 |
+
@xp_capabilities(
|
| 1317 |
+
jax_jit=False,
|
| 1318 |
+
skip_backends=[("dask.array", "cannot handle zero-length rigid transforms")],
|
| 1319 |
+
)
|
| 1320 |
+
def __getitem__(
|
| 1321 |
+
self, indexer: int | slice | EllipsisType | None | ArrayLike
|
| 1322 |
+
) -> RigidTransform:
|
| 1323 |
+
"""Extract transform(s) at given index(es) from this object.
|
| 1324 |
+
|
| 1325 |
+
Creates a new `RigidTransform` instance containing a subset of
|
| 1326 |
+
transforms stored in this object.
|
| 1327 |
+
|
| 1328 |
+
Parameters
|
| 1329 |
+
----------
|
| 1330 |
+
indexer : int or slice or array_like
|
| 1331 |
+
Specifies which transform(s) to extract. A single indexer must be
|
| 1332 |
+
specified, i.e. as if indexing a 1 dimensional array or list.
|
| 1333 |
+
|
| 1334 |
+
Returns
|
| 1335 |
+
-------
|
| 1336 |
+
transform : `RigidTransform` instance
|
| 1337 |
+
Contains
|
| 1338 |
+
- a single transform, if `indexer` is a single index
|
| 1339 |
+
- a stack of transform(s), if `indexer` is a slice, or an index
|
| 1340 |
+
array.
|
| 1341 |
+
|
| 1342 |
+
Raises
|
| 1343 |
+
------
|
| 1344 |
+
TypeError
|
| 1345 |
+
If the transform is a single transform.
|
| 1346 |
+
|
| 1347 |
+
Examples
|
| 1348 |
+
--------
|
| 1349 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1350 |
+
>>> t = [[0, 0, 0], [1, 0, 0], [2, 0, 0]] # 3 translations
|
| 1351 |
+
>>> tf = Tf.from_translation(t)
|
| 1352 |
+
|
| 1353 |
+
A single index returns a single transform:
|
| 1354 |
+
|
| 1355 |
+
>>> tf[0].as_matrix()
|
| 1356 |
+
array([[1., 0., 0., 0.],
|
| 1357 |
+
[0., 1., 0., 0.],
|
| 1358 |
+
[0., 0., 1., 0.],
|
| 1359 |
+
[0., 0., 0., 1.]])
|
| 1360 |
+
|
| 1361 |
+
A slice returns a stack of transforms:
|
| 1362 |
+
|
| 1363 |
+
>>> tf[1:3].translation
|
| 1364 |
+
array([[1., 0., 0.],
|
| 1365 |
+
[2., 0., 0.]])
|
| 1366 |
+
|
| 1367 |
+
An index array returns a stack of transforms:
|
| 1368 |
+
|
| 1369 |
+
>>> tf[[0, 2]].translation
|
| 1370 |
+
array([[0., 0., 0.],
|
| 1371 |
+
[2., 0., 0.]])
|
| 1372 |
+
"""
|
| 1373 |
+
if self.single:
|
| 1374 |
+
raise TypeError("Single transform is not subscriptable.")
|
| 1375 |
+
|
| 1376 |
+
is_array = isinstance(indexer, type(self._matrix))
|
| 1377 |
+
xp = self._xp
|
| 1378 |
+
# Masking is only specified in the Array API when the array is the sole index
|
| 1379 |
+
# This special case handling is necessary to support boolean indexing and
|
| 1380 |
+
# integer array indexing with take (see
|
| 1381 |
+
# https://github.com/data-apis/array-api/pull/900#issuecomment-2674432480)
|
| 1382 |
+
# Ideally we would converge to [indexer, ...] indexing, but this is not
|
| 1383 |
+
# supported for now.
|
| 1384 |
+
if is_array and indexer.dtype == xp.bool:
|
| 1385 |
+
return RigidTransform(self._matrix[indexer], normalize=False)
|
| 1386 |
+
if is_array and xp.isdtype(indexer.dtype, "integral"):
|
| 1387 |
+
if self._matrix.shape[0] == 0:
|
| 1388 |
+
raise IndexError("cannot take from an empty array")
|
| 1389 |
+
return RigidTransform(
|
| 1390 |
+
xp.take(self._matrix, indexer, axis=0), normalize=False
|
| 1391 |
+
)
|
| 1392 |
+
return RigidTransform(self._matrix[indexer, ...], normalize=False)
|
| 1393 |
+
|
| 1394 |
+
@xp_capabilities(
|
| 1395 |
+
jax_jit=False,
|
| 1396 |
+
skip_backends=[("dask.array", "cannot handle zero-length rigid transforms")],
|
| 1397 |
+
)
|
| 1398 |
+
def __setitem__(
|
| 1399 |
+
self,
|
| 1400 |
+
indexer: int | slice | EllipsisType | None | ArrayLike,
|
| 1401 |
+
value: RigidTransform,
|
| 1402 |
+
):
|
| 1403 |
+
"""Set transform(s) at given index(es) in this object.
|
| 1404 |
+
|
| 1405 |
+
Parameters
|
| 1406 |
+
----------
|
| 1407 |
+
indexer : int or slice or array_like
|
| 1408 |
+
Specifies which transform(s) to replace. A single indexer must be
|
| 1409 |
+
specified, i.e. as if indexing a 1 dimensional array or list.
|
| 1410 |
+
|
| 1411 |
+
value : `RigidTransform` instance
|
| 1412 |
+
The transform(s) to set.
|
| 1413 |
+
|
| 1414 |
+
Raises
|
| 1415 |
+
------
|
| 1416 |
+
TypeError
|
| 1417 |
+
If the transform is a single transform.
|
| 1418 |
+
|
| 1419 |
+
Examples
|
| 1420 |
+
--------
|
| 1421 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1422 |
+
>>> t = [[0, 0, 0], [1, 0, 0], [2, 0, 0]] # 3 translations
|
| 1423 |
+
>>> tf = Tf.from_translation(t)
|
| 1424 |
+
|
| 1425 |
+
Set a single transform:
|
| 1426 |
+
|
| 1427 |
+
>>> tf[0] = Tf.from_translation([9, 9, 9])
|
| 1428 |
+
>>> tf.translation
|
| 1429 |
+
array([[9., 9., 9.],
|
| 1430 |
+
[1., 0., 0.],
|
| 1431 |
+
[2., 0., 0.]])
|
| 1432 |
+
"""
|
| 1433 |
+
if self.single:
|
| 1434 |
+
raise TypeError("Single transform is not subscriptable.")
|
| 1435 |
+
|
| 1436 |
+
if not isinstance(value, RigidTransform):
|
| 1437 |
+
raise TypeError("value must be a RigidTransform object")
|
| 1438 |
+
|
| 1439 |
+
self._matrix = self._backend.setitem(self._matrix, indexer, value.as_matrix())
|
| 1440 |
+
|
| 1441 |
+
@xp_capabilities(
|
| 1442 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1443 |
+
)
|
| 1444 |
+
def __mul__(self, other: RigidTransform) -> RigidTransform | NotImplementedType:
|
| 1445 |
+
"""Compose this transform with the other.
|
| 1446 |
+
|
| 1447 |
+
If ``p`` and ``q`` are two transforms, then the composition of '``q``
|
| 1448 |
+
followed by ``p``' is equivalent to ``p * q``. In terms of
|
| 1449 |
+
transformation matrices, the composition can be expressed as
|
| 1450 |
+
``p.as_matrix() @ q.as_matrix()``.
|
| 1451 |
+
|
| 1452 |
+
In terms of translations and rotations, the composition when applied to
|
| 1453 |
+
a vector ``v`` is equivalent to
|
| 1454 |
+
``p.translation + p.rotation.apply(q.translation)
|
| 1455 |
+
+ (p.rotation * q.rotation).apply(v)``.
|
| 1456 |
+
|
| 1457 |
+
This function supports composition of multiple transforms at a time using
|
| 1458 |
+
broadcasting rules. The resulting shape for two `RigidTransform` instances
|
| 1459 |
+
``p`` and ``q`` is `np.broadcast_shapes(p.shape, q.shape)`.
|
| 1460 |
+
|
| 1461 |
+
Parameters
|
| 1462 |
+
----------
|
| 1463 |
+
other : `RigidTransform` instance
|
| 1464 |
+
Transform(s) to be composed with this one. The shapes must be
|
| 1465 |
+
broadcastable.
|
| 1466 |
+
|
| 1467 |
+
Returns
|
| 1468 |
+
-------
|
| 1469 |
+
`RigidTransform` instance
|
| 1470 |
+
The composed transform.
|
| 1471 |
+
|
| 1472 |
+
Examples
|
| 1473 |
+
--------
|
| 1474 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1475 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1476 |
+
>>> import numpy as np
|
| 1477 |
+
|
| 1478 |
+
Compose two transforms:
|
| 1479 |
+
|
| 1480 |
+
>>> tf1 = Tf.from_translation([1, 0, 0])
|
| 1481 |
+
>>> tf2 = Tf.from_translation([0, 1, 0])
|
| 1482 |
+
>>> tf = tf1 * tf2
|
| 1483 |
+
>>> tf.translation
|
| 1484 |
+
array([1., 1., 0.])
|
| 1485 |
+
>>> tf.single
|
| 1486 |
+
True
|
| 1487 |
+
|
| 1488 |
+
When applied to a vector, the composition of two transforms is applied
|
| 1489 |
+
in right-to-left order.
|
| 1490 |
+
|
| 1491 |
+
>>> t1, r1 = [1, 2, 3], R.from_euler('z', 60, degrees=True)
|
| 1492 |
+
>>> t2, r2 = [0, 1, 0], R.from_euler('x', 30, degrees=True)
|
| 1493 |
+
>>> tf1 = Tf.from_components(t1, r1)
|
| 1494 |
+
>>> tf2 = Tf.from_components(t2, r2)
|
| 1495 |
+
>>> tf = tf1 * tf2
|
| 1496 |
+
>>> tf.apply([1, 0, 0])
|
| 1497 |
+
array([0.6339746, 3.3660254, 3. ])
|
| 1498 |
+
>>> tf1.apply(tf2.apply([1, 0, 0]))
|
| 1499 |
+
array([0.6339746, 3.3660254, 3. ])
|
| 1500 |
+
|
| 1501 |
+
When at least one of the transforms is not single, the result is a stack
|
| 1502 |
+
of transforms.
|
| 1503 |
+
|
| 1504 |
+
>>> tf1 = Tf.from_translation([1, 0, 0])
|
| 1505 |
+
>>> tf2 = Tf.from_translation([[0, 2, 0], [0, 0, 3]])
|
| 1506 |
+
>>> tf = tf1 * tf2
|
| 1507 |
+
>>> tf.translation
|
| 1508 |
+
array([[1., 2., 0.],
|
| 1509 |
+
[1., 0., 3.]])
|
| 1510 |
+
>>> tf.single
|
| 1511 |
+
False
|
| 1512 |
+
>>> len(tf)
|
| 1513 |
+
2
|
| 1514 |
+
|
| 1515 |
+
Broadcasting rules apply when composing multiple transforms at a time.
|
| 1516 |
+
|
| 1517 |
+
>>> tf1 = Tf.from_translation(np.ones((5, 1, 3))) # Shape (5, 1, 3)
|
| 1518 |
+
>>> tf2 = Tf.from_translation(np.ones((1, 4, 3))) # Shape (1, 4, 3)
|
| 1519 |
+
>>> tf = tf1 * tf2 # Shape (5, 4, 3)
|
| 1520 |
+
>>> tf.translation.shape
|
| 1521 |
+
(5, 4, 3)
|
| 1522 |
+
"""
|
| 1523 |
+
if not isinstance(other, RigidTransform):
|
| 1524 |
+
# If other is not a RigidTransform, we return NotImplemented to allow other
|
| 1525 |
+
# types to implement __rmul__
|
| 1526 |
+
return NotImplemented
|
| 1527 |
+
if not broadcastable(self._matrix.shape, other._matrix.shape):
|
| 1528 |
+
raise ValueError(
|
| 1529 |
+
f"Cannot broadcast {self._matrix.shape[:-2]} transforms in "
|
| 1530 |
+
f"first to {other._matrix.shape[:-2]} transforms in second object."
|
| 1531 |
+
)
|
| 1532 |
+
cython_compatible = self._matrix.ndim < 4 and other._matrix.ndim < 4
|
| 1533 |
+
backend = select_backend(self._xp, cython_compatible=cython_compatible)
|
| 1534 |
+
matrix = backend.compose_transforms(self._matrix, other._matrix)
|
| 1535 |
+
# Only necessary for cython. Array API broadcasting handles this by default
|
| 1536 |
+
if self._single and other._single:
|
| 1537 |
+
matrix = matrix[0, ...]
|
| 1538 |
+
return RigidTransform(matrix, normalize=True, copy=False)
|
| 1539 |
+
|
| 1540 |
+
@xp_capabilities(
|
| 1541 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1542 |
+
)
|
| 1543 |
+
def __pow__(self, n: float) -> RigidTransform:
|
| 1544 |
+
"""Compose this transform with itself `n` times.
|
| 1545 |
+
|
| 1546 |
+
A rigid transform `p` when raised to non-integer powers can be thought
|
| 1547 |
+
of as finding a fraction of the transformation. For example, a power of
|
| 1548 |
+
0.5 finds a "halfway" transform from the identity to `p`.
|
| 1549 |
+
|
| 1550 |
+
This is implemented by applying screw linear interpolation (ScLERP)
|
| 1551 |
+
between `p` and the identity transform, where the angle of the rotation
|
| 1552 |
+
component is scaled by `n`, and the translation is proportionally
|
| 1553 |
+
adjusted along the screw axis.
|
| 1554 |
+
|
| 1555 |
+
``q = p ** n`` can also be expressed as
|
| 1556 |
+
``q = RigidTransform.from_exp_coords(p.as_exp_coords() * n)``.
|
| 1557 |
+
|
| 1558 |
+
If `n` is negative, then the transform is inverted before the power
|
| 1559 |
+
is applied. In other words, ``p ** -abs(n) == p.inv() ** abs(n)``.
|
| 1560 |
+
|
| 1561 |
+
Parameters
|
| 1562 |
+
----------
|
| 1563 |
+
n : float
|
| 1564 |
+
The number of times to compose the transform with itself.
|
| 1565 |
+
|
| 1566 |
+
Returns
|
| 1567 |
+
-------
|
| 1568 |
+
`RigidTransform` instance
|
| 1569 |
+
If the input Rotation `p` contains `N` multiple rotations, then
|
| 1570 |
+
the output will contain `N` rotations where the `i` th rotation
|
| 1571 |
+
is equal to ``p[i] ** n``.
|
| 1572 |
+
|
| 1573 |
+
Notes
|
| 1574 |
+
-----
|
| 1575 |
+
There are three notable cases: if ``n == 1`` then a copy of the original
|
| 1576 |
+
transform is returned, if ``n == 0`` then the identity transform is
|
| 1577 |
+
returned, and if ``n == -1`` then the inverse transform is returned.
|
| 1578 |
+
|
| 1579 |
+
Note that fractional powers ``n`` which effectively take a root of
|
| 1580 |
+
rotation, do so using the shortest path smallest representation of that
|
| 1581 |
+
angle (the principal root). This means that powers of ``n`` and ``1/n``
|
| 1582 |
+
are not necessarily inverses of each other. For example, a 0.5 power of
|
| 1583 |
+
a +240 degree rotation will be calculated as the 0.5 power of a -120
|
| 1584 |
+
degree rotation, with the result being a rotation of -60 rather than
|
| 1585 |
+
+120 degrees.
|
| 1586 |
+
|
| 1587 |
+
Examples
|
| 1588 |
+
--------
|
| 1589 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1590 |
+
>>> import numpy as np
|
| 1591 |
+
|
| 1592 |
+
A power of 2 returns the transform composed with itself:
|
| 1593 |
+
|
| 1594 |
+
>>> tf = Tf.from_translation([1, 2, 3])
|
| 1595 |
+
>>> (tf ** 2).translation
|
| 1596 |
+
array([2., 4., 6.])
|
| 1597 |
+
>>> (tf ** 2).as_matrix()
|
| 1598 |
+
array([[1., 0., 0., 2.],
|
| 1599 |
+
[0., 1., 0., 4.],
|
| 1600 |
+
[0., 0., 1., 6.],
|
| 1601 |
+
[0., 0., 0., 1.]])
|
| 1602 |
+
|
| 1603 |
+
A negative power returns the inverse of the transform raised to the
|
| 1604 |
+
absolute value of `n`:
|
| 1605 |
+
|
| 1606 |
+
>>> (tf ** -2).translation
|
| 1607 |
+
array([-2., -4., -6.])
|
| 1608 |
+
>>> np.allclose((tf ** -2).as_matrix(), (tf.inv() ** 2).as_matrix(),
|
| 1609 |
+
... atol=1e-12)
|
| 1610 |
+
True
|
| 1611 |
+
|
| 1612 |
+
A power of 0 returns the identity transform:
|
| 1613 |
+
|
| 1614 |
+
>>> (tf ** 0).as_matrix()
|
| 1615 |
+
array([[1., 0., 0., 0.],
|
| 1616 |
+
[0., 1., 0., 0.],
|
| 1617 |
+
[0., 0., 1., 0.],
|
| 1618 |
+
[0., 0., 0., 1.]])
|
| 1619 |
+
|
| 1620 |
+
A power of 1 returns a copy of the original transform:
|
| 1621 |
+
|
| 1622 |
+
>>> (tf ** 1).as_matrix()
|
| 1623 |
+
array([[1., 0., 0., 1.],
|
| 1624 |
+
[0., 1., 0., 2.],
|
| 1625 |
+
[0., 0., 1., 3.],
|
| 1626 |
+
[0., 0., 0., 1.]])
|
| 1627 |
+
|
| 1628 |
+
A fractional power returns a transform with a scaled rotation and
|
| 1629 |
+
translated along the screw axis. Here we take the square root of the
|
| 1630 |
+
transform, which when squared recovers the original transform:
|
| 1631 |
+
|
| 1632 |
+
>>> tf_half = (tf ** 0.5)
|
| 1633 |
+
>>> tf_half.translation
|
| 1634 |
+
array([0.5, 1., 1.5])
|
| 1635 |
+
>>> (tf_half ** 2).as_matrix()
|
| 1636 |
+
array([[1., 0., 0., 1.],
|
| 1637 |
+
[0., 1., 0., 2.],
|
| 1638 |
+
[0., 0., 1., 3.],
|
| 1639 |
+
[0., 0., 0., 1.]])
|
| 1640 |
+
"""
|
| 1641 |
+
matrix = self._backend.pow(self._matrix, n)
|
| 1642 |
+
if self._single:
|
| 1643 |
+
matrix = matrix[0, ...]
|
| 1644 |
+
return RigidTransform._from_raw_matrix(matrix, self._xp, self._backend)
|
| 1645 |
+
|
| 1646 |
+
@xp_capabilities(
|
| 1647 |
+
skip_backends=[("dask.array", "missing linalg.cross/det functions")]
|
| 1648 |
+
)
|
| 1649 |
+
def inv(self) -> RigidTransform:
|
| 1650 |
+
"""Invert this transform.
|
| 1651 |
+
|
| 1652 |
+
Composition of a transform with its inverse results in an identity
|
| 1653 |
+
transform.
|
| 1654 |
+
|
| 1655 |
+
A rigid transform is a composition of a rotation and a translation,
|
| 1656 |
+
where the rotation is applied first, followed by the translation. So the
|
| 1657 |
+
inverse transform is equivalent to the inverse translation followed by
|
| 1658 |
+
the inverse rotation.
|
| 1659 |
+
|
| 1660 |
+
Returns
|
| 1661 |
+
-------
|
| 1662 |
+
`RigidTransform` instance
|
| 1663 |
+
The inverse of this transform.
|
| 1664 |
+
|
| 1665 |
+
Examples
|
| 1666 |
+
--------
|
| 1667 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1668 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1669 |
+
>>> import numpy as np
|
| 1670 |
+
|
| 1671 |
+
A transform composed with its inverse results in an identity transform:
|
| 1672 |
+
|
| 1673 |
+
>>> rng = np.random.default_rng(seed=123)
|
| 1674 |
+
>>> t = rng.random(3)
|
| 1675 |
+
>>> r = R.random(rng=rng)
|
| 1676 |
+
>>> tf = Tf.from_components(t, r)
|
| 1677 |
+
>>> tf.as_matrix()
|
| 1678 |
+
array([[-0.45431291, 0.67276178, -0.58394466, 0.68235186],
|
| 1679 |
+
[-0.23272031, 0.54310598, 0.80676958, 0.05382102],
|
| 1680 |
+
[ 0.85990758, 0.50242162, -0.09017473, 0.22035987],
|
| 1681 |
+
[ 0. , 0. , 0. , 1. ]])
|
| 1682 |
+
|
| 1683 |
+
>>> (tf.inv() * tf).as_matrix()
|
| 1684 |
+
array([[[1., 0., 0., 0.],
|
| 1685 |
+
[0., 1., 0., 0.],
|
| 1686 |
+
[0., 0., 1., 0.],
|
| 1687 |
+
[0., 0., 0., 1.]]])
|
| 1688 |
+
|
| 1689 |
+
The inverse rigid transform is the same as the inverse translation
|
| 1690 |
+
followed by the inverse rotation:
|
| 1691 |
+
|
| 1692 |
+
>>> t, r = tf.as_components()
|
| 1693 |
+
>>> r_inv = r.inv() # inverse rotation
|
| 1694 |
+
>>> t_inv = -t # inverse translation
|
| 1695 |
+
>>> tf_r_inv = Tf.from_rotation(r_inv)
|
| 1696 |
+
>>> tf_t_inv = Tf.from_translation(t_inv)
|
| 1697 |
+
>>> np.allclose((tf_r_inv * tf_t_inv).as_matrix(),
|
| 1698 |
+
... tf.inv().as_matrix(),
|
| 1699 |
+
... atol=1e-12)
|
| 1700 |
+
True
|
| 1701 |
+
>>> (tf_r_inv * tf_t_inv * tf).as_matrix()
|
| 1702 |
+
array([[[1., 0., 0., 0.],
|
| 1703 |
+
[0., 1., 0., 0.],
|
| 1704 |
+
[0., 0., 1., 0.],
|
| 1705 |
+
[0., 0., 0., 1.]]])
|
| 1706 |
+
"""
|
| 1707 |
+
matrix = self._backend.inv(self._matrix)
|
| 1708 |
+
if self._single:
|
| 1709 |
+
matrix = matrix[0, ...]
|
| 1710 |
+
return RigidTransform._from_raw_matrix(matrix, self._xp, self._backend)
|
| 1711 |
+
|
| 1712 |
+
@xp_capabilities(
|
| 1713 |
+
skip_backends=[
|
| 1714 |
+
("dask.array", "missing linalg.cross/det functions"),
|
| 1715 |
+
("cupy", "missing .mT attribute in cupy<14.*"),
|
| 1716 |
+
]
|
| 1717 |
+
)
|
| 1718 |
+
def apply(self, vector: ArrayLike, inverse: bool = False) -> Array:
|
| 1719 |
+
"""Apply the transform to a vector.
|
| 1720 |
+
|
| 1721 |
+
If the original frame transforms to the final frame by this transform,
|
| 1722 |
+
then its application to a vector can be seen in two ways:
|
| 1723 |
+
|
| 1724 |
+
- As a projection of vector components expressed in the final frame
|
| 1725 |
+
to the original frame.
|
| 1726 |
+
- As the physical transformation of a vector being glued to the
|
| 1727 |
+
original frame as it transforms. In this case the vector
|
| 1728 |
+
components are expressed in the original frame before and after
|
| 1729 |
+
the transformation.
|
| 1730 |
+
|
| 1731 |
+
In terms of rotation matrices and translation vectors, this application
|
| 1732 |
+
is the same as
|
| 1733 |
+
``self.translation + self.rotation.as_matrix() @ vector``.
|
| 1734 |
+
|
| 1735 |
+
Parameters
|
| 1736 |
+
----------
|
| 1737 |
+
vector : array_like, shape (..., 3)
|
| 1738 |
+
Vector(s) to be transformed. Each vector[..., :] represents a 3D
|
| 1739 |
+
vector.
|
| 1740 |
+
inverse : bool, optional
|
| 1741 |
+
If True, the inverse of the transform is applied to the vector.
|
| 1742 |
+
|
| 1743 |
+
Returns
|
| 1744 |
+
-------
|
| 1745 |
+
transformed_vector : numpy.ndarray, shape (..., 3)
|
| 1746 |
+
The transformed vector(s) with shape determined by broadcasting
|
| 1747 |
+
the transform and vector shapes together.
|
| 1748 |
+
|
| 1749 |
+
Examples
|
| 1750 |
+
--------
|
| 1751 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1752 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1753 |
+
>>> import numpy as np
|
| 1754 |
+
|
| 1755 |
+
Apply a single transform to a vector. Here the transform is just a
|
| 1756 |
+
translation, so the result is the vector added to the translation
|
| 1757 |
+
vector.
|
| 1758 |
+
|
| 1759 |
+
>>> t = np.array([1, 2, 3])
|
| 1760 |
+
>>> tf = Tf.from_translation(t)
|
| 1761 |
+
>>> t + np.array([1, 0, 0])
|
| 1762 |
+
array([2, 2, 3])
|
| 1763 |
+
>>> tf.apply([1, 0, 0])
|
| 1764 |
+
array([2., 2., 3.])
|
| 1765 |
+
|
| 1766 |
+
Apply a single transform to a stack of vectors:
|
| 1767 |
+
|
| 1768 |
+
>>> tf.apply([[1, 0, 0], [0, 1, 0]])
|
| 1769 |
+
array([[2., 2., 3.],
|
| 1770 |
+
[1., 3., 3.]])
|
| 1771 |
+
|
| 1772 |
+
Apply the inverse of a transform to a vector, so the result is the
|
| 1773 |
+
negative of the translation vector added to the vector.
|
| 1774 |
+
|
| 1775 |
+
>>> -t + np.array([1, 0, 0])
|
| 1776 |
+
array([0, -2, -3])
|
| 1777 |
+
>>> tf.apply([1, 0, 0], inverse=True)
|
| 1778 |
+
array([0., -2., -3.])
|
| 1779 |
+
|
| 1780 |
+
Broadcasting is supported when applying multiple transforms to an N-dimensional
|
| 1781 |
+
array of vectors.
|
| 1782 |
+
|
| 1783 |
+
>>> tf = Tf.from_translation(np.ones((4, 5, 1, 3)))
|
| 1784 |
+
>>> vectors = np.zeros((2, 3))
|
| 1785 |
+
>>> tf.apply(vectors).shape
|
| 1786 |
+
(4, 5, 2, 3)
|
| 1787 |
+
|
| 1788 |
+
For transforms which are not just pure translations, applying it to a
|
| 1789 |
+
vector is the same as applying the rotation component to the vector and
|
| 1790 |
+
then adding the translation component.
|
| 1791 |
+
|
| 1792 |
+
>>> r = R.from_euler('z', 60, degrees=True)
|
| 1793 |
+
>>> tf = Tf.from_components(t, r)
|
| 1794 |
+
>>> t + r.apply([1, 0, 0])
|
| 1795 |
+
array([1.5, 2.8660254, 3. ])
|
| 1796 |
+
>>> tf.apply([1, 0, 0])
|
| 1797 |
+
array([1.5, 2.8660254, 3. ])
|
| 1798 |
+
|
| 1799 |
+
When applying the inverse of a transform, the result is the negative of
|
| 1800 |
+
the translation vector added to the vector, and then rotated by the
|
| 1801 |
+
inverse rotation.
|
| 1802 |
+
|
| 1803 |
+
>>> r.inv().apply(-t + np.array([1, 0, 0]))
|
| 1804 |
+
array([-1.73205081, -1. , -3. ])
|
| 1805 |
+
>>> tf.apply([1, 0, 0], inverse=True)
|
| 1806 |
+
array([-1.73205081, -1. , -3. ])
|
| 1807 |
+
"""
|
| 1808 |
+
# We do not use the cached xp here to catch cases where matrix and vector have
|
| 1809 |
+
# different xp instances.
|
| 1810 |
+
xp = array_namespace(self._matrix, vector)
|
| 1811 |
+
vector = xp.asarray(
|
| 1812 |
+
vector, dtype=self._matrix.dtype, device=device(self._matrix)
|
| 1813 |
+
)
|
| 1814 |
+
cython_compatible = self._matrix.ndim < 4 and vector.ndim < 3
|
| 1815 |
+
backend = select_backend(xp, cython_compatible=cython_compatible)
|
| 1816 |
+
result = backend.apply(self._matrix, vector, inverse)
|
| 1817 |
+
if self._single and vector.ndim == 1:
|
| 1818 |
+
result = result[0, ...]
|
| 1819 |
+
return result
|
| 1820 |
+
|
| 1821 |
+
@property
|
| 1822 |
+
def rotation(self) -> Rotation:
|
| 1823 |
+
"""Return the rotation component of the transform.
|
| 1824 |
+
|
| 1825 |
+
A transform is a composition of a rotation and a translation, such that
|
| 1826 |
+
when applied to a vector, the vector is first rotated and then
|
| 1827 |
+
translated. This property returns the rotation part of the transform.
|
| 1828 |
+
|
| 1829 |
+
Returns
|
| 1830 |
+
-------
|
| 1831 |
+
rotation : `Rotation` instance
|
| 1832 |
+
A single rotation or a stack of rotations.
|
| 1833 |
+
|
| 1834 |
+
Examples
|
| 1835 |
+
--------
|
| 1836 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1837 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1838 |
+
>>> import numpy as np
|
| 1839 |
+
|
| 1840 |
+
The rotation component is extracted from the transform:
|
| 1841 |
+
|
| 1842 |
+
>>> t = np.array([1, 0, 0])
|
| 1843 |
+
>>> r = R.random(3)
|
| 1844 |
+
>>> tf = Tf.from_components(t, r)
|
| 1845 |
+
>>> np.allclose(tf.rotation.as_matrix(), r.as_matrix())
|
| 1846 |
+
True
|
| 1847 |
+
"""
|
| 1848 |
+
if self._single:
|
| 1849 |
+
return Rotation.from_matrix(self._matrix[0, :3, :3])
|
| 1850 |
+
return Rotation.from_matrix(self._matrix[..., :3, :3])
|
| 1851 |
+
|
| 1852 |
+
@property
|
| 1853 |
+
def translation(self) -> Array:
|
| 1854 |
+
"""Return the translation component of the transform.
|
| 1855 |
+
|
| 1856 |
+
A transform is a composition of a rotation and a translation, such that
|
| 1857 |
+
when applied to a vector, the vector is first rotated and then
|
| 1858 |
+
translated. This property returns the translation part of the transform.
|
| 1859 |
+
|
| 1860 |
+
Returns
|
| 1861 |
+
-------
|
| 1862 |
+
translation : numpy.ndarray, shape (..., 3)
|
| 1863 |
+
Translation vectors with the same leading dimensions as the transform.
|
| 1864 |
+
|
| 1865 |
+
Examples
|
| 1866 |
+
--------
|
| 1867 |
+
>>> from scipy.spatial.transform import RigidTransform as Tf
|
| 1868 |
+
>>> from scipy.spatial.transform import Rotation as R
|
| 1869 |
+
>>> import numpy as np
|
| 1870 |
+
|
| 1871 |
+
The translation component is extracted from the transform:
|
| 1872 |
+
|
| 1873 |
+
>>> t = np.array([[1, 0, 0], [2, 0, 0], [3, 0, 0]])
|
| 1874 |
+
>>> r = R.random()
|
| 1875 |
+
>>> tf = Tf.from_components(t, r)
|
| 1876 |
+
>>> np.allclose(tf.translation, t)
|
| 1877 |
+
True
|
| 1878 |
+
"""
|
| 1879 |
+
if self._single:
|
| 1880 |
+
return self._xp.asarray(self._matrix[0, :3, 3], copy=True)
|
| 1881 |
+
return self._xp.asarray(self._matrix[..., :3, 3], copy=True)
|
| 1882 |
+
|
| 1883 |
+
@property
|
| 1884 |
+
def single(self) -> bool:
|
| 1885 |
+
"""Whether this instance represents a single transform.
|
| 1886 |
+
|
| 1887 |
+
Single transforms are not subscriptable, and do not have a length.
|
| 1888 |
+
|
| 1889 |
+
Returns
|
| 1890 |
+
-------
|
| 1891 |
+
single : bool
|
| 1892 |
+
True if this instance represents a single transform, False
|
| 1893 |
+
otherwise.
|
| 1894 |
+
"""
|
| 1895 |
+
return self._single or self._matrix.ndim == 2
|
| 1896 |
+
|
| 1897 |
+
@property
|
| 1898 |
+
def shape(self) -> tuple[int, ...]:
|
| 1899 |
+
"""The shape of the transform's leading dimensions."""
|
| 1900 |
+
if self._single or self._matrix.ndim == 2:
|
| 1901 |
+
return ()
|
| 1902 |
+
return self._matrix.shape[:-2]
|
| 1903 |
+
|
| 1904 |
+
def __reduce__(self) -> tuple[Callable, tuple]:
|
| 1905 |
+
"""Reduce the RigidTransform for pickling.
|
| 1906 |
+
|
| 1907 |
+
We store modules inside RigidTransforms which cannot be pickled. To circumvent
|
| 1908 |
+
this, we pickle only the matrix and restore the cached modules from the matrix
|
| 1909 |
+
type in `from_matrix`.
|
| 1910 |
+
"""
|
| 1911 |
+
matrix = self._matrix
|
| 1912 |
+
if self._single:
|
| 1913 |
+
matrix = matrix[0, ...]
|
| 1914 |
+
return (self.__class__.from_matrix, (matrix,))
|
| 1915 |
+
|
| 1916 |
+
@xp_capabilities()
|
| 1917 |
+
def __iter__(self) -> Iterator[RigidTransform]:
|
| 1918 |
+
"""Iterate over transforms."""
|
| 1919 |
+
if self._single or self._matrix.ndim == 2:
|
| 1920 |
+
raise TypeError("Single transform is not iterable.")
|
| 1921 |
+
# We return a generator that yields a new RigidTransform object for each
|
| 1922 |
+
# transform in the current object. We cannot rely on the default implementation
|
| 1923 |
+
# because jax will not raise an IndexError for out-of-bounds indices.
|
| 1924 |
+
for i in range(self._matrix.shape[0]):
|
| 1925 |
+
yield RigidTransform._from_raw_matrix(
|
| 1926 |
+
self._matrix[i, ...], self._xp, self._backend
|
| 1927 |
+
)
|
| 1928 |
+
|
| 1929 |
+
@staticmethod
|
| 1930 |
+
def _from_raw_matrix(
|
| 1931 |
+
matrix: Array, xp: ModuleType, backend: ModuleType | None = None
|
| 1932 |
+
) -> RigidTransform:
|
| 1933 |
+
"""Create a RigidTransform skipping all sanitization steps.
|
| 1934 |
+
|
| 1935 |
+
This method is is intended for internal, performant creation of RigidTransforms
|
| 1936 |
+
with matrices that are guaranteed to be valid.
|
| 1937 |
+
"""
|
| 1938 |
+
tf = RigidTransform.__new__(RigidTransform)
|
| 1939 |
+
tf._single = matrix.ndim == 2 and is_numpy(xp)
|
| 1940 |
+
if tf._single:
|
| 1941 |
+
matrix = xpx.atleast_nd(matrix, ndim=3, xp=xp)
|
| 1942 |
+
tf._matrix = matrix
|
| 1943 |
+
tf._xp = xp
|
| 1944 |
+
if backend is None:
|
| 1945 |
+
backend = select_backend(xp, matrix.ndim < 4)
|
| 1946 |
+
tf._backend = backend
|
| 1947 |
+
return tf
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_cy.cp312-win_amd64.dll.a
ADDED
|
Binary file (1.69 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_cy.cp312-win_amd64.pyd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8de630dfc038d90734a7f027bceb530bcd4cd41f713ca1a06ecade83511041ad
|
| 3 |
+
size 242688
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rigid_transform_xp.py
ADDED
|
@@ -0,0 +1,448 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from types import EllipsisType
|
| 2 |
+
|
| 3 |
+
from scipy._lib._array_api import (
|
| 4 |
+
array_namespace,
|
| 5 |
+
Array,
|
| 6 |
+
ArrayLike,
|
| 7 |
+
is_lazy_array,
|
| 8 |
+
xp_vector_norm,
|
| 9 |
+
xp_result_type,
|
| 10 |
+
xp_promote,
|
| 11 |
+
is_array_api_obj,
|
| 12 |
+
)
|
| 13 |
+
import scipy._lib.array_api_extra as xpx
|
| 14 |
+
from scipy.spatial.transform._rotation_xp import (
|
| 15 |
+
as_matrix as quat_as_matrix,
|
| 16 |
+
from_matrix as quat_from_matrix,
|
| 17 |
+
_from_matrix_orthogonal as quat_from_matrix_orthogonal,
|
| 18 |
+
from_rotvec as quat_from_rotvec,
|
| 19 |
+
as_rotvec as quat_as_rotvec,
|
| 20 |
+
compose_quat,
|
| 21 |
+
from_quat,
|
| 22 |
+
inv as quat_inv,
|
| 23 |
+
mean as quat_mean,
|
| 24 |
+
)
|
| 25 |
+
from scipy._lib.array_api_compat import device as xp_device
|
| 26 |
+
from scipy._lib._util import broadcastable
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def from_matrix(matrix: Array, normalize: bool = True, copy: bool = True) -> Array:
|
| 30 |
+
xp = array_namespace(matrix)
|
| 31 |
+
# Shape check should be done before calling this function
|
| 32 |
+
if normalize or copy:
|
| 33 |
+
matrix = xp.asarray(matrix, copy=True)
|
| 34 |
+
|
| 35 |
+
last_row_ok = xp.all(
|
| 36 |
+
matrix[..., 3, :] == xp.asarray([0, 0, 0, 1.0], device=xp_device(matrix)),
|
| 37 |
+
axis=-1,
|
| 38 |
+
)
|
| 39 |
+
lazy = is_lazy_array(matrix)
|
| 40 |
+
# We delay lazy branch checks until after normalization to avoid overwriting nans
|
| 41 |
+
# with the rotation matrix
|
| 42 |
+
if not lazy and xp.any(~last_row_ok):
|
| 43 |
+
if last_row_ok.shape == ():
|
| 44 |
+
idx = ()
|
| 45 |
+
else:
|
| 46 |
+
idx = tuple(int(i[0]) for i in xp.nonzero(~last_row_ok))
|
| 47 |
+
vals = matrix[idx + (3, ...)]
|
| 48 |
+
raise ValueError(
|
| 49 |
+
f"Expected last row of transformation matrix {idx} to be "
|
| 50 |
+
f"exactly [0, 0, 0, 1], got {vals}"
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# The quat_from_matrix() method orthogonalizes the rotation
|
| 54 |
+
# component of the transformation matrix. While this does have some
|
| 55 |
+
# overhead in converting a rotation matrix to a quaternion and back, it
|
| 56 |
+
# allows for skipping singular value decomposition for near-orthogonal
|
| 57 |
+
# matrices, which is a computationally expensive operation.
|
| 58 |
+
if normalize:
|
| 59 |
+
rotmat = quat_as_matrix(quat_from_matrix(matrix[..., :3, :3]))
|
| 60 |
+
matrix = xpx.at(matrix)[..., :3, :3].set(rotmat)
|
| 61 |
+
# Lazy branch matrix invalidation
|
| 62 |
+
if lazy:
|
| 63 |
+
matrix = xp.where(last_row_ok[..., None, None], matrix, xp.nan)
|
| 64 |
+
return matrix
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def from_rotation(quat: Array) -> Array:
|
| 68 |
+
xp = array_namespace(quat)
|
| 69 |
+
rotmat = quat_as_matrix(quat)
|
| 70 |
+
matrix = xp.zeros(
|
| 71 |
+
(*rotmat.shape[:-2], 4, 4), dtype=quat.dtype, device=xp_device(quat)
|
| 72 |
+
)
|
| 73 |
+
matrix = xpx.at(matrix)[..., :3, :3].set(rotmat)
|
| 74 |
+
matrix = xpx.at(matrix)[..., 3, 3].set(1)
|
| 75 |
+
return matrix
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def from_translation(translation: Array) -> Array:
|
| 79 |
+
xp = array_namespace(translation)
|
| 80 |
+
|
| 81 |
+
if translation.shape[-1] != 3:
|
| 82 |
+
raise ValueError(
|
| 83 |
+
f"Expected `translation` to have shape (..., 3), got {translation.shape}."
|
| 84 |
+
)
|
| 85 |
+
device = xp_device(translation)
|
| 86 |
+
dtype = xp_result_type(translation, force_floating=True, xp=xp)
|
| 87 |
+
eye = xp.eye(4, dtype=dtype, device=device)
|
| 88 |
+
|
| 89 |
+
matrix = xpx.atleast_nd(eye, ndim=translation.ndim + 1, xp=xp)
|
| 90 |
+
matrix = xp.zeros(
|
| 91 |
+
(*translation.shape[:-1], 4, 4),
|
| 92 |
+
dtype=dtype,
|
| 93 |
+
device=device,
|
| 94 |
+
)
|
| 95 |
+
matrix = xpx.at(matrix)[...].set(xp.eye(4, dtype=dtype, device=device))
|
| 96 |
+
matrix = xpx.at(matrix)[..., :3, 3].set(
|
| 97 |
+
xp_promote(translation, force_floating=True, xp=xp)
|
| 98 |
+
)
|
| 99 |
+
return matrix
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def from_components(translation: Array, quat: Array) -> Array:
|
| 103 |
+
return compose_transforms(from_translation(translation), from_rotation(quat))
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def from_exp_coords(exp_coords: Array) -> Array:
|
| 107 |
+
rot_vec = exp_coords[..., :3]
|
| 108 |
+
rot_matrix = quat_as_matrix(quat_from_rotvec(rot_vec))
|
| 109 |
+
translation_transform = _compute_se3_exp_translation_transform(rot_vec)
|
| 110 |
+
translations = (translation_transform @ exp_coords[..., 3:, None])[..., 0]
|
| 111 |
+
return _create_transformation_matrix(translations, rot_matrix)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def from_dual_quat(dual_quat: Array, *, scalar_first: bool = False) -> Array:
|
| 115 |
+
xp = array_namespace(dual_quat)
|
| 116 |
+
|
| 117 |
+
if dual_quat.shape[-1] != 8:
|
| 118 |
+
raise ValueError(
|
| 119 |
+
f"Expected `dual_quat` to have shape (..., 8), got {dual_quat.shape}."
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
real_part = dual_quat[..., :4]
|
| 123 |
+
dual_part = dual_quat[..., 4:]
|
| 124 |
+
if scalar_first:
|
| 125 |
+
real_part = xp.roll(real_part, -1, axis=-1)
|
| 126 |
+
dual_part = xp.roll(dual_part, -1, axis=-1)
|
| 127 |
+
|
| 128 |
+
real_part, dual_part = _normalize_dual_quaternion(real_part, dual_part)
|
| 129 |
+
|
| 130 |
+
rot_quat = from_quat(real_part)
|
| 131 |
+
|
| 132 |
+
translation = 2.0 * compose_quat(dual_part, quat_inv(rot_quat))[..., :3]
|
| 133 |
+
matrix = _create_transformation_matrix(translation, quat_as_matrix(rot_quat))
|
| 134 |
+
|
| 135 |
+
return matrix
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def as_exp_coords(matrix: Array) -> Array:
|
| 139 |
+
xp = array_namespace(matrix)
|
| 140 |
+
rot_vec = quat_as_rotvec(quat_from_matrix_orthogonal(matrix[..., :3, :3]))
|
| 141 |
+
translation_transform = _compute_se3_log_translation_transform(rot_vec)
|
| 142 |
+
translations = (translation_transform @ matrix[..., :3, 3][..., None])[..., 0]
|
| 143 |
+
exp_coords = xp.concat([rot_vec, translations], axis=-1)
|
| 144 |
+
return exp_coords
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def as_dual_quat(matrix: Array, *, scalar_first: bool = False) -> Array:
|
| 148 |
+
xp = array_namespace(matrix)
|
| 149 |
+
real_parts = quat_from_matrix_orthogonal(matrix[..., :3, :3])
|
| 150 |
+
|
| 151 |
+
pure_translation_quats = xp.empty(
|
| 152 |
+
(*matrix.shape[:-2], 4), dtype=matrix.dtype, device=xp_device(matrix)
|
| 153 |
+
)
|
| 154 |
+
pure_translation_quats = xpx.at(pure_translation_quats)[..., :3].set(
|
| 155 |
+
matrix[..., :3, 3]
|
| 156 |
+
)
|
| 157 |
+
pure_translation_quats = xpx.at(pure_translation_quats)[..., 3].set(0.0)
|
| 158 |
+
|
| 159 |
+
dual_parts = 0.5 * compose_quat(pure_translation_quats, real_parts)
|
| 160 |
+
|
| 161 |
+
if scalar_first:
|
| 162 |
+
real_parts = xp.roll(real_parts, 1, axis=-1)
|
| 163 |
+
dual_parts = xp.roll(dual_parts, 1, axis=-1)
|
| 164 |
+
|
| 165 |
+
dual_quats = xp.concat([real_parts, dual_parts], axis=-1)
|
| 166 |
+
return dual_quats
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def compose_transforms(tf_matrix: Array, other_tf_matrix: Array) -> Array:
|
| 170 |
+
if not broadcastable(tf_matrix.shape, other_tf_matrix.shape):
|
| 171 |
+
len_a = tf_matrix.shape[0] if tf_matrix.ndim == 3 else 1
|
| 172 |
+
len_b = other_tf_matrix.shape[0] if other_tf_matrix.ndim == 3 else 1
|
| 173 |
+
raise ValueError(
|
| 174 |
+
"Expected equal number of transforms in both or a "
|
| 175 |
+
"single transform in either object, got "
|
| 176 |
+
f"{len_a} transforms in first and {len_b}"
|
| 177 |
+
"transforms in second object."
|
| 178 |
+
)
|
| 179 |
+
return tf_matrix @ other_tf_matrix
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def inv(matrix: Array) -> Array:
|
| 183 |
+
xp = array_namespace(matrix)
|
| 184 |
+
r_inv = xp.matrix_transpose(matrix[..., :3, :3])
|
| 185 |
+
# Matrix multiplication of r_inv and translation vector
|
| 186 |
+
t_inv = -(r_inv @ matrix[..., :3, 3][..., None])[..., 0]
|
| 187 |
+
matrix = xp.zeros(
|
| 188 |
+
(*matrix.shape[:-2], 4, 4), dtype=matrix.dtype, device=xp_device(matrix)
|
| 189 |
+
)
|
| 190 |
+
matrix = xpx.at(matrix)[..., :3, :3].set(r_inv)
|
| 191 |
+
matrix = xpx.at(matrix)[..., :3, 3].set(t_inv)
|
| 192 |
+
matrix = xpx.at(matrix)[..., 3, 3].set(1)
|
| 193 |
+
return matrix
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
def apply(matrix: Array, vector: Array, inverse: bool = False) -> Array:
|
| 197 |
+
xp = array_namespace(matrix)
|
| 198 |
+
if vector.shape[-1] != 3:
|
| 199 |
+
raise ValueError(f"Expected vector to have shape (..., 3), got {vector.shape}.")
|
| 200 |
+
vec = xp.empty(
|
| 201 |
+
(*vector.shape[:-1], 4), dtype=vector.dtype, device=xp_device(vector)
|
| 202 |
+
)
|
| 203 |
+
vec = xpx.at(vec)[..., :3].set(vector)
|
| 204 |
+
vec = xpx.at(vec)[..., 3].set(1)
|
| 205 |
+
vec = vec[..., None]
|
| 206 |
+
|
| 207 |
+
if inverse:
|
| 208 |
+
matrix = inv(matrix)
|
| 209 |
+
|
| 210 |
+
# We raise a ValueError manually here because letting the function run its course
|
| 211 |
+
# would raise heterogeneous error types and messages for different frameworks.
|
| 212 |
+
# However, the error only mimics numpy's error message and does not provide the
|
| 213 |
+
# same amount of context.
|
| 214 |
+
if not broadcastable(matrix.shape, vec.shape):
|
| 215 |
+
raise ValueError("operands could not be broadcast together")
|
| 216 |
+
return (matrix @ vec)[..., :3, 0]
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def pow(matrix: Array, n: float | Array) -> Array:
|
| 220 |
+
xp = array_namespace(matrix)
|
| 221 |
+
device = xp_device(matrix)
|
| 222 |
+
# If n is an array, we sanitize it to a scalar and promote quat and n to
|
| 223 |
+
# the same dtype.
|
| 224 |
+
if is_array_api_obj(n):
|
| 225 |
+
if n.shape == (1,):
|
| 226 |
+
n = n[0]
|
| 227 |
+
elif n.ndim != 0:
|
| 228 |
+
raise ValueError("Array exponent must be a scalar")
|
| 229 |
+
matrix, n = xp_promote(matrix, n, force_floating=True, xp=xp)
|
| 230 |
+
|
| 231 |
+
# If n is a lazy array, we cannot take fast paths for special cases.
|
| 232 |
+
if is_lazy_array(n):
|
| 233 |
+
# Lazy execution. We compute all special cases and the general case
|
| 234 |
+
result = from_exp_coords(as_exp_coords(matrix) * n)
|
| 235 |
+
identity = xp.eye(4, dtype=matrix.dtype, device=device)
|
| 236 |
+
result = xp.where(n == 0, identity, result)
|
| 237 |
+
result = xp.where(n == -1, inv(matrix), result)
|
| 238 |
+
result = xp.where(n == 1, matrix, result)
|
| 239 |
+
return result
|
| 240 |
+
if n == 0:
|
| 241 |
+
identity = xp.eye(4, dtype=matrix.dtype, device=device)
|
| 242 |
+
identity = xpx.atleast_nd(identity, ndim=matrix.ndim, xp=xp)
|
| 243 |
+
return xp.tile(identity, (*matrix.shape[:-2], 1, 1))
|
| 244 |
+
elif n == -1:
|
| 245 |
+
return inv(matrix)
|
| 246 |
+
elif n == 1:
|
| 247 |
+
return matrix
|
| 248 |
+
return from_exp_coords(as_exp_coords(matrix) * n)
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def mean(
|
| 252 |
+
matrix: Array,
|
| 253 |
+
weights: ArrayLike | None = None,
|
| 254 |
+
axis: None | int | tuple[int, ...] = None
|
| 255 |
+
) -> Array:
|
| 256 |
+
xp = array_namespace(matrix)
|
| 257 |
+
if matrix.shape[0] == 0:
|
| 258 |
+
raise ValueError("Mean of an empty rotation set is undefined.")
|
| 259 |
+
# Axis logic: For None, we reduce over all axes. For int, we only reduce over that
|
| 260 |
+
# axis. For tuple, we reduce over all specified axes.
|
| 261 |
+
all_axes = tuple(range(matrix.ndim - 2))
|
| 262 |
+
if axis is None:
|
| 263 |
+
axis = all_axes
|
| 264 |
+
elif isinstance(axis, int):
|
| 265 |
+
axis = (axis,)
|
| 266 |
+
if not isinstance(axis, tuple):
|
| 267 |
+
raise ValueError("`axis` must be None, int, or tuple of ints.")
|
| 268 |
+
# Ensure all axes are within bounds
|
| 269 |
+
if (axis != () and
|
| 270 |
+
(min(axis) < -(matrix.ndim - 2) or max(axis) > (matrix.ndim - 3))
|
| 271 |
+
):
|
| 272 |
+
raise ValueError(
|
| 273 |
+
f"axis {axis} is out of bounds for transform with shape "
|
| 274 |
+
f"{matrix.shape[:-2]}."
|
| 275 |
+
)
|
| 276 |
+
# Ensure all axes are positive and unique
|
| 277 |
+
axis = tuple(sorted(set(x % (matrix.ndim - 2) for x in axis)))
|
| 278 |
+
|
| 279 |
+
lazy = is_lazy_array(matrix)
|
| 280 |
+
quats = quat_from_matrix_orthogonal(matrix[..., :3, :3])
|
| 281 |
+
if weights is None:
|
| 282 |
+
quats_mean = quat_mean(quats, axis=axis)
|
| 283 |
+
else:
|
| 284 |
+
neg_weights = weights < 0
|
| 285 |
+
any_neg_weights = xp.any(neg_weights)
|
| 286 |
+
if not lazy and any_neg_weights:
|
| 287 |
+
raise ValueError("`weights` must be non-negative.")
|
| 288 |
+
if weights.shape != matrix.shape[:-2]:
|
| 289 |
+
raise ValueError(
|
| 290 |
+
f"Expected `weights` to match transform shape, got shape "
|
| 291 |
+
f"{weights.shape} for {matrix.shape[:-2]} transformations."
|
| 292 |
+
)
|
| 293 |
+
quats_mean = quat_mean(quats, weights=weights, axis=axis)
|
| 294 |
+
r_mean = quat_as_matrix(quats_mean)
|
| 295 |
+
|
| 296 |
+
t = matrix[..., :3, 3]
|
| 297 |
+
if weights is None:
|
| 298 |
+
t_mean = xp.mean(t, axis=axis)
|
| 299 |
+
else:
|
| 300 |
+
norm = xp.sum(weights[..., None], axis=axis)
|
| 301 |
+
wsum = xp.sum(t * weights[..., None], axis=axis)
|
| 302 |
+
t_mean = wsum / norm
|
| 303 |
+
|
| 304 |
+
tf = _create_transformation_matrix(t_mean, r_mean)
|
| 305 |
+
if weights is not None and lazy:
|
| 306 |
+
# We cannot raise on negative weights because jit code needs to be
|
| 307 |
+
# non-branching. We return NaN instead
|
| 308 |
+
mask = xp.where(any_neg_weights, xp.nan, 1.0)
|
| 309 |
+
tf = mask * tf
|
| 310 |
+
return tf
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def setitem(
|
| 314 |
+
matrix: Array,
|
| 315 |
+
indexer: Array | int | tuple | slice | EllipsisType | None,
|
| 316 |
+
value: Array,
|
| 317 |
+
) -> Array:
|
| 318 |
+
xp = array_namespace(matrix)
|
| 319 |
+
if isinstance(indexer, EllipsisType):
|
| 320 |
+
return xpx.at(matrix)[indexer].set(value)
|
| 321 |
+
if is_array_api_obj(indexer) and indexer.dtype == xp.bool:
|
| 322 |
+
return xpx.at(matrix)[indexer].set(value)
|
| 323 |
+
return xpx.at(matrix)[indexer, ...].set(value)
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def normalize_dual_quaternion(dual_quat: Array) -> Array:
|
| 327 |
+
"""Normalize dual quaternion."""
|
| 328 |
+
xp = array_namespace(dual_quat)
|
| 329 |
+
real, dual = _normalize_dual_quaternion(dual_quat[..., :4], dual_quat[..., 4:])
|
| 330 |
+
return xp.concat((real, dual), axis=-1)
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
def _create_transformation_matrix(
|
| 334 |
+
translations: Array, rotation_matrices: Array
|
| 335 |
+
) -> Array:
|
| 336 |
+
if not translations.shape[:-1] == rotation_matrices.shape[:-2]:
|
| 337 |
+
raise ValueError(
|
| 338 |
+
"The number of rotation matrices and translations must be the same."
|
| 339 |
+
)
|
| 340 |
+
xp = array_namespace(translations)
|
| 341 |
+
matrix = xp.empty(
|
| 342 |
+
(*translations.shape[:-1], 4, 4),
|
| 343 |
+
dtype=translations.dtype,
|
| 344 |
+
device=xp_device(translations),
|
| 345 |
+
)
|
| 346 |
+
matrix = xpx.at(matrix)[..., :3, :3].set(rotation_matrices)
|
| 347 |
+
matrix = xpx.at(matrix)[..., :3, 3].set(translations)
|
| 348 |
+
matrix = xpx.at(matrix)[..., 3, :3].set(0)
|
| 349 |
+
matrix = xpx.at(matrix)[..., 3, 3].set(1)
|
| 350 |
+
return matrix
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def _compute_se3_exp_translation_transform(rot_vec: Array) -> Array:
|
| 354 |
+
"""Compute the transformation matrix from the se3 translation part to SE3
|
| 355 |
+
translation.
|
| 356 |
+
|
| 357 |
+
The transformation matrix depends on the rotation vector.
|
| 358 |
+
"""
|
| 359 |
+
xp = array_namespace(rot_vec)
|
| 360 |
+
device = xp_device(rot_vec)
|
| 361 |
+
dtype = rot_vec.dtype
|
| 362 |
+
angle = xp_vector_norm(rot_vec, axis=-1, keepdims=True, xp=xp)
|
| 363 |
+
small_scale = angle < 1e-3
|
| 364 |
+
|
| 365 |
+
k1_small = 0.5 - angle**2 / 24 + angle**4 / 720
|
| 366 |
+
# Avoid division by zero for non-branching computations. The value will get
|
| 367 |
+
# discarded in the xp.where selection.
|
| 368 |
+
safe_angle = angle + xp.asarray(small_scale, dtype=dtype, device=device)
|
| 369 |
+
k1 = (1.0 - xp.cos(angle)) / safe_angle**2
|
| 370 |
+
k1 = xp.where(small_scale, k1_small, k1)
|
| 371 |
+
|
| 372 |
+
k2_small = 1 / 6 - angle**2 / 120 + angle**4 / 5040
|
| 373 |
+
# Again, avoid division by zero by adding one to all near-zero angles.
|
| 374 |
+
safe_angle = angle + xp.asarray(small_scale, dtype=dtype, device=device)
|
| 375 |
+
k2 = (angle - xp.sin(angle)) / safe_angle**3
|
| 376 |
+
k2 = xp.where(small_scale, k2_small, k2)
|
| 377 |
+
|
| 378 |
+
s = _create_skew_matrix(rot_vec)
|
| 379 |
+
eye = xp.eye(3, dtype=dtype, device=device)
|
| 380 |
+
|
| 381 |
+
return eye + k1[..., None] * s + k2[..., None] * s @ s
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def _compute_se3_log_translation_transform(rot_vec: Array) -> Array:
|
| 385 |
+
"""Compute the transformation matrix from SE3 translation to the se3
|
| 386 |
+
translation part.
|
| 387 |
+
|
| 388 |
+
It is the inverse of `_compute_se3_exp_translation_transform` in a closed
|
| 389 |
+
analytical form.
|
| 390 |
+
"""
|
| 391 |
+
xp = array_namespace(rot_vec)
|
| 392 |
+
dtype = rot_vec.dtype
|
| 393 |
+
device = xp_device(rot_vec)
|
| 394 |
+
angle = xp_vector_norm(rot_vec, axis=-1, keepdims=True, xp=xp)
|
| 395 |
+
mask = angle < 1e-3
|
| 396 |
+
|
| 397 |
+
k_small = 1 / 12 + angle**2 / 720 + angle**4 / 30240
|
| 398 |
+
safe_angle = angle + xp.asarray(mask, dtype=dtype, device=device)
|
| 399 |
+
k = (1 - 0.5 * angle / xp.tan(0.5 * safe_angle)) / safe_angle**2
|
| 400 |
+
k = xp.where(mask, k_small, k)
|
| 401 |
+
|
| 402 |
+
s = _create_skew_matrix(rot_vec)
|
| 403 |
+
|
| 404 |
+
return xp.eye(3, dtype=dtype, device=device) - 0.5 * s + k[..., None] * s @ s
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def _create_skew_matrix(vec: Array) -> Array:
|
| 408 |
+
"""Create skew-symmetric (aka cross-product) matrix for stack of vectors."""
|
| 409 |
+
xp = array_namespace(vec)
|
| 410 |
+
result = xp.zeros((*vec.shape[:-1], 3, 3), dtype=vec.dtype, device=xp_device(vec))
|
| 411 |
+
result = xpx.at(result)[..., 0, 1].set(-vec[..., 2])
|
| 412 |
+
result = xpx.at(result)[..., 0, 2].set(vec[..., 1])
|
| 413 |
+
result = xpx.at(result)[..., 1, 0].set(vec[..., 2])
|
| 414 |
+
result = xpx.at(result)[..., 1, 2].set(-vec[..., 0])
|
| 415 |
+
result = xpx.at(result)[..., 2, 0].set(-vec[..., 1])
|
| 416 |
+
result = xpx.at(result)[..., 2, 1].set(vec[..., 0])
|
| 417 |
+
return result
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
def _normalize_dual_quaternion(
|
| 421 |
+
real_part: Array, dual_part: Array
|
| 422 |
+
) -> tuple[Array, Array]:
|
| 423 |
+
"""Ensure that the dual quaternion has unit norm.
|
| 424 |
+
|
| 425 |
+
The norm is a dual number and must be 1 + 0 * epsilon, which means that
|
| 426 |
+
the real quaternion must have unit norm and the dual quaternion must be
|
| 427 |
+
orthogonal to the real quaternion.
|
| 428 |
+
"""
|
| 429 |
+
xp = array_namespace(real_part)
|
| 430 |
+
|
| 431 |
+
real_norm = xp_vector_norm(real_part, axis=-1, keepdims=True, xp=xp)
|
| 432 |
+
|
| 433 |
+
# special case: real quaternion is 0, we set it to identity
|
| 434 |
+
zero_real_mask = real_norm == 0.0
|
| 435 |
+
unit_quat = xp.asarray(
|
| 436 |
+
[0.0, 0.0, 0.0, 1.0], dtype=real_part.dtype, device=xp_device(real_part)
|
| 437 |
+
)
|
| 438 |
+
real_part = xp.where(zero_real_mask, unit_quat, real_part)
|
| 439 |
+
real_norm = xp.where(zero_real_mask, 1.0, real_norm)
|
| 440 |
+
|
| 441 |
+
# 1. ensure unit real quaternion
|
| 442 |
+
real_part = real_part / real_norm
|
| 443 |
+
dual_part = dual_part / real_norm
|
| 444 |
+
|
| 445 |
+
# 2. ensure orthogonality of real and dual quaternion
|
| 446 |
+
dual_part -= xp.sum(real_part * dual_part, axis=-1, keepdims=True) * real_part
|
| 447 |
+
|
| 448 |
+
return real_part, dual_part
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_cy.cp312-win_amd64.dll.a
ADDED
|
Binary file (1.61 kB). View file
|
|
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_cy.cp312-win_amd64.pyd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4f68115dad53da6a532a54d81e334931f14455e523a3fe78caf1523f1fead01e
|
| 3 |
+
size 557568
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_groups.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
from scipy.constants import golden as phi
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def icosahedral(cls):
|
| 6 |
+
g1 = tetrahedral(cls).as_quat()
|
| 7 |
+
a = 0.5
|
| 8 |
+
b = 0.5 / phi
|
| 9 |
+
c = phi / 2
|
| 10 |
+
g2 = np.array([[+a, +b, +c, 0],
|
| 11 |
+
[+a, +b, -c, 0],
|
| 12 |
+
[+a, +c, 0, +b],
|
| 13 |
+
[+a, +c, 0, -b],
|
| 14 |
+
[+a, -b, +c, 0],
|
| 15 |
+
[+a, -b, -c, 0],
|
| 16 |
+
[+a, -c, 0, +b],
|
| 17 |
+
[+a, -c, 0, -b],
|
| 18 |
+
[+a, 0, +b, +c],
|
| 19 |
+
[+a, 0, +b, -c],
|
| 20 |
+
[+a, 0, -b, +c],
|
| 21 |
+
[+a, 0, -b, -c],
|
| 22 |
+
[+b, +a, 0, +c],
|
| 23 |
+
[+b, +a, 0, -c],
|
| 24 |
+
[+b, +c, +a, 0],
|
| 25 |
+
[+b, +c, -a, 0],
|
| 26 |
+
[+b, -a, 0, +c],
|
| 27 |
+
[+b, -a, 0, -c],
|
| 28 |
+
[+b, -c, +a, 0],
|
| 29 |
+
[+b, -c, -a, 0],
|
| 30 |
+
[+b, 0, +c, +a],
|
| 31 |
+
[+b, 0, +c, -a],
|
| 32 |
+
[+b, 0, -c, +a],
|
| 33 |
+
[+b, 0, -c, -a],
|
| 34 |
+
[+c, +a, +b, 0],
|
| 35 |
+
[+c, +a, -b, 0],
|
| 36 |
+
[+c, +b, 0, +a],
|
| 37 |
+
[+c, +b, 0, -a],
|
| 38 |
+
[+c, -a, +b, 0],
|
| 39 |
+
[+c, -a, -b, 0],
|
| 40 |
+
[+c, -b, 0, +a],
|
| 41 |
+
[+c, -b, 0, -a],
|
| 42 |
+
[+c, 0, +a, +b],
|
| 43 |
+
[+c, 0, +a, -b],
|
| 44 |
+
[+c, 0, -a, +b],
|
| 45 |
+
[+c, 0, -a, -b],
|
| 46 |
+
[0, +a, +c, +b],
|
| 47 |
+
[0, +a, +c, -b],
|
| 48 |
+
[0, +a, -c, +b],
|
| 49 |
+
[0, +a, -c, -b],
|
| 50 |
+
[0, +b, +a, +c],
|
| 51 |
+
[0, +b, +a, -c],
|
| 52 |
+
[0, +b, -a, +c],
|
| 53 |
+
[0, +b, -a, -c],
|
| 54 |
+
[0, +c, +b, +a],
|
| 55 |
+
[0, +c, +b, -a],
|
| 56 |
+
[0, +c, -b, +a],
|
| 57 |
+
[0, +c, -b, -a]])
|
| 58 |
+
return cls.from_quat(np.concatenate((g1, g2)))
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def octahedral(cls):
|
| 62 |
+
g1 = tetrahedral(cls).as_quat()
|
| 63 |
+
c = np.sqrt(2) / 2
|
| 64 |
+
g2 = np.array([[+c, 0, 0, +c],
|
| 65 |
+
[0, +c, 0, +c],
|
| 66 |
+
[0, 0, +c, +c],
|
| 67 |
+
[0, 0, -c, +c],
|
| 68 |
+
[0, -c, 0, +c],
|
| 69 |
+
[-c, 0, 0, +c],
|
| 70 |
+
[0, +c, +c, 0],
|
| 71 |
+
[0, -c, +c, 0],
|
| 72 |
+
[+c, 0, +c, 0],
|
| 73 |
+
[-c, 0, +c, 0],
|
| 74 |
+
[+c, +c, 0, 0],
|
| 75 |
+
[-c, +c, 0, 0]])
|
| 76 |
+
return cls.from_quat(np.concatenate((g1, g2)))
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def tetrahedral(cls):
|
| 80 |
+
g1 = np.eye(4)
|
| 81 |
+
c = 0.5
|
| 82 |
+
g2 = np.array([[c, -c, -c, +c],
|
| 83 |
+
[c, -c, +c, +c],
|
| 84 |
+
[c, +c, -c, +c],
|
| 85 |
+
[c, +c, +c, +c],
|
| 86 |
+
[c, -c, -c, -c],
|
| 87 |
+
[c, -c, +c, -c],
|
| 88 |
+
[c, +c, -c, -c],
|
| 89 |
+
[c, +c, +c, -c]])
|
| 90 |
+
return cls.from_quat(np.concatenate((g1, g2)))
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def dicyclic(cls, n, axis=2):
|
| 94 |
+
g1 = cyclic(cls, n, axis).as_rotvec()
|
| 95 |
+
|
| 96 |
+
thetas = np.linspace(0, np.pi, n, endpoint=False)
|
| 97 |
+
rv = np.pi * np.vstack([np.zeros(n), np.cos(thetas), np.sin(thetas)]).T
|
| 98 |
+
g2 = np.roll(rv, axis, axis=1)
|
| 99 |
+
return cls.from_rotvec(np.concatenate((g1, g2)))
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def cyclic(cls, n, axis=2):
|
| 103 |
+
thetas = np.linspace(0, 2 * np.pi, n, endpoint=False)
|
| 104 |
+
rv = np.vstack([thetas, np.zeros(n), np.zeros(n)]).T
|
| 105 |
+
return cls.from_rotvec(np.roll(rv, axis, axis=1))
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def create_group(cls, group, axis='Z'):
|
| 109 |
+
if not isinstance(group, str):
|
| 110 |
+
raise ValueError("`group` argument must be a string")
|
| 111 |
+
|
| 112 |
+
permitted_axes = ['x', 'y', 'z', 'X', 'Y', 'Z']
|
| 113 |
+
if axis not in permitted_axes:
|
| 114 |
+
raise ValueError("`axis` must be one of " + ", ".join(permitted_axes))
|
| 115 |
+
|
| 116 |
+
if group in ['I', 'O', 'T']:
|
| 117 |
+
symbol = group
|
| 118 |
+
order = 1
|
| 119 |
+
elif group[:1] in ['C', 'D'] and group[1:].isdigit():
|
| 120 |
+
symbol = group[:1]
|
| 121 |
+
order = int(group[1:])
|
| 122 |
+
else:
|
| 123 |
+
raise ValueError("`group` must be one of 'I', 'O', 'T', 'Dn', 'Cn'")
|
| 124 |
+
|
| 125 |
+
if order < 1:
|
| 126 |
+
raise ValueError("Group order must be positive")
|
| 127 |
+
|
| 128 |
+
axis = 'xyz'.index(axis.lower())
|
| 129 |
+
if symbol == 'I':
|
| 130 |
+
return icosahedral(cls)
|
| 131 |
+
elif symbol == 'O':
|
| 132 |
+
return octahedral(cls)
|
| 133 |
+
elif symbol == 'T':
|
| 134 |
+
return tetrahedral(cls)
|
| 135 |
+
elif symbol == 'D':
|
| 136 |
+
return dicyclic(cls, order, axis=axis)
|
| 137 |
+
elif symbol == 'C':
|
| 138 |
+
return cyclic(cls, order, axis=axis)
|
| 139 |
+
else:
|
| 140 |
+
assert False
|
loan-advisor-agent/.venv/Lib/site-packages/scipy/spatial/transform/_rotation_spline.py
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ve_banded
|
| 3 |
+
from ._rotation import Rotation
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def _create_skew_matrix(x):
|
| 7 |
+
"""Create skew-symmetric matrices corresponding to vectors.
|
| 8 |
+
|
| 9 |
+
Parameters
|
| 10 |
+
----------
|
| 11 |
+
x : ndarray, shape (n, 3)
|
| 12 |
+
Set of vectors.
|
| 13 |
+
|
| 14 |
+
Returns
|
| 15 |
+
-------
|
| 16 |
+
ndarray, shape (n, 3, 3)
|
| 17 |
+
"""
|
| 18 |
+
result = np.zeros((len(x), 3, 3))
|
| 19 |
+
result[:, 0, 1] = -x[:, 2]
|
| 20 |
+
result[:, 0, 2] = x[:, 1]
|
| 21 |
+
result[:, 1, 0] = x[:, 2]
|
| 22 |
+
result[:, 1, 2] = -x[:, 0]
|
| 23 |
+
result[:, 2, 0] = -x[:, 1]
|
| 24 |
+
result[:, 2, 1] = x[:, 0]
|
| 25 |
+
return result
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _matrix_vector_product_of_stacks(A, b):
|
| 29 |
+
"""Compute the product of stack of matrices and vectors."""
|
| 30 |
+
return np.einsum("ijk,ik->ij", A, b)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _angular_rate_to_rotvec_dot_matrix(rotvecs):
|
| 34 |
+
"""Compute matrices to transform angular rates to rot. vector derivatives.
|
| 35 |
+
|
| 36 |
+
The matrices depend on the current attitude represented as a rotation
|
| 37 |
+
vector.
|
| 38 |
+
|
| 39 |
+
Parameters
|
| 40 |
+
----------
|
| 41 |
+
rotvecs : ndarray, shape (n, 3)
|
| 42 |
+
Set of rotation vectors.
|
| 43 |
+
|
| 44 |
+
Returns
|
| 45 |
+
-------
|
| 46 |
+
ndarray, shape (n, 3, 3)
|
| 47 |
+
"""
|
| 48 |
+
norm = np.linalg.norm(rotvecs, axis=1)
|
| 49 |
+
k = np.empty_like(norm)
|
| 50 |
+
|
| 51 |
+
mask = norm > 1e-4
|
| 52 |
+
nm = norm[mask]
|
| 53 |
+
k[mask] = (1 - 0.5 * nm / np.tan(0.5 * nm)) / nm**2
|
| 54 |
+
mask = ~mask
|
| 55 |
+
nm = norm[mask]
|
| 56 |
+
k[mask] = 1/12 + 1/720 * nm**2
|
| 57 |
+
|
| 58 |
+
skew = _create_skew_matrix(rotvecs)
|
| 59 |
+
|
| 60 |
+
result = np.empty((len(rotvecs), 3, 3))
|
| 61 |
+
result[:] = np.identity(3)
|
| 62 |
+
result[:] += 0.5 * skew
|
| 63 |
+
result[:] += k[:, None, None] * np.matmul(skew, skew)
|
| 64 |
+
|
| 65 |
+
return result
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _rotvec_dot_to_angular_rate_matrix(rotvecs):
|
| 69 |
+
"""Compute matrices to transform rot. vector derivatives to angular rates.
|
| 70 |
+
|
| 71 |
+
The matrices depend on the current attitude represented as a rotation
|
| 72 |
+
vector.
|
| 73 |
+
|
| 74 |
+
Parameters
|
| 75 |
+
----------
|
| 76 |
+
rotvecs : ndarray, shape (n, 3)
|
| 77 |
+
Set of rotation vectors.
|
| 78 |
+
|
| 79 |
+
Returns
|
| 80 |
+
-------
|
| 81 |
+
ndarray, shape (n, 3, 3)
|
| 82 |
+
"""
|
| 83 |
+
norm = np.linalg.norm(rotvecs, axis=1)
|
| 84 |
+
k1 = np.empty_like(norm)
|
| 85 |
+
k2 = np.empty_like(norm)
|
| 86 |
+
|
| 87 |
+
mask = norm > 1e-4
|
| 88 |
+
nm = norm[mask]
|
| 89 |
+
k1[mask] = (1 - np.cos(nm)) / nm ** 2
|
| 90 |
+
k2[mask] = (nm - np.sin(nm)) / nm ** 3
|
| 91 |
+
|
| 92 |
+
mask = ~mask
|
| 93 |
+
nm = norm[mask]
|
| 94 |
+
k1[mask] = 0.5 - nm ** 2 / 24
|
| 95 |
+
k2[mask] = 1 / 6 - nm ** 2 / 120
|
| 96 |
+
|
| 97 |
+
skew = _create_skew_matrix(rotvecs)
|
| 98 |
+
|
| 99 |
+
result = np.empty((len(rotvecs), 3, 3))
|
| 100 |
+
result[:] = np.identity(3)
|
| 101 |
+
result[:] -= k1[:, None, None] * skew
|
| 102 |
+
result[:] += k2[:, None, None] * np.matmul(skew, skew)
|
| 103 |
+
|
| 104 |
+
return result
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def _angular_acceleration_nonlinear_term(rotvecs, rotvecs_dot):
|
| 108 |
+
"""Compute the non-linear term in angular acceleration.
|
| 109 |
+
|
| 110 |
+
The angular acceleration contains a quadratic term with respect to
|
| 111 |
+
the derivative of the rotation vector. This function computes that.
|
| 112 |
+
|
| 113 |
+
Parameters
|
| 114 |
+
----------
|
| 115 |
+
rotvecs : ndarray, shape (n, 3)
|
| 116 |
+
Set of rotation vectors.
|
| 117 |
+
rotvecs_dot : ndarray, shape (n, 3)
|
| 118 |
+
Set of rotation vector derivatives.
|
| 119 |
+
|
| 120 |
+
Returns
|
| 121 |
+
-------
|
| 122 |
+
ndarray, shape (n, 3)
|
| 123 |
+
"""
|
| 124 |
+
norm = np.linalg.norm(rotvecs, axis=1)
|
| 125 |
+
dp = np.sum(rotvecs * rotvecs_dot, axis=1)
|
| 126 |
+
cp = np.cross(rotvecs, rotvecs_dot)
|
| 127 |
+
ccp = np.cross(rotvecs, cp)
|
| 128 |
+
dccp = np.cross(rotvecs_dot, cp)
|
| 129 |
+
|
| 130 |
+
k1 = np.empty_like(norm)
|
| 131 |
+
k2 = np.empty_like(norm)
|
| 132 |
+
k3 = np.empty_like(norm)
|
| 133 |
+
|
| 134 |
+
mask = norm > 1e-4
|
| 135 |
+
nm = norm[mask]
|
| 136 |
+
k1[mask] = (-nm * np.sin(nm) - 2 * (np.cos(nm) - 1)) / nm ** 4
|
| 137 |
+
k2[mask] = (-2 * nm + 3 * np.sin(nm) - nm * np.cos(nm)) / nm ** 5
|
| 138 |
+
k3[mask] = (nm - np.sin(nm)) / nm ** 3
|
| 139 |
+
|
| 140 |
+
mask = ~mask
|
| 141 |
+
nm = norm[mask]
|
| 142 |
+
k1[mask] = 1/12 - nm ** 2 / 180
|
| 143 |
+
k2[mask] = -1/60 + nm ** 2 / 12604
|
| 144 |
+
k3[mask] = 1/6 - nm ** 2 / 120
|
| 145 |
+
|
| 146 |
+
dp = dp[:, None]
|
| 147 |
+
k1 = k1[:, None]
|
| 148 |
+
k2 = k2[:, None]
|
| 149 |
+
k3 = k3[:, None]
|
| 150 |
+
|
| 151 |
+
return dp * (k1 * cp + k2 * ccp) + k3 * dccp
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def _compute_angular_rate(rotvecs, rotvecs_dot):
|
| 155 |
+
"""Compute angular rates given rotation vectors and its derivatives.
|
| 156 |
+
|
| 157 |
+
Parameters
|
| 158 |
+
----------
|
| 159 |
+
rotvecs : ndarray, shape (n, 3)
|
| 160 |
+
Set of rotation vectors.
|
| 161 |
+
rotvecs_dot : ndarray, shape (n, 3)
|
| 162 |
+
Set of rotation vector derivatives.
|
| 163 |
+
|
| 164 |
+
Returns
|
| 165 |
+
-------
|
| 166 |
+
ndarray, shape (n, 3)
|
| 167 |
+
"""
|
| 168 |
+
return _matrix_vector_product_of_stacks(
|
| 169 |
+
_rotvec_dot_to_angular_rate_matrix(rotvecs), rotvecs_dot)
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def _compute_angular_acceleration(rotvecs, rotvecs_dot, rotvecs_dot_dot):
|
| 173 |
+
"""Compute angular acceleration given rotation vector and its derivatives.
|
| 174 |
+
|
| 175 |
+
Parameters
|
| 176 |
+
----------
|
| 177 |
+
rotvecs : ndarray, shape (n, 3)
|
| 178 |
+
Set of rotation vectors.
|
| 179 |
+
rotvecs_dot : ndarray, shape (n, 3)
|
| 180 |
+
Set of rotation vector derivatives.
|
| 181 |
+
rotvecs_dot_dot : ndarray, shape (n, 3)
|
| 182 |
+
Set of rotation vector second derivatives.
|
| 183 |
+
|
| 184 |
+
Returns
|
| 185 |
+
-------
|
| 186 |
+
ndarray, shape (n, 3)
|
| 187 |
+
"""
|
| 188 |
+
return (_compute_angular_rate(rotvecs, rotvecs_dot_dot) +
|
| 189 |
+
_angular_acceleration_nonlinear_term(rotvecs, rotvecs_dot))
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
def _create_block_3_diagonal_matrix(A, B, d):
|
| 193 |
+
"""Create a 3-diagonal block matrix as banded.
|
| 194 |
+
|
| 195 |
+
The matrix has the following structure:
|
| 196 |
+
|
| 197 |
+
DB...
|
| 198 |
+
ADB..
|
| 199 |
+
.ADB.
|
| 200 |
+
..ADB
|
| 201 |
+
...AD
|
| 202 |
+
|
| 203 |
+
The blocks A, B and D are 3-by-3 matrices. The D matrices has the form
|
| 204 |
+
d * I.
|
| 205 |
+
|
| 206 |
+
Parameters
|
| 207 |
+
----------
|
| 208 |
+
A : ndarray, shape (n, 3, 3)
|
| 209 |
+
Stack of A blocks.
|
| 210 |
+
B : ndarray, shape (n, 3, 3)
|
| 211 |
+
Stack of B blocks.
|
| 212 |
+
d : ndarray, shape (n + 1,)
|
| 213 |
+
Values for diagonal blocks.
|
| 214 |
+
|
| 215 |
+
Returns
|
| 216 |
+
-------
|
| 217 |
+
ndarray, shape (11, 3 * (n + 1))
|
| 218 |
+
Matrix in the banded form as used by `scipy.linalg.solve_banded`.
|
| 219 |
+
"""
|
| 220 |
+
ind = np.arange(3)
|
| 221 |
+
ind_blocks = np.arange(len(A))
|
| 222 |
+
|
| 223 |
+
A_i = np.empty_like(A, dtype=int)
|
| 224 |
+
A_i[:] = ind[:, None]
|
| 225 |
+
A_i += 3 * (1 + ind_blocks[:, None, None])
|
| 226 |
+
|
| 227 |
+
A_j = np.empty_like(A, dtype=int)
|
| 228 |
+
A_j[:] = ind
|
| 229 |
+
A_j += 3 * ind_blocks[:, None, None]
|
| 230 |
+
|
| 231 |
+
B_i = np.empty_like(B, dtype=int)
|
| 232 |
+
B_i[:] = ind[:, None]
|
| 233 |
+
B_i += 3 * ind_blocks[:, None, None]
|
| 234 |
+
|
| 235 |
+
B_j = np.empty_like(B, dtype=int)
|
| 236 |
+
B_j[:] = ind
|
| 237 |
+
B_j += 3 * (1 + ind_blocks[:, None, None])
|
| 238 |
+
|
| 239 |
+
diag_i = diag_j = np.arange(3 * len(d))
|
| 240 |
+
i = np.hstack((A_i.ravel(), B_i.ravel(), diag_i))
|
| 241 |
+
j = np.hstack((A_j.ravel(), B_j.ravel(), diag_j))
|
| 242 |
+
values = np.hstack((A.ravel(), B.ravel(), np.repeat(d, 3)))
|
| 243 |
+
|
| 244 |
+
u = 5
|
| 245 |
+
l = 5
|
| 246 |
+
result = np.zeros((u + l + 1, 3 * len(d)))
|
| 247 |
+
result[u + i - j, j] = values
|
| 248 |
+
return result
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
class RotationSpline:
|
| 252 |
+
"""Interpolate rotations with continuous angular rate and acceleration.
|
| 253 |
+
|
| 254 |
+
The rotation vectors between each consecutive orientation are cubic
|
| 255 |
+
functions of time and it is guaranteed that angular rate and acceleration
|
| 256 |
+
are continuous. Such interpolation are analogous to cubic spline
|
| 257 |
+
interpolation.
|
| 258 |
+
|
| 259 |
+
Refer to [1]_ for math and implementation details.
|
| 260 |
+
|
| 261 |
+
Parameters
|
| 262 |
+
----------
|
| 263 |
+
times : array_like, shape (N,)
|
| 264 |
+
Times of the known rotations. At least 2 times must be specified.
|
| 265 |
+
rotations : `Rotation` instance
|
| 266 |
+
Rotations to perform the interpolation between. Must contain N
|
| 267 |
+
rotations.
|
| 268 |
+
|
| 269 |
+
Methods
|
| 270 |
+
-------
|
| 271 |
+
__call__
|
| 272 |
+
|
| 273 |
+
References
|
| 274 |
+
----------
|
| 275 |
+
.. [1] `Smooth Attitude Interpolation
|
| 276 |
+
<https://github.com/scipy/scipy/files/2932755/attitude_interpolation.pdf>`_
|
| 277 |
+
|
| 278 |
+
Examples
|
| 279 |
+
--------
|
| 280 |
+
>>> from scipy.spatial.transform import Rotation, RotationSpline
|
| 281 |
+
>>> import numpy as np
|
| 282 |
+
|
| 283 |
+
Define the sequence of times and rotations from the Euler angles:
|
| 284 |
+
|
| 285 |
+
>>> times = [0, 10, 20, 40]
|
| 286 |
+
>>> angles = [[-10, 20, 30], [0, 15, 40], [-30, 45, 30], [20, 45, 90]]
|
| 287 |
+
>>> rotations = Rotation.from_euler('XYZ', angles, degrees=True)
|
| 288 |
+
|
| 289 |
+
Create the interpolator object:
|
| 290 |
+
|
| 291 |
+
>>> spline = RotationSpline(times, rotations)
|
| 292 |
+
|
| 293 |
+
Interpolate the Euler angles, angular rate and acceleration:
|
| 294 |
+
|
| 295 |
+
>>> angular_rate = np.rad2deg(spline(times, 1))
|
| 296 |
+
>>> angular_acceleration = np.rad2deg(spline(times, 2))
|
| 297 |
+
>>> times_plot = np.linspace(times[0], times[-1], 100)
|
| 298 |
+
>>> angles_plot = spline(times_plot).as_euler('XYZ', degrees=True)
|
| 299 |
+
>>> angular_rate_plot = np.rad2deg(spline(times_plot, 1))
|
| 300 |
+
>>> angular_acceleration_plot = np.rad2deg(spline(times_plot, 2))
|
| 301 |
+
|
| 302 |
+
On this plot you see that Euler angles are continuous and smooth:
|
| 303 |
+
|
| 304 |
+
>>> import matplotlib.pyplot as plt
|
| 305 |
+
>>> plt.plot(times_plot, angles_plot)
|
| 306 |
+
>>> plt.plot(times, angles, 'x')
|
| 307 |
+
>>> plt.title("Euler angles")
|
| 308 |
+
>>> plt.show()
|
| 309 |
+
|
| 310 |
+
The angular rate is also smooth:
|
| 311 |
+
|
| 312 |
+
>>> plt.plot(times_plot, angular_rate_plot)
|
| 313 |
+
>>> plt.plot(times, angular_rate, 'x')
|
| 314 |
+
>>> plt.title("Angular rate")
|
| 315 |
+
>>> plt.show()
|
| 316 |
+
|
| 317 |
+
The angular acceleration is continuous, but not smooth. Also note that
|
| 318 |
+
the angular acceleration is not a piecewise-linear function, because
|
| 319 |
+
it is different from the second derivative of the rotation vector (which
|
| 320 |
+
is a piecewise-linear function as in the cubic spline).
|
| 321 |
+
|
| 322 |
+
>>> plt.plot(times_plot, angular_acceleration_plot)
|
| 323 |
+
>>> plt.plot(times, angular_acceleration, 'x')
|
| 324 |
+
>>> plt.title("Angular acceleration")
|
| 325 |
+
>>> plt.show()
|
| 326 |
+
"""
|
| 327 |
+
# Parameters for the solver for angular rate.
|
| 328 |
+
MAX_ITER = 10
|
| 329 |
+
TOL = 1e-9
|
| 330 |
+
|
| 331 |
+
def _solve_for_angular_rates(self, dt, angular_rates, rotvecs):
|
| 332 |
+
angular_rate_first = angular_rates[0].copy()
|
| 333 |
+
|
| 334 |
+
A = _angular_rate_to_rotvec_dot_matrix(rotvecs)
|
| 335 |
+
A_inv = _rotvec_dot_to_angular_rate_matrix(rotvecs)
|
| 336 |
+
M = _create_block_3_diagonal_matrix(
|
| 337 |
+
2 * A_inv[1:-1] / dt[1:-1, None, None],
|
| 338 |
+
2 * A[1:-1] / dt[1:-1, None, None],
|
| 339 |
+
4 * (1 / dt[:-1] + 1 / dt[1:]))
|
| 340 |
+
|
| 341 |
+
b0 = 6 * (rotvecs[:-1] * dt[:-1, None] ** -2 +
|
| 342 |
+
rotvecs[1:] * dt[1:, None] ** -2)
|
| 343 |
+
b0[0] -= 2 / dt[0] * A_inv[0].dot(angular_rate_first)
|
| 344 |
+
b0[-1] -= 2 / dt[-1] * A[-1].dot(angular_rates[-1])
|
| 345 |
+
|
| 346 |
+
for iteration in range(self.MAX_ITER):
|
| 347 |
+
rotvecs_dot = _matrix_vector_product_of_stacks(A, angular_rates)
|
| 348 |
+
delta_beta = _angular_acceleration_nonlinear_term(
|
| 349 |
+
rotvecs[:-1], rotvecs_dot[:-1])
|
| 350 |
+
b = b0 - delta_beta
|
| 351 |
+
angular_rates_new = solve_banded((5, 5), M, b.ravel())
|
| 352 |
+
angular_rates_new = angular_rates_new.reshape((-1, 3))
|
| 353 |
+
|
| 354 |
+
delta = np.abs(angular_rates_new - angular_rates[:-1])
|
| 355 |
+
angular_rates[:-1] = angular_rates_new
|
| 356 |
+
if np.all(delta < self.TOL * (1 + np.abs(angular_rates_new))):
|
| 357 |
+
break
|
| 358 |
+
|
| 359 |
+
rotvecs_dot = _matrix_vector_product_of_stacks(A, angular_rates)
|
| 360 |
+
angular_rates = np.vstack((angular_rate_first, angular_rates[:-1]))
|
| 361 |
+
|
| 362 |
+
return angular_rates, rotvecs_dot
|
| 363 |
+
|
| 364 |
+
def __init__(self, times, rotations):
|
| 365 |
+
from scipy.interpolate import PPoly
|
| 366 |
+
|
| 367 |
+
if rotations.single:
|
| 368 |
+
raise ValueError("`rotations` must be a sequence of rotations.")
|
| 369 |
+
|
| 370 |
+
if rotations.as_quat().ndim > 2:
|
| 371 |
+
raise ValueError(
|
| 372 |
+
"Rotations with more than 1 leading dimension are not supported."
|
| 373 |
+
)
|
| 374 |
+
|
| 375 |
+
if len(rotations) == 1:
|
| 376 |
+
raise ValueError("`rotations` must contain at least 2 rotations.")
|
| 377 |
+
|
| 378 |
+
times = np.asarray(times, dtype=float)
|
| 379 |
+
if times.ndim != 1:
|
| 380 |
+
raise ValueError("`times` must be 1-dimensional.")
|
| 381 |
+
|
| 382 |
+
if len(times) != len(rotations):
|
| 383 |
+
raise ValueError("Expected number of rotations to be equal to "
|
| 384 |
+
"number of timestamps given, "
|
| 385 |
+
f"got {len(rotations)} rotations "
|
| 386 |
+
f"and {len(times)} timestamps.")
|
| 387 |
+
|
| 388 |
+
dt = np.diff(times)
|
| 389 |
+
if np.any(dt <= 0):
|
| 390 |
+
raise ValueError("Values in `times` must be in a strictly "
|
| 391 |
+
"increasing order.")
|
| 392 |
+
|
| 393 |
+
rotvecs = (rotations[:-1].inv() * rotations[1:]).as_rotvec()
|
| 394 |
+
angular_rates = rotvecs / dt[:, None]
|
| 395 |
+
|
| 396 |
+
if len(rotations) == 2:
|
| 397 |
+
rotvecs_dot = angular_rates
|
| 398 |
+
else:
|
| 399 |
+
angular_rates, rotvecs_dot = self._solve_for_angular_rates(
|
| 400 |
+
dt, angular_rates, rotvecs)
|
| 401 |
+
|
| 402 |
+
dt = dt[:, None]
|
| 403 |
+
coeff = np.empty((4, len(times) - 1, 3))
|
| 404 |
+
coeff[0] = (-2 * rotvecs + dt * angular_rates
|
| 405 |
+
+ dt * rotvecs_dot) / dt ** 3
|
| 406 |
+
coeff[1] = (3 * rotvecs - 2 * dt * angular_rates
|
| 407 |
+
- dt * rotvecs_dot) / dt ** 2
|
| 408 |
+
coeff[2] = angular_rates
|
| 409 |
+
coeff[3] = 0
|
| 410 |
+
|
| 411 |
+
self.times = times
|
| 412 |
+
self.rotations = rotations
|
| 413 |
+
self.interpolator = PPoly(coeff, times)
|
| 414 |
+
|
| 415 |
+
def __call__(self, times, order=0):
|
| 416 |
+
"""Compute interpolated values.
|
| 417 |
+
|
| 418 |
+
Parameters
|
| 419 |
+
----------
|
| 420 |
+
times : float or array_like
|
| 421 |
+
Times of interest.
|
| 422 |
+
order : {0, 1, 2}, optional
|
| 423 |
+
Order of differentiation:
|
| 424 |
+
|
| 425 |
+
* 0 (default) : return Rotation
|
| 426 |
+
* 1 : return the angular rate in rad/sec
|
| 427 |
+
* 2 : return the angular acceleration in rad/sec/sec
|
| 428 |
+
|
| 429 |
+
Returns
|
| 430 |
+
-------
|
| 431 |
+
Interpolated Rotation, angular rate or acceleration.
|
| 432 |
+
"""
|
| 433 |
+
if order not in [0, 1, 2]:
|
| 434 |
+
raise ValueError("`order` must be 0, 1 or 2.")
|
| 435 |
+
|
| 436 |
+
times = np.asarray(times, dtype=float)
|
| 437 |
+
if times.ndim > 1:
|
| 438 |
+
raise ValueError("`times` must be at most 1-dimensional.")
|
| 439 |
+
|
| 440 |
+
singe_time = times.ndim == 0
|
| 441 |
+
times = np.atleast_1d(times)
|
| 442 |
+
|
| 443 |
+
rotvecs = self.interpolator(times)
|
| 444 |
+
if order == 0:
|
| 445 |
+
index = np.searchsorted(self.times, times, side='right')
|
| 446 |
+
index -= 1
|
| 447 |
+
index[index < 0] = 0
|
| 448 |
+
n_segments = len(self.times) - 1
|
| 449 |
+
index[index > n_segments - 1] = n_segments - 1
|
| 450 |
+
result = self.rotations[index] * Rotation.from_rotvec(rotvecs)
|
| 451 |
+
elif order == 1:
|
| 452 |
+
rotvecs_dot = self.interpolator(times, 1)
|
| 453 |
+
result = _compute_angular_rate(rotvecs, rotvecs_dot)
|
| 454 |
+
elif order == 2:
|
| 455 |
+
rotvecs_dot = self.interpolator(times, 1)
|
| 456 |
+
rotvecs_dot_dot = self.interpolator(times, 2)
|
| 457 |
+
result = _compute_angular_acceleration(rotvecs, rotvecs_dot,
|
| 458 |
+
rotvecs_dot_dot)
|
| 459 |
+
else:
|
| 460 |
+
assert False
|
| 461 |
+
|
| 462 |
+
if singe_time:
|
| 463 |
+
result = result[0]
|
| 464 |
+
|
| 465 |
+
return result
|