Group Abstract Group Abstract

Message Boards Message Boards

0
|
418 Views
|
10 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Help to retrieve hidden cells/part of a notebook

I wonder if anyone can help to solve a - to me - rather mysterious matter. I wrote a notebook containing some calculations. At the beginning of the code, a drop-down menu is presented from which the user can select, by clicking, the input data that the notebook should use. The input data are stored in a GitHub repository, and the purpose of the drop-down menu is just to choose which GitHub input file should be read and downloaded for the subsequent calculations. I wrote the piece representing the drop-down menu with the help of the AI Assistant, because my knowledge was not sufficient to write it.

The notebook worked very well, and it still does. The problem is that now, by opening the notebook, I can only see the visual representation of the drop-down menu, see the attached screenshot. screenshot of the part of the Notebook

However, if I want to see its content, and hence I click on the marker on the right hand side of the margin, the code does not appear, only the expression "Null". This is already seen above the drop-down menu in the attached screenshot, which was taken after I clicked on the marker on the r.h.s. margin.

The true mystery (for me) is that the piece of code, which generates the drop-down menu, must be still there, because THE DROP-DOWN MENU STILL WORKS! My wondering is why I cannot see the hidden piece of code, and how I could make it visible again.

For the information of the kind people who are prepared to help me to solve this puzzle, here is the code (taken from an earlier version of the notebook where it is still visible):

ClearAll["Global`*"]\[IndentingNewLine]Manipulate[\[IndentingNewLine]  data=Import[\[IndentingNewLine]    StringJoin[\[IndentingNewLine]      "https://raw.githubusercontent.com/imre-chalmers-se/IET_book/refs/heads/main/data/active/",\[IndentingNewLine]      fileName,\[IndentingNewLine]      ".json"\[IndentingNewLine]    ],\[IndentingNewLine]    "RawJSON"\[IndentingNewLine]  ];\[IndentingNewLine]  \[IndentingNewLine]  (* Display the imported data or a message *)\[IndentingNewLine]  Column[{\[IndentingNewLine]    "Selected file: " <> fileName <> ".json",\[IndentingNewLine]    "Data preview: ",\[IndentingNewLine]    Short[data]\[IndentingNewLine]  }],\[IndentingNewLine]  \[IndentingNewLine]  {{fileName,"SFR"},{"SFR","Allegro","MSDR","PWRSMR","LWRSMR","MSFR","LFRSMR","FHR"},ControlType->PopupMenu}] 

The notebook itself, from which the above screenshot was taken, is attached to this note. It was also uploaded to the Wolfram Repository, and can be downloaded from the Notebook Archive:

https://notebookarchive.org/2025-05-7dypmeq

The drop-down menu is seen in Section 1: "Select the reactor for the calculations and read the corresponding data file". Clickiing on the cell margin will show the text "Null" instead of the above snippet.

I am very grateful if someone can help solve this mystery. The significance of the matter is that the Notebook in the Archive was used to do the calculations and the plots in the newly published book "Surveillance and Diagnostics of Next Generation Nuclear Reactors", and it is referred to in the book. The readers are encouraged to run the Notebook, reproduce the figures in the book, do calculations with modified input data, or even upload new data to the GitHub repository. The way the data is collected, and the address of the GitHub repository, are in the now invisible snippet; this is why it is important to me to make the content visible. I am grateful for any possible help.

Attachments:
POSTED BY: Imre Pazsit
10 Replies
Posted 1 month ago

Maybe you could consider something that is more simple than Manipulate. With the idea that simple means robust. Here is one example, with the output in a Panel:

Panel[
  Column[{
    PopupMenu[Dynamic@fileName,{"SFR","Allegro","MSDR","PWRSMR","LWRSMR","MSFR","LFRSMR","FHR"}],
    data=Dynamic@Import[
      StringJoin[
        "https://raw.githubusercontent.com/imre-chalmers-se/IET_book/refs/heads/main/data/active/",
        fileName,".json"
      ],
      "RawJSON"
    ]
  }]
]

enter image description here

POSTED BY: Hans Milton

Normally, the code being replaced by Null does not happen to me. It has been a long time since my code has been altered in the way you are experiencing. Maybe fifteen or twenty years, or more. I cannot recall exactly what happened, but the notebook when reopened would be altered. As I say, I cannot recall the details, and I don't have any advice on how to avoid it.

As for the code in the damaged notebook you posted, the original input cell is lost, completely; however, the output cell containing the Manipulate[] panel contains the code for running the Manipulate[]. The output of Manipulate[] always contains the code, except global definitions are not stored and are lost when you restart Mathematica. If you copy the output into an input cell and apply InputForm to it, it will print code to generate the Manipulate[] (<output_cell> // InputForm). In general, it may or may not be the original code, but often it is. Note in your case the code line ClearAll["Global`*"] will be missing.

POSTED BY: Michael Rogers

If I edit the code back into the input cell in place of Null, hide the code, save the notebook, quit Mathematica, reopen the notebook, unhide the code; then code is there and everything seems to be as you wish.

I don't know how the original code was overwritten by Null in the notebook you posted, but the code is no longer in the notebook. It does not happen under normal circumstances, in my experience.

POSTED BY: Michael Rogers
Posted 1 month ago

Ok, I think I understand now. You want the drop-down menu to actually return the downloaded data, and not just return Null and then propagate the data as a “side effect”. Check this:

POSTED BY: Hans Milton
Posted 1 month ago

I get this below if I first evaluate the cell in the Preamble section

enter image description here

POSTED BY: Hans Milton

Thank you very much for this suggestion! I tested it and it works nicely. I will implement it in my notebook, maybe it will be less prone to disappearing!

POSTED BY: Imre Pazsit

Thanks, that explains half of the mystery (at least at my level of understanding...) So the code is not there, but the drop-down menu generated by the code, which performs the reading of the data of the selected reactor core, is still there. Brilliant, thank you very much!

What I still need to understand is why the code disappeared, and how I can protect the notebook that if I copy the snippet back as you described and as I did it in the past, it does not disappear again. This would be a very appreciated piece of information.

POSTED BY: Imre Pazsit

Thank you for your comment. Yes, I was also thinking of this possibility. In fact, quite some time ago (the error appeared several months ago), I did exactly what you suggest. It worked for a while, but the same symptom reappeared after a few days. I wonder if it happens to you as well.

And what is even more mysterious is that the code must still be there, because when I run the version with the "Null", the drop-down menu still supplies the requested data. You can try it by downloading the notebook from the Notebook archive and running it.

POSTED BY: Imre Pazsit

Thank you very much for devoting more attention to this. I apologise for being difficult, but this is still not what I want. It is not the results of an operation/command which I am looking for, rather for the piece of code which creates the drop-down menu and the reading commands.

I can illustrate it by using an earlier version of the Notebook, where I can still make the content of the cell visible. In that older version, when I open the notebook, still the same drop-down menu is visible as in the recent code (that you also run), but the code generating it is hidden: The drop-down menu without the code

Now to make the code visible, I click on the vertical line second from the left at the right margin (the one which has a semi-arrow on the top), to make the rest of the cell visible, and then it looks like this: The full content of the cell

This is what I cannot achieve with the current Notebook, i.e. to make the piiece of code visitble above the drop-down menu. The vertical lines on the right hand side margin look different (see the included figure in my original post, i.e. on the top of this conversation). And if I click on the right hand side line (which is marked blue in the figure), then, instead of the piece of code shown in the last figure above, only the text "Null" appears (again, this is also shown in the first figure).

But the piece of code is still in my Notebook, since the drop-down menu still works, but I cannot make it visible. I want this piece of code to be possible to make visible, because this is from where the users can find out the data of the GitHub repository, if they want to upload further data (as I ask them in the book, which refers to the Notebook in the Repository.

I would appreciate very much if you could help me to make the code "snippet" visible.

POSTED BY: Imre Pazsit

Thank you for looking at this. The post you show confirms that the cell works, because your notebook successfully read the data corresponding to the SFR (Sodium Fast Reactor) core.

My problem is that I cannot make the content of the cell visible, which performs the reading through the choice in the drop-down menu.

POSTED BY: Imre Pazsit
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard