Strange behavior of Out[] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How do I extract the contents of a selected cell as plain text?How to make a parallel auto-generated .m package from Initialization cells?Making flash cards with MathematicaDifference between double quotesHow is CellContext->CellGroup supposed to work?Automatic shading of all InitializationCell->True cells in older versions“Find currently evaluating cell” does not seem to work correctlyExporting notebooks inserts unwanted $CellContext. Workaround?Stop notebook from auto-scrolling upon printingDocked Cell Slider that controls magnification of Output Cells only

IC on Digikey is 5x more expensive than board containing same IC on Alibaba: How?

Is the Mordenkainen's Sword spell underpowered?

How does TikZ render an arc?

What does Sonny Burch mean by, "S.H.I.E.L.D. and HYDRA don't even exist anymore"?

Dinosaur Word Search, Letter Solve, and Unscramble

Fit odd number of triplets in a measure?

Any stored/leased 737s that could substitute for grounded MAXs?

How do you cope with tons of web fonts when copying and pasting from web pages?

How to get a flat-head nail out of a piece of wood?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

What should one know about term logic before studying propositional and predicate logic?

Searching extreme points of polyhedron

How can I list files in reverse time order by a command and pass them as arguments to another command?

Is it OK if I do not take the receipt in Germany?

Short story about astronauts fertilizing soil with their own bodies

Is there a spell that can create a permanent fire?

By what mechanism was the 2017 UK General Election called?

Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?

Plotting a Maclaurin series

Marquee sign letters

How to name indistinguishable henchmen in a screenplay?

Pointing to problems without suggesting solutions

Is honorific speech ever used in the first person?

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?



Strange behavior of Out[]



Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How do I extract the contents of a selected cell as plain text?How to make a parallel auto-generated .m package from Initialization cells?Making flash cards with MathematicaDifference between double quotesHow is CellContext->CellGroup supposed to work?Automatic shading of all InitializationCell->True cells in older versions“Find currently evaluating cell” does not seem to work correctlyExporting notebooks inserts unwanted $CellContext. Workaround?Stop notebook from auto-scrolling upon printingDocked Cell Slider that controls magnification of Output Cells only










7












$begingroup$


Let's create two notebooks external.nb and primary.nb. Then call the external.nb notebook from the primary.nb and investigate values of Out[ ]. The context of the external notebook is not important, however for the demonstration of the strange behavior it should contain number of cells. My external.nb notebook contains 4 cells:



a=1; 



b=1



c=1



d


The primary notebook contains the single cell which calls the external notebook from the primary. If we put both notebooks in the same directory, the cell is



NotebookEvaluate @ FileNameJoin[
NotebookDirectory[EvaluationNotebook[]], "external.nb"
]


Open the primary.nb and evaluate the cell which calls the evaluation of the external.nb.



The output yields



Out[1] = d


So it returns output of the last cell of the called notebook.



Now refer to input %4 of primary.nb. I would expect an empty output, since at the moment there is no %4 out in the primary notebook. However the result is the same d.



Asking



?? Out[]


we see the primary.nb knows all Out[] values of the external.nb notebook. Bug or feature?










share|improve this question











$endgroup$











  • $begingroup$
    The kernel state (including In/Out values) is not local to notebooks. This is expected.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:05










  • $begingroup$
    That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
    $endgroup$
    – user18792
    Mar 19 at 12:17










  • $begingroup$
    Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:22















7












$begingroup$


Let's create two notebooks external.nb and primary.nb. Then call the external.nb notebook from the primary.nb and investigate values of Out[ ]. The context of the external notebook is not important, however for the demonstration of the strange behavior it should contain number of cells. My external.nb notebook contains 4 cells:



a=1; 



b=1



c=1



d


The primary notebook contains the single cell which calls the external notebook from the primary. If we put both notebooks in the same directory, the cell is



NotebookEvaluate @ FileNameJoin[
NotebookDirectory[EvaluationNotebook[]], "external.nb"
]


Open the primary.nb and evaluate the cell which calls the evaluation of the external.nb.



The output yields



Out[1] = d


So it returns output of the last cell of the called notebook.



Now refer to input %4 of primary.nb. I would expect an empty output, since at the moment there is no %4 out in the primary notebook. However the result is the same d.



Asking



?? Out[]


we see the primary.nb knows all Out[] values of the external.nb notebook. Bug or feature?










share|improve this question











$endgroup$











  • $begingroup$
    The kernel state (including In/Out values) is not local to notebooks. This is expected.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:05










  • $begingroup$
    That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
    $endgroup$
    – user18792
    Mar 19 at 12:17










  • $begingroup$
    Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:22













7












7








7





$begingroup$


Let's create two notebooks external.nb and primary.nb. Then call the external.nb notebook from the primary.nb and investigate values of Out[ ]. The context of the external notebook is not important, however for the demonstration of the strange behavior it should contain number of cells. My external.nb notebook contains 4 cells:



a=1; 



b=1



c=1



d


The primary notebook contains the single cell which calls the external notebook from the primary. If we put both notebooks in the same directory, the cell is



NotebookEvaluate @ FileNameJoin[
NotebookDirectory[EvaluationNotebook[]], "external.nb"
]


Open the primary.nb and evaluate the cell which calls the evaluation of the external.nb.



The output yields



Out[1] = d


So it returns output of the last cell of the called notebook.



Now refer to input %4 of primary.nb. I would expect an empty output, since at the moment there is no %4 out in the primary notebook. However the result is the same d.



Asking



?? Out[]


we see the primary.nb knows all Out[] values of the external.nb notebook. Bug or feature?










share|improve this question











$endgroup$




Let's create two notebooks external.nb and primary.nb. Then call the external.nb notebook from the primary.nb and investigate values of Out[ ]. The context of the external notebook is not important, however for the demonstration of the strange behavior it should contain number of cells. My external.nb notebook contains 4 cells:



a=1; 



b=1



c=1



d


The primary notebook contains the single cell which calls the external notebook from the primary. If we put both notebooks in the same directory, the cell is



NotebookEvaluate @ FileNameJoin[
NotebookDirectory[EvaluationNotebook[]], "external.nb"
]


Open the primary.nb and evaluate the cell which calls the evaluation of the external.nb.



The output yields



Out[1] = d


So it returns output of the last cell of the called notebook.



Now refer to input %4 of primary.nb. I would expect an empty output, since at the moment there is no %4 out in the primary notebook. However the result is the same d.



Asking



?? Out[]


we see the primary.nb knows all Out[] values of the external.nb notebook. Bug or feature?







front-end kernel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 19 at 11:27









Kuba

107k12211536




107k12211536










asked Mar 19 at 11:22









user18792user18792

1,785915




1,785915











  • $begingroup$
    The kernel state (including In/Out values) is not local to notebooks. This is expected.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:05










  • $begingroup$
    That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
    $endgroup$
    – user18792
    Mar 19 at 12:17










  • $begingroup$
    Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:22
















  • $begingroup$
    The kernel state (including In/Out values) is not local to notebooks. This is expected.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:05










  • $begingroup$
    That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
    $endgroup$
    – user18792
    Mar 19 at 12:17










  • $begingroup$
    Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
    $endgroup$
    – Szabolcs
    Mar 19 at 12:22















$begingroup$
The kernel state (including In/Out values) is not local to notebooks. This is expected.
$endgroup$
– Szabolcs
Mar 19 at 12:05




$begingroup$
The kernel state (including In/Out values) is not local to notebooks. This is expected.
$endgroup$
– Szabolcs
Mar 19 at 12:05












$begingroup$
That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
$endgroup$
– user18792
Mar 19 at 12:17




$begingroup$
That is clear, however why then not to continue the enumeration from the last Out[ ] value the kernel knows in the new notebook? I find this confusing.
$endgroup$
– user18792
Mar 19 at 12:17












$begingroup$
Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
$endgroup$
– Szabolcs
Mar 19 at 12:22




$begingroup$
Right, now I see what you mean. primary.nb keeps counting up from 1, yet higher input line values are already set in Out thanks to external.nb. It is indeed strange.
$endgroup$
– Szabolcs
Mar 19 at 12:22










1 Answer
1






active

oldest

votes


















7












$begingroup$

I am guessing that this has to do with the following note in the NotebookEvaluate documentation:




The cells of the notebook are evaluated in a dialog subsession.




Here is an example session demonstrating similar behaviour:



enter image description here



See Dialog if you are not familiar with it.



Within the dialog, $Line keeps getting incremented as usual, and Out values are set. But once the dialog finishes, $Line is reset to its original value.



This is documented:




Dialog automatically localizes the values of $Line, $MessageList, and $Epilog.




Side note: A dialog is something you would normally encounter not when explicitly entering it, but when interrupting evaluation or when debugging (say, you set the debugger to break on a message/assert). Try e.g. Do[Pause[1], i, 30], then interrupt using Alt-, (Option-Command-. on Mac). Now you can evaluate i to check its value, or examine the kernel state in other ways. Exit the dialog using Return[]. It is natural that one would not want these evaluations to influence $Line once the dialog has finished.






share|improve this answer









$endgroup$












  • $begingroup$
    Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
    $endgroup$
    – user18792
    Mar 20 at 7:29










  • $begingroup$
    @user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
    $endgroup$
    – Szabolcs
    Mar 20 at 8:47












Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193547%2fstrange-behavior-of-out%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









7












$begingroup$

I am guessing that this has to do with the following note in the NotebookEvaluate documentation:




The cells of the notebook are evaluated in a dialog subsession.




Here is an example session demonstrating similar behaviour:



enter image description here



See Dialog if you are not familiar with it.



Within the dialog, $Line keeps getting incremented as usual, and Out values are set. But once the dialog finishes, $Line is reset to its original value.



This is documented:




Dialog automatically localizes the values of $Line, $MessageList, and $Epilog.




Side note: A dialog is something you would normally encounter not when explicitly entering it, but when interrupting evaluation or when debugging (say, you set the debugger to break on a message/assert). Try e.g. Do[Pause[1], i, 30], then interrupt using Alt-, (Option-Command-. on Mac). Now you can evaluate i to check its value, or examine the kernel state in other ways. Exit the dialog using Return[]. It is natural that one would not want these evaluations to influence $Line once the dialog has finished.






share|improve this answer









$endgroup$












  • $begingroup$
    Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
    $endgroup$
    – user18792
    Mar 20 at 7:29










  • $begingroup$
    @user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
    $endgroup$
    – Szabolcs
    Mar 20 at 8:47
















7












$begingroup$

I am guessing that this has to do with the following note in the NotebookEvaluate documentation:




The cells of the notebook are evaluated in a dialog subsession.




Here is an example session demonstrating similar behaviour:



enter image description here



See Dialog if you are not familiar with it.



Within the dialog, $Line keeps getting incremented as usual, and Out values are set. But once the dialog finishes, $Line is reset to its original value.



This is documented:




Dialog automatically localizes the values of $Line, $MessageList, and $Epilog.




Side note: A dialog is something you would normally encounter not when explicitly entering it, but when interrupting evaluation or when debugging (say, you set the debugger to break on a message/assert). Try e.g. Do[Pause[1], i, 30], then interrupt using Alt-, (Option-Command-. on Mac). Now you can evaluate i to check its value, or examine the kernel state in other ways. Exit the dialog using Return[]. It is natural that one would not want these evaluations to influence $Line once the dialog has finished.






share|improve this answer









$endgroup$












  • $begingroup$
    Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
    $endgroup$
    – user18792
    Mar 20 at 7:29










  • $begingroup$
    @user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
    $endgroup$
    – Szabolcs
    Mar 20 at 8:47














7












7








7





$begingroup$

I am guessing that this has to do with the following note in the NotebookEvaluate documentation:




The cells of the notebook are evaluated in a dialog subsession.




Here is an example session demonstrating similar behaviour:



enter image description here



See Dialog if you are not familiar with it.



Within the dialog, $Line keeps getting incremented as usual, and Out values are set. But once the dialog finishes, $Line is reset to its original value.



This is documented:




Dialog automatically localizes the values of $Line, $MessageList, and $Epilog.




Side note: A dialog is something you would normally encounter not when explicitly entering it, but when interrupting evaluation or when debugging (say, you set the debugger to break on a message/assert). Try e.g. Do[Pause[1], i, 30], then interrupt using Alt-, (Option-Command-. on Mac). Now you can evaluate i to check its value, or examine the kernel state in other ways. Exit the dialog using Return[]. It is natural that one would not want these evaluations to influence $Line once the dialog has finished.






share|improve this answer









$endgroup$



I am guessing that this has to do with the following note in the NotebookEvaluate documentation:




The cells of the notebook are evaluated in a dialog subsession.




Here is an example session demonstrating similar behaviour:



enter image description here



See Dialog if you are not familiar with it.



Within the dialog, $Line keeps getting incremented as usual, and Out values are set. But once the dialog finishes, $Line is reset to its original value.



This is documented:




Dialog automatically localizes the values of $Line, $MessageList, and $Epilog.




Side note: A dialog is something you would normally encounter not when explicitly entering it, but when interrupting evaluation or when debugging (say, you set the debugger to break on a message/assert). Try e.g. Do[Pause[1], i, 30], then interrupt using Alt-, (Option-Command-. on Mac). Now you can evaluate i to check its value, or examine the kernel state in other ways. Exit the dialog using Return[]. It is natural that one would not want these evaluations to influence $Line once the dialog has finished.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 19 at 12:29









SzabolcsSzabolcs

165k15450954




165k15450954











  • $begingroup$
    Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
    $endgroup$
    – user18792
    Mar 20 at 7:29










  • $begingroup$
    @user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
    $endgroup$
    – Szabolcs
    Mar 20 at 8:47

















  • $begingroup$
    Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
    $endgroup$
    – user18792
    Mar 20 at 7:29










  • $begingroup$
    @user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
    $endgroup$
    – Szabolcs
    Mar 20 at 8:47
















$begingroup$
Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
$endgroup$
– user18792
Mar 20 at 7:29




$begingroup$
Since the behavior is documented I conclude this is the intended design feature. I use NotebookEvaluate for package development, because it is much more convenient way to add new definitions and navigate in the many cell notebook than in plain .m file. I think I will try to add Clear[Out] as the last cell in the external.nb.
$endgroup$
– user18792
Mar 20 at 7:29












$begingroup$
@user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
$endgroup$
– Szabolcs
Mar 20 at 8:47





$begingroup$
@user18792 You can edit an .m file as if it were a notebook. You can add section cells and text cells. You can close and open section cells. Try it.
$endgroup$
– Szabolcs
Mar 20 at 8:47


















draft saved

draft discarded
















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193547%2fstrange-behavior-of-out%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Masuk log Menu navigasi

Identifying “long and narrow” polygons in with PostGISlength and width of polygonWhy postgis st_overlaps reports Qgis' “avoid intersections” generated polygon as overlapping with others?Adjusting polygons to boundary and filling holesDrawing polygons with fixed area?How to remove spikes in Polygons with PostGISDeleting sliver polygons after difference operation in QGIS?Snapping boundaries in PostGISSplit polygon into parts adding attributes based on underlying polygon in QGISSplitting overlap between polygons and assign to nearest polygon using PostGIS?Expanding polygons and clipping at midpoint?Removing Intersection of Buffers in Same Layers

Старые Смолеговицы Содержание История | География | Демография | Достопримечательности | Примечания | НавигацияHGЯOLHGЯOL41 206 832 01641 606 406 141Административно-территориальное деление Ленинградской области«Переписная оброчная книга Водской пятины 1500 года», С. 793«Карта Ингерманландии: Ивангорода, Яма, Копорья, Нотеборга», по материалам 1676 г.«Генеральная карта провинции Ингерманландии» Э. Белинга и А. Андерсина, 1704 г., составлена по материалам 1678 г.«Географический чертёж над Ижорскою землей со своими городами» Адриана Шонбека 1705 г.Новая и достоверная всей Ингерманландии ланткарта. Грав. А. Ростовцев. СПб., 1727 г.Топографическая карта Санкт-Петербургской губернии. 5-и верстка. Шуберт. 1834 г.Описание Санкт-Петербургской губернии по уездам и станамСпецкарта западной части России Ф. Ф. Шуберта. 1844 г.Алфавитный список селений по уездам и станам С.-Петербургской губернииСписки населённых мест Российской Империи, составленные и издаваемые центральным статистическим комитетом министерства внутренних дел. XXXVII. Санкт-Петербургская губерния. По состоянию на 1862 год. СПб. 1864. С. 203Материалы по статистике народного хозяйства в С.-Петербургской губернии. Вып. IX. Частновладельческое хозяйство в Ямбургском уезде. СПб, 1888, С. 146, С. 2, 7, 54Положение о гербе муниципального образования Курское сельское поселениеСправочник истории административно-территориального деления Ленинградской области.Топографическая карта Ленинградской области, квадрат О-35-23-В (Хотыницы), 1930 г.АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1933, С. 27, 198АрхивированоАдминистративно-экономический справочник по Ленинградской области. — Л., 1936, с. 219АрхивированоАдминистративно-территориальное деление Ленинградской области. — Л., 1966, с. 175АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1973, С. 180АрхивированоАдминистративно-территориальное деление Ленинградской области. — Лениздат, 1990, ISBN 5-289-00612-5, С. 38АрхивированоАдминистративно-территориальное деление Ленинградской области. — СПб., 2007, с. 60АрхивированоКоряков Юрий База данных «Этно-языковой состав населённых пунктов России». Ленинградская область.Административно-территориальное деление Ленинградской области. — СПб, 1997, ISBN 5-86153-055-6, С. 41АрхивированоКультовый комплекс Старые Смолеговицы // Электронная энциклопедия ЭрмитажаПроблемы выявления, изучения и сохранения культовых комплексов с каменными крестами: по материалам работ 2016-2017 гг. в Ленинградской области