During the development of a program to process bioinformatic data, I have encountered a peculiar shadow warning:
GlobalParentList::shdw: Symbol ParentList appears in multiple contexts {Global
,System}; definitions in context Global
may shadow or be shadowed by other definitions. >>
Some background:
- No where in the program do I create a variable named ParentList.
- ParentList appears to be an undocumented System symbol (at least I can't find documentation on it.)
- When I run my program as a complete, single block of code, I do not get the shadow warning, yet when I run segments of code linearly (which I am doing because I am writing a paper on the program), then the warning appears. This behavior is consistent whether I use Mathematica v 9.0.1 or 10.0.2
- I have tracked the single line of code that generates the warning. Notice how the list of names in the Global context changes after the code is executed.
Before troublespot:
Names["Global`*"]
...,overlapadj,overlapcoord,passengermers,passengerpopup,...
Trouble spot & subsequent list of Global names:
Export[StringJoin[ToString[studyname], " - siRNA alignment.jpg"],
Pane[graphicoutput, 801], ImageResolution -> 300];
GlobalParentList::shdw: Symbol ParentList appears in multiple contexts {Global
,System}; definitions in context Global
may shadow or be shadowed by other definitions. >>
Names["Global`*"]
...,overlapadj,overlapcoord,Global`ParentList,passengermers,passengerpopup,...
Notice how the Global namespace has a new symbol called ParentList that wasn't there before the Export command.
Even though I do not get the shadow warning when I run the entire program as one block of code, I still do get the spurious creation of the variable ParentList in the Global context.
When I tried to recreate a minimal example of the bug in a new notebook I was not able to reproduce this behavior, making me think the primary issue really isn't with the Export command as shown above.
So, I am stuck.
A. Have you seen behavior like this before?
B. Would you have suggestions about how to troubleshoot this problem?
Edit (01/08/2015): Into the Heart of Darkness
Continued efforts to shed light on this peculiar behavior have failed. I have tried:
- Re-positioning the offending line of code to another spot within the code (to see if execution order mattered) - shadow warning still appears
- Re-typing the entire cell of code from scratch to see if the cell itself was corrupt - shadow warning still appears
- Loading a copy of the notebook into Notepad and searched for the offending symbol. The symbol does not appear anywhere before the generation of the warning itself.
- Changed the export format from jpg to gif - shadow warning still appears
- Using various permutations of Trace to shake the problem loose - all to no effect. (I admit I am not very skilled at using Trace.)
It really seems as though Mathematica is spontaneously doing something that I am unable to monitor. Exasperating to say the least.
(01/08/2015) Later in the day
- For some reason, I was inspired to try changing the export format from jpg to pdf, and the shadow warning disappeared. I have repeated this several times with a fresh kernel to be sure the change in behavior is real and reproducible.
Question C: Could there be a subtle "bug" in Mathematica's use of code for raster graphics vs vector graphics that causes the ParentList symbol to bleed into the global namespace?
(01/17/15) The Saga Continues ...
I sent a minimal example notebook to WRI and they were not able to reproduce the problem on their computers. They advised me to reset the system preferences by holding (CTRL-SHIFT) while loading Mathematica. Unfortunately this had no effect, as I still get the warning message.
Here is an example of the warning and new symbol that shows up in the global namespace:
If anyone is still interested, I have made the notebook I sent to WRI (and which causes the warning on my system) available here:
https://www.dropbox.com/s/ogspeip2ctmbahu/shadow%20testing-minimal1.nb?dl=0
I would be appreciative if others could run it (from a fresh kernel) and let me know if any warning appears. If not, I suppose I just have a corruption somewhere on my machine that I will have to live with. Certainly has me scratching my head. Thanks for reading.
(01/18/15) A peek at the solution...
StackExchange user Simon Woods found the symbol generating the shadow warning (ParentList) in the stylesheet being used to write the program. (See comment section below.) This stylesheet is the authoring template used by The Mathematica Journal.
While Simon was able to reproduce this bug (thankfully!) under Windows 7, StackExchange user ybeltukov was not able to reproduce the bug under the Linux version of Mathematica.
So, it seems that I stumbled upon a problem in a stylesheet that produces a shadow warning that is operating system dependent.
Question D: Why would a stylesheet function differently under different operating systems?
Question E: Has anyone seen a stylesheet behave this way under different operating systems?
I will alert WRI technical support about this and the editors of The Mathematica Journal.
ParentList
before the internal package that contains its definition is loaded (automatically). Unless this is directly affecting your work, I would suggest just ignoring it. $\endgroup$$CellContext`ParentList
as a spurious entry in theInputAutoReplacements
list for the style cells StandardForm and TraditionalForm in the FormatType Styles section. Removing these makes the problem go away, as does changing the stylesheet to something else. $\endgroup$