Skip to content

Commit 2d55cd0

Browse files
Merge pull request #93 from Stanford-NavLab/derek/namespacing
Derek/namespacing
2 parents b825613 + 2fed9a9 commit 2d55cd0

9 files changed

Lines changed: 106 additions & 71 deletions

File tree

docs/source/contributing/development.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Standard GitHub Workflow
4141
:code:`docs/source/index.rst` to match the :code:`README.md`
4242
* add a section in the appropriate tutorial notebook located in
4343
:code:`notebooks/tutorials/*`
44+
* if the feature is in a new file, import the file in the
45+
`module's import block <https://github.com/Stanford-NavLab/gnss_lib_py/blob/main/gnss_lib_py/__init__.py>`__.
4446

4547
5. Add tests for the newly added code and ensure the new code is covered.
4648
See the :ref:`Testing<testing>` section for more details.
@@ -133,6 +135,8 @@ NAVLab GitHub Workflow
133135
:code:`docs/source/index.rst` to match the :code:`README.md`
134136
* add a section in the appropriate tutorial notebook located in
135137
:code:`notebooks/tutorials/*`
138+
* if the feature is in a new file, import the file in the
139+
`module's import block <https://github.com/Stanford-NavLab/gnss_lib_py/blob/main/gnss_lib_py/__init__.py>`__.
136140

137141
5. Add tests for the newly added code and ensure the new code is covered.
138142
See the :ref:`Testing<testing>` section for more details.
@@ -242,6 +246,8 @@ Pull Request Review Workflow
242246
* the appropriate tutorial notebook located in
243247
:code:`notebooks/tutorials/*` with a simple example of the new
244248
functionality
249+
* if a new file was created, it should likely be imported in the
250+
`module's import block <https://github.com/Stanford-NavLab/gnss_lib_py/blob/main/gnss_lib_py/__init__.py>`__.
245251

246252
4. Verify that all tests run on your system:
247253

gnss_lib_py/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Handle version and add submodules to gnss_lib_py namesppace."""
2+
3+
from importlib import metadata
4+
5+
# import submodules into gnss_lib_py namespace
6+
from gnss_lib_py.algorithms.gnss_filters import *
7+
from gnss_lib_py.algorithms.residuals import *
8+
from gnss_lib_py.algorithms.snapshot import *
9+
10+
from gnss_lib_py.parsers.android import *
11+
from gnss_lib_py.parsers.ephemeris import *
12+
from gnss_lib_py.parsers.navdata import *
13+
from gnss_lib_py.parsers.precise_ephemerides import *
14+
15+
from gnss_lib_py.utils.coordinates import *
16+
from gnss_lib_py.utils.filters import *
17+
from gnss_lib_py.utils.sim_gnss import *
18+
from gnss_lib_py.utils.time_conversions import *
19+
from gnss_lib_py.utils.visualizations import *
20+
21+
# single location of version exists in pyproject.toml
22+
__version__ = metadata.version("gnss-lib-py")

notebooks/timing_comparisons.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"outputs": [],
4343
"source": [
4444
"SETUP_CODE = '''\n",
45-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
45+
"from gnss_lib_py import AndroidDerived2021\n",
4646
"\n",
4747
"# load Android Google Challenge data\n",
4848
"navdata = AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)\n",
@@ -74,7 +74,7 @@
7474
"SETUP_CODE = '''\n",
7575
"import pandas as pd\n",
7676
"\n",
77-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
77+
"from gnss_lib_py import AndroidDerived2021\n",
7878
"\n",
7979
"# load Android Google Challenge data\n",
8080
"df = pd.read_csv(\"Pixel4XL_derived.csv\")\n",
@@ -107,7 +107,7 @@
107107
"SETUP_CODE = '''\n",
108108
"import pandas as pd\n",
109109
"\n",
110-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
110+
"from gnss_lib_py import AndroidDerived2021\n",
111111
"\n",
112112
"# load Android Google Challenge data\n",
113113
"df = pd.read_csv(\"Pixel4XL_derived.csv\")\n",

notebooks/tutorials/algorithms.ipynb

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
19-
"from gnss_lib_py.algorithms.snapshot import solve_wls\n",
20-
"from gnss_lib_py.utils.visualizations import plot_map"
18+
"import gnss_lib_py as glp"
2119
]
2220
},
2321
{
@@ -29,7 +27,7 @@
2927
"source": [
3028
"# load Android Google Challenge data\n",
3129
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/android_2021/Pixel4XL_derived.csv --quiet -O \"Pixel4XL_derived.csv\"\n",
32-
"derived_data = AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)"
30+
"derived_data = glp.AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)"
3331
]
3432
},
3533
{
@@ -47,7 +45,7 @@
4745
"metadata": {},
4846
"outputs": [],
4947
"source": [
50-
"state_wls = solve_wls(derived_data)"
48+
"state_wls = glp.solve_wls(derived_data)"
5149
]
5250
},
5351
{
@@ -65,7 +63,7 @@
6563
"metadata": {},
6664
"outputs": [],
6765
"source": [
68-
"plot_map(state_wls)"
66+
"glp.plot_map(state_wls)"
6967
]
7068
},
7169
{
@@ -83,9 +81,7 @@
8381
"metadata": {},
8482
"outputs": [],
8583
"source": [
86-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
87-
"from gnss_lib_py.algorithms.gnss_filters import solve_gnss_ekf\n",
88-
"from gnss_lib_py.utils.visualizations import plot_map"
84+
"import gnss_lib_py as glp"
8985
]
9086
},
9187
{
@@ -97,7 +93,7 @@
9793
"source": [
9894
"# load Android Google Challenge data\n",
9995
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/android_2021/Pixel4XL_derived.csv --quiet -O \"Pixel4XL_derived.csv\"\n",
100-
"derived_data = AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)"
96+
"derived_data = glp.AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)"
10197
]
10298
},
10399
{
@@ -117,7 +113,7 @@
117113
},
118114
"outputs": [],
119115
"source": [
120-
"state_ekf = solve_gnss_ekf(derived_data)"
116+
"state_ekf = glp.solve_gnss_ekf(derived_data)"
121117
]
122118
},
123119
{
@@ -135,7 +131,7 @@
135131
"metadata": {},
136132
"outputs": [],
137133
"source": [
138-
"plot_map(state_ekf)"
134+
"glp.plot_map(state_ekf)"
139135
]
140136
},
141137
{
@@ -153,8 +149,28 @@
153149
"metadata": {},
154150
"outputs": [],
155151
"source": [
156-
"from gnss_lib_py.algorithms.residuals import solve_residuals\n",
157-
"from gnss_lib_py.utils.visualizations import plot_metric_by_constellation\n",
152+
"import gnss_lib_py as glp"
153+
]
154+
},
155+
{
156+
"cell_type": "code",
157+
"execution_count": null,
158+
"id": "12285e7e",
159+
"metadata": {},
160+
"outputs": [],
161+
"source": [
162+
"# load Android Google Challenge data\n",
163+
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/android_2021/Pixel4XL_derived.csv --quiet -O \"Pixel4XL_derived.csv\"\n",
164+
"derived_data = glp.AndroidDerived2021(\"Pixel4XL_derived.csv\", remove_timing_outliers=False)"
165+
]
166+
},
167+
{
168+
"cell_type": "code",
169+
"execution_count": null,
170+
"id": "e92db703",
171+
"metadata": {},
172+
"outputs": [],
173+
"source": [
158174
"galileo_data = derived_data.where(\"gnss_id\",\"galileo\")"
159175
]
160176
},
@@ -173,7 +189,7 @@
173189
"metadata": {},
174190
"outputs": [],
175191
"source": [
176-
"solve_residuals(galileo_data, state_wls, inplace=True)"
192+
"glp.solve_residuals(galileo_data, state_wls, inplace=True)"
177193
]
178194
},
179195
{
@@ -191,7 +207,7 @@
191207
"metadata": {},
192208
"outputs": [],
193209
"source": [
194-
"figs = plot_metric_by_constellation(galileo_data, \"gps_millis\", \"residuals_m\")"
210+
"figs = glp.plot_metric_by_constellation(galileo_data, \"gps_millis\", \"residuals_m\")"
195211
]
196212
}
197213
],

notebooks/tutorials/coordinates.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"outputs": [],
1515
"source": [
1616
"import numpy as np\n",
17-
"from gnss_lib_py.utils import coordinates as coord"
17+
"import gnss_lib_py as glp"
1818
]
1919
},
2020
{
@@ -34,11 +34,11 @@
3434
"# Using the LLA coordinates the Aero/Astro department at Stanford University\n",
3535
"x_lla = np.array([[37.427112], [-122.1764146], [16]])\n",
3636
"print('Converted ECEF coordinates')\n",
37-
"print(coord.geodetic_to_ecef(x_lla))\n",
37+
"print(glp.geodetic_to_ecef(x_lla))\n",
3838
"\n",
3939
"x_ecef = np.array([[-2700628], [-4292443], [3855152]])\n",
4040
"print('Converted LLA coordinates')\n",
41-
"print(coord.ecef_to_geodetic(x_ecef))"
41+
"print(glp.ecef_to_geodetic(x_ecef))"
4242
]
4343
},
4444
{
@@ -64,11 +64,11 @@
6464
"outputs": [],
6565
"source": [
6666
"# Instantiate using LLA coordinates\n",
67-
"local_frame = coord.LocalCoord.from_geodetic(x_lla)\n",
67+
"local_frame = glp.LocalCoord.from_geodetic(x_lla)\n",
6868
"print('NED to ECEF conversion matrix for initialized local frame')\n",
6969
"print(local_frame.ned_to_ecef_matrix)\n",
7070
"\n",
71-
"local_frame = coord.LocalCoord.from_geodetic(x_ecef)\n",
71+
"local_frame = glp.LocalCoord.from_geodetic(x_ecef)\n",
7272
"print('NED to ECEF conversion matrix for initialized local frame')\n",
7373
"print(local_frame.ned_to_ecef_matrix)"
7474
]
@@ -143,8 +143,8 @@
143143
"metadata": {},
144144
"outputs": [],
145145
"source": [
146-
"from gnss_lib_py.utils.coordinates import ecef_to_el_az\n",
147-
"from gnss_lib_py.parsers.android import AndroidDerived2022\n",
146+
"from gnss_lib_py import ecef_to_el_az\n",
147+
"from gnss_lib_py import AndroidDerived2022\n",
148148
"\n",
149149
"# load Android Google Challenge data\n",
150150
"!wget https://raw.githubusercontent.com/Stanford-NavLab/gnss_lib_py/main/data/unit_test/android_2022/device_gnss.csv --quiet -O \"device_gnss.csv\"\n",

notebooks/tutorials/navdata.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"import numpy as np\n",
1010
"import pandas as pd\n",
1111
"\n",
12-
"from gnss_lib_py.parsers.navdata import NavData"
12+
"from gnss_lib_py import NavData"
1313
]
1414
},
1515
{

notebooks/tutorials/parsers.ipynb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"metadata": {},
3232
"outputs": [],
3333
"source": [
34-
"from gnss_lib_py.parsers.android import AndroidDerived2022"
34+
"from gnss_lib_py import AndroidDerived2022"
3535
]
3636
},
3737
{
@@ -99,7 +99,7 @@
9999
"metadata": {},
100100
"outputs": [],
101101
"source": [
102-
"from gnss_lib_py.parsers.android import AndroidGroundTruth2022"
102+
"from gnss_lib_py import AndroidGroundTruth2022"
103103
]
104104
},
105105
{
@@ -161,7 +161,7 @@
161161
"metadata": {},
162162
"outputs": [],
163163
"source": [
164-
"from gnss_lib_py.parsers.android import solve_kaggle_baseline\n",
164+
"from gnss_lib_py import solve_kaggle_baseline\n",
165165
"\n",
166166
"state_estimate = solve_kaggle_baseline(derived_data)\n",
167167
"\n",
@@ -183,7 +183,7 @@
183183
"metadata": {},
184184
"outputs": [],
185185
"source": [
186-
"from gnss_lib_py.parsers.android import prepare_kaggle_submission\n",
186+
"from gnss_lib_py import prepare_kaggle_submission\n",
187187
"\n",
188188
"solution = prepare_kaggle_submission(state_estimate, trip_id = \"my_trace/my_phone\")\n",
189189
"\n",
@@ -205,8 +205,8 @@
205205
"metadata": {},
206206
"outputs": [],
207207
"source": [
208-
"from gnss_lib_py.parsers.android import solve_kaggle_dataset\n",
209-
"from gnss_lib_py.algorithms.snapshot import solve_wls\n",
208+
"from gnss_lib_py import solve_kaggle_dataset\n",
209+
"from gnss_lib_py import solve_wls\n",
210210
"\n",
211211
"# submission = solve_kaggle_dataset(folder_path = \"/path/to/train/or/test/folder/\", \n",
212212
"# solver = solve_wls)\n",
@@ -238,7 +238,7 @@
238238
"metadata": {},
239239
"outputs": [],
240240
"source": [
241-
"from gnss_lib_py.parsers.android import AndroidDerived2021"
241+
"from gnss_lib_py import AndroidDerived2021"
242242
]
243243
},
244244
{
@@ -306,7 +306,7 @@
306306
"metadata": {},
307307
"outputs": [],
308308
"source": [
309-
"from gnss_lib_py.parsers.android import AndroidGroundTruth2021"
309+
"from gnss_lib_py import AndroidGroundTruth2021"
310310
]
311311
},
312312
{
@@ -383,8 +383,8 @@
383383
"metadata": {},
384384
"outputs": [],
385385
"source": [
386-
"from gnss_lib_py.parsers.precise_ephemerides import multi_gnss_from_precise_eph\n",
387-
"from gnss_lib_py.parsers.android import AndroidDerived2021\n",
386+
"from gnss_lib_py import multi_gnss_from_precise_eph\n",
387+
"from gnss_lib_py import AndroidDerived2021\n",
388388
"import numpy as np\n",
389389
"\n",
390390
"# load Android Google Challenge data\n",
@@ -656,7 +656,7 @@
656656
"metadata": {},
657657
"outputs": [],
658658
"source": [
659-
"from gnss_lib_py.parsers.navdata import NavData\n",
659+
"from gnss_lib_py import NavData\n",
660660
"\n",
661661
"class MyReceiver(NavData):\n",
662662
" \"\"\"Class handling measurements from MyReceiver.\n",
@@ -758,7 +758,7 @@
758758
"metadata": {},
759759
"outputs": [],
760760
"source": [
761-
"from gnss_lib_py.utils.visualizations import plot_metric\n",
761+
"from gnss_lib_py import plot_metric\n",
762762
"fig = plot_metric(my_receiver_data,\"gps_millis\",\"corr_pr_m\",groupby=\"sv_id\")"
763763
]
764764
}

0 commit comments

Comments
 (0)