This is a Jupyter quirk that cost me some hours and caused me some grief.
So beware!

Please see the attached image and Jupyter notebook.

Note the following block of code, which has been succeeding for me for
days, even when "Run All Cells" is carried out:

my_mols = [mol.RDK_mol for mol in mols]
my_descriptions = [mol.description for mol in mols]
type(gridImage)
gridImage = MolsToGridImage(my_mols, molsPerRow=2, subImgSize=(350, 250),
legends=my_descriptions, useSVG=True, kekulize=False)
gridImage

The last line successfully displays the gird. But read on -- it won't
succeed for you.

When I made a copy of the notebook, it failed on the type() statement,
because gridImage had not yet been defined. When I removed the type()
statement, it failed on the last line, because gridImage must actually be
displayed via SVG(gridImage). But when I try the latter in the original,
SVG(gridImage) evokes an error message.

In the original, when "Cell>Run All Cells" is selected, type()
succeeds,because Jupyter still remembers the gridImage variable that had
been created in the previous invocation.

In early versions of the notebook, gridImage was a different structure that
did not require SVG() to display. Now the generated gridImage is supposed
to require SVG(), and yet it (1) fails with SVG() and (2) succeeds without
it as if SVG were being used. This strikes me as bizarre. I have a hard
time understanding how this can be.

However you see this, it's a cautionary tale.  Running a Jupyter notebook
is not the same as using a pretty interface to run a Python script.

The only thing I have found to avoid this is "Kernel > Restart and Run
All".

The web suggests "%reset" to clear user variables in iPython, but, if
executed at the top of the first In[] in Jupyter, it results in no output
whatsoever, so I don't know what it's doing. If someone knows of a
directive that can be used in-line, please speak up. I always want my
user-defined variables to be expunged if I execute "Cell > Run all"

-P.

Attachment: Several-molecules.ipynb
Description: Binary data

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to