Skip to content

Commit d53d9bb

Browse files
authored
Documentation fix (#162)
* The installation process is updated * Some errors that were not alowing to build the documentation were fixed * Some fixing in the documentation generation were made. * Some code cleanup and update of docstrings
1 parent 6a549fb commit d53d9bb

14 files changed

+402
-156
lines changed

doc/conf.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
"nbsphinx",
4747
]
4848

49+
# The warnings should not be generated in the documentation, so we suppress them.
50+
# This may create issues later on, so be careful.
51+
suppress_warnings = [
52+
'nbsphinx',
53+
]
4954
apidoc_module_dir = "../pyoptools"
5055
apidoc_output_dir = ""
5156
apidoc_excluded_paths = ["doc"]
@@ -227,10 +232,3 @@
227232
# If false, no module index is generated.
228233
# latex_use_modindex = True
229234

230-
nbsphinx_prolog = """
231-
.. warning::
232-
There is an issue with the generation of documentation from notebooks,
233-
such as this page, that causes interactive plots generated using the
234-
Plot3D function to appear incorrect. The examples should produce correct
235-
3D plots when executed directly in Jupyter Lab.
236-
"""

doc/install.rst

+25-38
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,43 @@ pyOpTools can be downloaded from the project GitHub repository at:
1111
Installing via pip
1212
------------------
1313

14-
On Windows, Mac OS and Linux you can use `pip`` to install pyOpTools.
14+
No matter if you're using Windows, Mac OS, or Linux, you can easily install
15+
pyOpTools. Jupyter Lab is a dependency of the pyoptools package, so it will
16+
also be installed automatically when you install pyoptools using `pip`. Using
17+
the installed Jupyter Lab you should be able to run all the examples in this
18+
documentation without any trouble.
1519

16-
pip install pyoptools
17-
18-
This will install the latest available version of pyoptools.
19-
20-
Installing it in Debian 11 (should work on any Debian derivative)
21-
-----------------------------------------------------------------
22-
23-
pyOpTools is being developed almost exclusively using "Debian derivative" Linux
24-
distributions, so this installation procedure is the most tested and reliable. To
25-
generate the pyoptool .deb package you just need to run the following command in the project root::
20+
Just run this command:
2621

27-
make deb
22+
.. code-block:: bash
2823
29-
This will create a .deb package outside the pyOpTool's source root tree. This can be installed using the command::
24+
pip install pyoptools
3025
31-
dpkg -i python3-pyoptools_<version>_<platform>.deb
26+
This will install the latest version of pyoptools along with Jupyter Lab, so
27+
you're all set to run the examples hassle-free.
3228

33-
where version/platform should be adjusted accordingly.
3429

30+
Installing it in Debian 12 (should work on any Debian derivative)
31+
-----------------------------------------------------------------
3532

36-
Installing pyOpTools inside a python virtualenv
37-
-----------------------------------------------
33+
The preferred method for installing pyOpTools, particularly on "Debian derivative"
34+
Linux distributions, is to install it as a system package. To generate the
35+
pyoptools .deb package, simply navigate to the project root and execute the
36+
following command:
3837

39-
After a Python3 virtualenv is created and activated, pyOpTools can be installed by running the following command, inside the project root::
40-
41-
pip install -r requirements.txt
42-
python3 setup.py install
43-
44-
.. _visualizing_pyoptools_in_jupyter:
38+
.. code-block:: bash
4539
46-
Visualizing pyOpTools simulations in a JupyterLab notebook
47-
----------------------------------------------------------
40+
make deb
4841
49-
Before being able to visualize pyOpTools simulations in a
50-
`jupyterlab <https://jupyter.org>`_ Notebook, pythreejs must be enabled::
42+
Executing this command will generate a .deb package outside the pyOpTool's
43+
source root tree. To install the generated package, use the following command:
5144

52-
jupyter labextension install jupyter-threejs
45+
.. code-block:: bash
5346
54-
after this is done, you will be able to visualize the simulations using
55-
the :func:`~pyoptools.gui.ipywidgets.Plot3D` command. JupyterLab and pythreejs
56-
are listed in the requirements.txt file so there is no need to install them
57-
separetelly.
47+
dpkg -i python3-pyoptools_<version>_<platform>.deb
5848
5949
60-
The plot window is interactive. Using the mouse, it is possible to rotate
61-
the image by click and drag with the left button, zoom by using the scroll
62-
wheel and translate by click and drag with the right button.
50+
Make sure to adjust the <version> and <platform> parameters accordingly. This
51+
method eliminates the need for virtual environments and ensures a smooth
52+
installation process.
6353

64-
.. note ::
65-
Please do not run jupyter lab from the pyOpTools source code directory.
66-
pyOptools modules will not import correctly.

doc/modules.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pyoptools
2+
=========
3+
4+
.. toctree::
5+
:maxdepth: 4
6+
7+
pyoptools

doc/notebooks/basic/00-Intro.ipynb

+6-3
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@
9393
"metadata": {},
9494
"outputs": [],
9595
"source": [
96-
"L=library.Edmund.get(\"32475\")\n",
97-
"SEN=CCD(size=(20,20))\n",
96+
"L=library.Edmund[\"32475\"]\n",
97+
"SEN=CCD(size=(20,20))#c.rotateZ(D[2])\n",
98+
" #c.rotateY(D[1])\n",
99+
" #c.rotateX(D[0])\n",
100+
"\n",
98101
"R=parallel_beam_c(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0.0), \n",
99102
" size=(10, 10), num_rays=(5, 5), wavelength=0.58929)"
100103
]
@@ -181,7 +184,7 @@
181184
"name": "python",
182185
"nbconvert_exporter": "python",
183186
"pygments_lexer": "ipython3",
184-
"version": "3.10.6"
187+
"version": "3.11.2"
185188
}
186189
},
187190
"nbformat": 4,

doc/notebooks/basic/SimpleComponents.ipynb

+14-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18-
"from pyoptools.all import *\n",
18+
"from pyoptools.all import *\n",
1919
"from numpy import pi,sqrt"
2020
]
2121
},
@@ -57,7 +57,7 @@
5757
"\n",
5858
"**surflist**\n",
5959
"\n",
60-
"> List of tuples of the form `(surface, (PosX,PosY,PosZ), (RotX,RotY,RotZ)` where `surface` is an [instance of a subclass](pyoptools.raytrace.surface.rst) of [Surface](../../pyoptools.raytrace.surface.surface.rst), `PosX,PosY,PosZ`are the surface’s vertex coordinates, and `RotX,RotY,RotZ` are the rotation angles of the surface around the X , Y , and Z axes, given in radians. The rotation about the Z axis if applied first, then the rotation about the Y axis, and finally the rotation about the X axis.\n",
60+
"> List of tuples of the form `(surface, (PosX,PosY,PosZ), (RotX,RotY,RotZ)` where `surface` is an instance of a subclass of [Surface](../../pyoptools.raytrace.surface.surface.rst), `PosX,PosY,PosZ`are the surface’s vertex coordinates, and `RotX,RotY,RotZ` are the rotation angles of the surface around the X , Y , and Z axes, given in radians. The rotation about the Z axis if applied first, then the rotation about the Y axis, and finally the rotation about the X axis.\n",
6161
"\n",
6262
"**material**\n",
6363
"\n",
@@ -119,7 +119,7 @@
119119
" (b_face,(width/2,0,0),(0,pi/2,0)),\n",
120120
" (h_face,(0,0,0),(0,-pi/4,0)),\n",
121121
" (e1,(0,height/2,0),(pi/2,-pi/2,0)),\n",
122-
" (e2,(0,height/2,0),(pi/2,-pi/2,0))\n",
122+
" (e2,(0,-height/2,0),(pi/2,-pi/2,0))\n",
123123
" ],material=material.schott[\"N-BK7\"])\n",
124124
"Plot3D(P,size=(120,120),scale=3,rot=[(pi/6,pi/8,0)])"
125125
]
@@ -167,7 +167,7 @@
167167
" (b_face,(width/2,0,0),(0,pi/2,0)),\n",
168168
" (h_face,(0,0,0),(0,-pi/4,0)),\n",
169169
" (e1,(0,height/2,0),(pi/2,-pi/2,0)),\n",
170-
" (e2,(0,height/2,0),(pi/2,-pi/2,0))\n",
170+
" (e2,(0,-height/2,0),(pi/2,-pi/2,0))\n",
171171
" ],material=material.schott[\"N-BK7\"])\n",
172172
" return P\n",
173173
"P1=prism()\n",
@@ -178,6 +178,13 @@
178178
"Plot3D(cube,size=(120,120),scale=3,rot=[(pi/6,pi/8,0)])"
179179
]
180180
},
181+
{
182+
"cell_type": "code",
183+
"execution_count": null,
184+
"metadata": {},
185+
"outputs": [],
186+
"source": []
187+
},
181188
{
182189
"cell_type": "code",
183190
"execution_count": null,
@@ -188,7 +195,7 @@
188195
],
189196
"metadata": {
190197
"kernelspec": {
191-
"display_name": "Python 3",
198+
"display_name": "Python 3 (ipykernel)",
192199
"language": "python",
193200
"name": "python3"
194201
},
@@ -202,9 +209,9 @@
202209
"name": "python",
203210
"nbconvert_exporter": "python",
204211
"pygments_lexer": "ipython3",
205-
"version": "3.8.6"
212+
"version": "3.11.2"
206213
}
207214
},
208215
"nbformat": 4,
209-
"nbformat_minor": 1
216+
"nbformat_minor": 4
210217
}

doc/notebooks/basic/SimpleRayTraces.ipynb

+2-4
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,8 @@
511511
]
512512
},
513513
{
514-
"cell_type": "code",
515-
"execution_count": null,
514+
"cell_type": "raw",
516515
"metadata": {},
517-
"outputs": [],
518516
"source": [
519517
"r_b= parallel_beam_c(size=(2,2),num_rays=(5,5), wavelength=.650)\n",
520518
"\n",
@@ -713,7 +711,7 @@
713711
"name": "python",
714712
"nbconvert_exporter": "python",
715713
"pygments_lexer": "ipython3",
716-
"version": "3.10.6"
714+
"version": "3.11.2"
717715
}
718716
},
719717
"nbformat": 4,

doc/notebooks/basic/materials.ipynb

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Materials"
8+
]
9+
},
310
{
411
"cell_type": "raw",
512
"metadata": {},
@@ -31,7 +38,7 @@
3138
],
3239
"metadata": {
3340
"kernelspec": {
34-
"display_name": "Python 3",
41+
"display_name": "Python 3 (ipykernel)",
3542
"language": "python",
3643
"name": "python3"
3744
},
@@ -45,9 +52,9 @@
4552
"name": "python",
4653
"nbconvert_exporter": "python",
4754
"pygments_lexer": "ipython3",
48-
"version": "3.8.6"
55+
"version": "3.11.2"
4956
}
5057
},
5158
"nbformat": 4,
52-
"nbformat_minor": 2
59+
"nbformat_minor": 4
5360
}

doc/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ nbsphinx
1818
imageio
1919
PyYAML
2020
importlib_resources
21+
sympy
22+
ijson
File renamed without changes.

0 commit comments

Comments
 (0)