Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index and value errors in Chapter 3 #21

Closed
AleBeda opened this issue Feb 3, 2022 · 4 comments · Fixed by #27
Closed

Index and value errors in Chapter 3 #21

AleBeda opened this issue Feb 3, 2022 · 4 comments · Fixed by #27
Labels
bug Something isn't working

Comments

@AleBeda
Copy link

AleBeda commented Feb 3, 2022

In Chapter 3 there are several index errors (caused by wrong ⎕IO setting) and some value errors, as shown in the screenshots. (A few errors of course are supposed to be there and on purpose.)

Screen Shot 2022-02-03 at 12 31 40 PM

Screen Shot 2022-02-03 at 12 32 01 PM

Screen Shot 2022-02-03 at 12 32 36 PM

Screen Shot 2022-02-03 at 12 33 18 PM

Screen Shot 2022-02-03 at 12 33 35 PM

Screen Shot 2022-02-03 at 12 33 48 PM

Screen Shot 2022-02-03 at 12 34 23 PM

I am viewing the book on Safari on macOS 10.14.16 (Mojave). I reloaded the web page.
I have exactly the same problem on the iPad.

@rodrigogiraoserrao rodrigogiraoserrao added the bug Something isn't working label Feb 3, 2022
@rodrigogiraoserrao
Copy link
Contributor

Thanks for reporting this, this is not your fault. I rebuilt the book recently and I think the book generation is picking up the wrong settings.
Working on fixing this.

@rodrigogiraoserrao
Copy link
Contributor

rodrigogiraoserrao commented Feb 3, 2022

It's odd that higher up in the chapter, indexing is being done with ⎕IO ← 1.

In section 3.6, indexing is still ⎕IO ← 1-based, as is proven by the indexing into prod in the examples.

Further down the chapter, there are some interactions with workspaces, loading and saving things. Maybe one of those is interfering with ⎕IO..? Will keep investigating.

@AleBeda
Copy link
Author

AleBeda commented Feb 3, 2022

@rodrigogiraoserrao for long chapters, it may be worthwhile doing some defensive coding and resetting the interpreter to known conditions in various points in the chapter with the hide-input tag, and possibly the hide-output tag as well.

@rodrigogiraoserrao
Copy link
Contributor

@rodrigogiraoserrao for long chapters, it may be worthwhile doing some defensive coding and resetting the interpreter to known conditions in various points in the chapter with the hide-input tag, and possibly the hide-output tag as well.

I understand what you mean, but I don't get why you suggest that: the notebooks are written in a linear sequence, and each chapter starts with a clean session.
Thus, in theory, the state is always known and fairly well controlled.

As for this issue, I am still trying to figure out what is happening, because opening the chapter notebook on my computer and re-executing the whole notebook doesn't result in any issues whatsoever.
It's only when I build the book through jupyter-book that this problem arises.

rodrigogiraoserrao added a commit that referenced this issue Feb 9, 2022
The INDEX ERRORs that were happening arose because the MyPreciousWs that was being loaded in the section about workspaces had been saved, somehow, with ⎕IO ← 0, which meant that loading it was throwing off the remainder of the calculations.

Supposedly, this issue would never really arise because the workspace was first being saved from within the notebook, and only then loaded. However, because the workspace already existed in the �ook folder, the first attempt to )save it was failing: the current workspace was the clear workspace and we were trying to save on top of a named workspace.

To fix this, I had to delete the MyPreciousWs from the �ook folder and re-execute the whole notebook, to both save a fresh copy of the workspace & to display the correct save message next to the )save command.
This commit includes a couple of immaterial changes to code cells which were used to force the re-execution of the (cached) notebook, a workaround that will hopefull be addressed with jupyter-book/jupyter-book#1633.

Thoughts for the future include adding a preprocessing step where the MyPreciousWs is always deleted from the �ook folder (to make sure that the command )save always works) or a hidden cell in the notebook that deletes the workspace before saving.
rodrigogiraoserrao added a commit that referenced this issue Feb 9, 2022
The INDEX ERRORs that were happening arose because the MyPreciousWs that was being loaded in the section about workspaces had been saved, somehow, with ⎕IO ← 0, which meant that loading it was throwing off the remainder of the calculations.

Supposedly, this issue would never really arise because the workspace was first being saved from within the notebook, and only then loaded. However, because the workspace already existed in the book folder, the first attempt to )save it was failing: the current workspace was the clear workspace and we were trying to save on top of a named workspace.

To fix this, I had to delete the MyPreciousWs from the book folder and re-execute the whole notebook, to both save a fresh copy of the workspace & to display the correct save message next to the )save command.
This commit includes a couple of immaterial changes to code cells which were used to force the re-execution of the (cached) notebook, a workaround that will hopefull be addressed with jupyter-book/jupyter-book#1633.

Thoughts for the future include adding a preprocessing step where the MyPreciousWs is always deleted from the book folder (to make sure that the command )save always works) or a hidden cell in the notebook that deletes the workspace before saving.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants