Skip to content

Commit c333fc2

Browse files
authored
Merge pull request #2376 from borglab/fix/examples
Small issues in examples
2 parents 9f995fb + b892005 commit c333fc2

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

python/gtsam/examples/DiscreteMotionModel.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Getting Started with a simple conditional distribution model -- Python"
7+
"# A Discrete Motion Model"
88
]
99
},
1010
{

python/gtsam/examples/FisheyeExample.ipynb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": "7762616d",
66
"metadata": {},
77
"source": [
8-
"# Fisheye Canera Structure-From-Motion Example\n",
8+
"# Fisheye Camera SfM Example\n",
99
"\n",
1010
"A visualSLAM example for the structure-from-motion problem on a\n",
1111
"simulated dataset. This version uses a fisheye camera model and a GaussNewton\n",
@@ -29,7 +29,13 @@
2929
]
3030
},
3131
"source": [
32-
"GTSAM Copyright 2010-2022, Georgia Tech Research Corporation,\nAtlanta, Georgia 30332-0415\nAll Rights Reserved\n\nAuthors: Frank Dellaert, et al. (see THANKS for the full author list)\n\nSee LICENSE for the license information"
32+
"GTSAM Copyright 2010-2022, Georgia Tech Research Corporation,\n",
33+
"Atlanta, Georgia 30332-0415\n",
34+
"All Rights Reserved\n",
35+
"\n",
36+
"Authors: Frank Dellaert, et al. (see THANKS for the full author list)\n",
37+
"\n",
38+
"See LICENSE for the license information"
3339
]
3440
},
3541
{
@@ -43,7 +49,11 @@
4349
},
4450
"outputs": [],
4551
"source": [
46-
"try:\n import google.colab\n %pip install --quiet gtsam-develop\nexcept ImportError:\n pass"
52+
"try:\n",
53+
" import google.colab\n",
54+
" %pip install --quiet gtsam-develop\n",
55+
"except ImportError:\n",
56+
" pass"
4757
]
4858
},
4959
{
@@ -280,4 +290,4 @@
280290
},
281291
"nbformat": 4,
282292
"nbformat_minor": 5
283-
}
293+
}

python/gtsam/examples/FitBasisExample.ipynb

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"metadata": {},
66
"source": [
77
"\n",
8-
"# FitBasis Example (Fourier + Chebyshev)\n",
8+
"# FitBasis (Fourier + Chebyshev)\n",
99
"\n",
1010
"<a href=\"https://colab.research.google.com/github/borglab/gtsam/blob/develop/python/gtsam/examples/FitBasisExample.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n",
1111
"\n",
@@ -42,7 +42,7 @@
4242
},
4343
{
4444
"cell_type": "code",
45-
"execution_count": 12,
45+
"execution_count": 1,
4646
"id": "50e0e944",
4747
"metadata": {
4848
"tags": [
@@ -61,7 +61,7 @@
6161
},
6262
{
6363
"cell_type": "code",
64-
"execution_count": 13,
64+
"execution_count": 2,
6565
"id": "b8cf1aff",
6666
"metadata": {},
6767
"outputs": [],
@@ -76,7 +76,7 @@
7676
},
7777
{
7878
"cell_type": "code",
79-
"execution_count": 14,
79+
"execution_count": 3,
8080
"id": "a040dcaf",
8181
"metadata": {},
8282
"outputs": [],
@@ -97,7 +97,7 @@
9797
},
9898
{
9999
"cell_type": "code",
100-
"execution_count": 15,
100+
"execution_count": 4,
101101
"id": "dab48fee",
102102
"metadata": {},
103103
"outputs": [],
@@ -139,7 +139,7 @@
139139
},
140140
{
141141
"cell_type": "code",
142-
"execution_count": 16,
142+
"execution_count": 5,
143143
"id": "c05c36fa",
144144
"metadata": {},
145145
"outputs": [
@@ -985,12 +985,12 @@
985985
"sequence : dict = {float(xi): float(yi) for xi, yi in zip(x_fourier, y)}\n",
986986
"model = gtsam.noiseModel.Isotropic.Sigma(1, 0.05)\n",
987987
"fit = gtsam.FitBasisFourierBasis(sequence, model, N)\n",
988-
"params = np.asarray(fit.parameters()).ravel()\n",
988+
"params = fit.parameters()\n",
989989
"\n",
990990
"# Extend the time domain to show periodic behavior\n",
991991
"t_dense = np.linspace(-0.5, 1.5, 600)\n",
992992
"x_dense = 2.0 * np.pi * t_dense\n",
993-
"W = np.asarray(gtsam.FourierBasis.WeightMatrix(len(params), x_dense))\n",
993+
"W = gtsam.FourierBasis.WeightMatrix(len(params), x_dense)\n",
994994
"y_fit = W @ params\n",
995995
"\n",
996996
"plot_fit(t, y, t_dense, y_fit, \"FourierBasis Fit (periodic beyond [0, 1])\")\n"
@@ -1014,7 +1014,7 @@
10141014
},
10151015
{
10161016
"cell_type": "code",
1017-
"execution_count": 17,
1017+
"execution_count": 6,
10181018
"id": "ddacb31c",
10191019
"metadata": {},
10201020
"outputs": [
@@ -1860,11 +1860,11 @@
18601860
"sequence = {float(xi): float(yi) for xi, yi in zip(x_cheb, y)}\n",
18611861
"model = gtsam.noiseModel.Isotropic.Sigma(1, 0.05)\n",
18621862
"fit = gtsam.FitBasisChebyshev1Basis(sequence, model, N)\n",
1863-
"params = np.asarray(fit.parameters()).ravel()\n",
1863+
"params = fit.parameters()\n",
18641864
"\n",
18651865
"t_dense = np.linspace(-0.1, 1.1, 600)\n",
18661866
"x_dense = 2.0 * t_dense - 1.0\n",
1867-
"W = np.asarray(gtsam.Chebyshev1Basis.WeightMatrix(len(params), x_dense))\n",
1867+
"W = gtsam.Chebyshev1Basis.WeightMatrix(len(params), x_dense)\n",
18681868
"y_fit = W @ params\n",
18691869
"\n",
18701870
"plot_fit(t, y, t_dense, y_fit, \"Chebyshev1Basis Fit (extrapolation outside [0, 1])\")\n"
@@ -1889,7 +1889,7 @@
18891889
},
18901890
{
18911891
"cell_type": "code",
1892-
"execution_count": 18,
1892+
"execution_count": 7,
18931893
"id": "fc3d1235",
18941894
"metadata": {},
18951895
"outputs": [
@@ -2734,11 +2734,11 @@
27342734
"sequence = {float(xi): float(yi) for xi, yi in zip(x_cheb, y)}\n",
27352735
"model = gtsam.noiseModel.Isotropic.Sigma(1, 0.05)\n",
27362736
"fit = gtsam.FitBasisChebyshev2Basis(sequence, model, N)\n",
2737-
"params = np.asarray(fit.parameters()).ravel()\n",
2737+
"params = fit.parameters()\n",
27382738
"\n",
27392739
"t_dense = np.linspace(-0.1, 1.1, 600)\n",
27402740
"x_dense = 2.0 * t_dense - 1.0\n",
2741-
"W = np.asarray(gtsam.Chebyshev2Basis.WeightMatrix(len(params), x_dense))\n",
2741+
"W = gtsam.Chebyshev2Basis.WeightMatrix(len(params), x_dense)\n",
27422742
"y_fit = W @ params\n",
27432743
"\n",
27442744
"plot_fit(t, y, t_dense, y_fit, \"Chebyshev2Basis Fit (extrapolation outside [0, 1])\")\n"
@@ -2764,7 +2764,7 @@
27642764
},
27652765
{
27662766
"cell_type": "code",
2767-
"execution_count": 19,
2767+
"execution_count": 8,
27682768
"id": "37db92b8",
27692769
"metadata": {},
27702770
"outputs": [
@@ -3625,14 +3625,14 @@
36253625
"sequence = {float(xi): float(yi) for xi, yi in zip(x_cheb, y)}\n",
36263626
"model = gtsam.noiseModel.Isotropic.Sigma(1, 0.05)\n",
36273627
"fit = gtsam.FitBasisChebyshev2(sequence, model, N)\n",
3628-
"params = np.asarray(fit.parameters()).ravel()\n",
3628+
"params = fit.parameters()\n",
36293629
"\n",
36303630
"t_dense = np.linspace(-0.1, 1.1, 600)\n",
36313631
"x_dense = 2.0 * t_dense - 1.0\n",
3632-
"W = np.asarray(gtsam.Chebyshev2.WeightMatrix(len(params), x_dense))\n",
3632+
"W = gtsam.Chebyshev2.WeightMatrix(len(params), x_dense)\n",
36333633
"y_fit = W @ params\n",
36343634
"\n",
3635-
"cheb_points = np.asarray(gtsam.Chebyshev2.Points(N)).ravel()\n",
3635+
"cheb_points = gtsam.Chebyshev2.Points(N)\n",
36363636
"t_cheb = 0.5 * (cheb_points + 1.0)\n",
36373637
"y_cheb = params\n",
36383638
"markers = go.Scatter(x=t_cheb, y=y_cheb, mode=\"markers\", name=\"Chebyshev2 points\", marker=dict(color=\"red\"))\n",
@@ -3649,12 +3649,6 @@
36493649
"\n",
36503650
"Chebyshev points are fixed nodes that cluster near the interval ends; this improves interpolation stability and reduces endpoint oscillations compared to equally spaced nodes (mitigating the Runge phenomenon)."
36513651
]
3652-
},
3653-
{
3654-
"cell_type": "markdown",
3655-
"id": "7d4c0b1d",
3656-
"metadata": {},
3657-
"source": []
36583652
}
36593653
],
36603654
"metadata": {

0 commit comments

Comments
 (0)