avoid Lexing with ipynb? #41
-
|
When using ipynb files in Teachbook, because I also want students to download such file and run the code in a jupyter notebook locally, I encounter a failure on the workflow summarize on Lexing, like: /home/runner/work/TeachBook/TeachBook/book/EI_manuals/16C_Light_Sensor_STUDENT.ipynb:230002: WARNING: Lexing literal_block '# ## Settings\n\n# Define the the scales for the measurement\ndesired_num_samples = 2000 # a number of samples you want - it will be adapted for use with fft\nDELAY_MS = 2 # 2ms is the lowest value possible\n\n# Declare the values of the components used in your oscillator\nC = ?? # Capacitance in Farads, so 1e9 for 1nF\nRa = ?? # Use the notation 1e3 for 1k\nRb = ??\nRc = ??\n\n# Parameters (do not change)\nRlambda = 0.62 # A/W\nAphotodiode = 1e-6 #m^2\n\n# Simplifications (do not change)\ndV = 2Ra/Rb10.8 # Voltage range (Vhigh_threshold - Vlow_threshold) in Volts\nIdiode = 10.8/Rc # Amps\n\n### Pre-configure (do not change)\nNUM_SAMPLES = nearest_power_of_2(desired_num_samples) # Adjusted to nearest power of 2 for fft' as "ipython3" resulted in an error at token: '?'. Retrying in relaxed mode. When removing the files causing the Lexing warning, the workflow summary is successfull. So therefore I deduct the Lexing is causing it, but I have no idea what to do about it. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
|
Hi @mwdocter , interesting. can you share a link to the repo? I've a hard time understanding exactly what's going on. |
Beta Was this translation helpful? Give feedback.
-
|
To be honest I think it is just the question marks in the Python code of the notebook. I am guessing that this is a notebook file in a book, which probably has Anyway, a link will help confirm. At least an explanation of the context since I also am not sure exactly what generated your output. Here is the warning block reformatted as code and reworked with line breaks to make more readable: /home/runner/work/TeachBook/TeachBook/book/EI_manuals/16C_Light_Sensor_STUDENT.ipynb:230002:
WARNING: Lexing literal_block# ## Settings
# Define the the scales for the measurement\ndesired_num_samples = 2000
# a number of samples you want - it will be adapted for use with fft
DELAY_MS = 2 # 2ms is the lowest value possible
# Declare the values of the components used in your oscillator
C = ?? # Capacitance in Farads, so 1e9 for 1nF
Ra = ?? # Use the notation 1e3 for 1k\nRb = ??\nRc = ??
# Parameters (do not change)
Rlambda = 0.62 # A/W
Aphotodiode = 1e-6 #m^2
# Simplifications (do not change)
dV = 2*Ra/Rb*10.8 # Voltage range (Vhigh_threshold - Vlow_threshold) in Volts
Idiode = 10.8/Rc # Amps\n\n### Pre-configure (do not change)
NUM_SAMPLES = nearest_power_of_2(desired_num_samples) # Adjusted to nearest power of 2 for fftas "ipython3" resulted in an error at token: '?'. Retrying in relaxed mode. |
Beta Was this translation helpful? Give feedback.
-
|
I opted for leaving the executables in (and accept the error), since I am not aiming for the most perfect book, but merely for a distribution method of ipynb files with a nice preview online. |
Beta Was this translation helpful? Give feedback.
-
I completely understand. In that case, then yes, just make the notebook look the way you want with outputs saved, then commit to repo. Another question: do you want students to download the file without outputs? You can do this with the Download Link Replacer! It requires maintaining a copy of the file with outputs deleted, but as a teacher it is well worth the effort to customize the student experience. Another application would be if you have student and solution versions (with and without solutions)...the DLR makes it easy to share files at specific moments while still being able to view one version online (e.g., the solutoin of the orginal assignment). Its described here https://teachbooks.io/manual/external/Download-Link-Replacer/README.html |
Beta Was this translation helpful? Give feedback.
-
|
I figured out how to avoid the Lexing: whenever having a fill in part in the python block, use ... instead of ?? |
Beta Was this translation helpful? Give feedback.
To be honest I think it is just the question marks in the Python code of the notebook. I am guessing that this is a notebook file in a book, which probably has
execute_notebooks: autoin_config.yml. See more here.Anyway, a link will help confirm. At least an explanation of the context since I also am not sure exactly what generated your output. Here is the warning block reformatted as code and reworked with line breaks to make more readable: