4

Bug introduced in 10.0.0 and fixed in 10.1.0.


Has anyone had problems with the DeleteMissing function in Mathematica 10.0.2? I find that it rarely works. Most of the time it returns a list which still contains all of the missing elements. For example, let's say a = {Missing[], 1, 2, 3} then DeleteMissing[a] returns {Missing[] , 1, 2, 3}.

Michael E2
  • 235,386
  • 17
  • 334
  • 747
Wintermute
  • 477
  • 3
  • 10
  • 1
    have not even used it so far, but have you seen und understood the level specification you can give as second argument? Without that it will drop elements at level 1 only, which might (or might not) be your problem... – Albert Retey Jan 29 '15 at 15:09
  • 3
    Can you provide some code to reproduce the issue? – Yves Klett Jan 29 '15 at 15:13
  • @YvesKlett See my edit. – Wintermute Jan 29 '15 at 16:32
  • 1
    strange, I just tried this with 10.0.2 on Windows 7 and it seems to work (i.e. returns {1,2,3}). What system are you on? – Albert Retey Jan 29 '15 at 16:44
  • @AlbertRetey I'm running OSX 10.7.5. Sometimes the function works fine, most of the time you get the output I've shown above. – Wintermute Jan 29 '15 at 16:49
  • I have now tried several times but could not see it fail. What exactly do you do between repetitions? Kernel quit, regenerate test-list, ... Can you explain where the lists you are trying with come from? – Albert Retey Jan 29 '15 at 16:52
  • I've actually seen the problem when I open a new notebook, create a list with a missing element, then apply delete missing. – Wintermute Jan 29 '15 at 16:59
  • 1
    how exactly do you create such a list, by entering as input or is it returned from other functions? Can you show the offending lists when that happens with InputForm? One possible reason could be something like a "Missing"[] which as output will (with the default settings) look exactly like Missing[] but of course will not be matched by DeleteMissing... – Albert Retey Jan 29 '15 at 18:42
  • When I create each list I check that the head of the element Missing[] is indeed Missing. Like above I'll just type List={Missing[],1,2,3} to create the list. – Wintermute Jan 29 '15 at 18:56
  • I can reproduce your problem with DeleteMissing in V10.0.2 running on OS X. DeleteCases[a, _Missing] works fine. – m_goldberg Jan 29 '15 at 19:37
  • I cannot reproduce the problem on OS X, M10.0.2. Do you have the suggestions bar turned on? Have you tried restarting Mathematica? Can you give a complete reproducible example? I.e. show step by step what you did right after starting up Mathematica. Make sure no other notebooks are open, just the one you're typing in. – Szabolcs Jan 29 '15 at 20:13
  • Like this. Well, it must be the suggestions bar's doing as apparently now I can reproduce it. – Szabolcs Jan 29 '15 at 20:17

2 Answers2

6

I can reproduce this problem only if the Suggestions Bar is enabled. In this case DeleteMissing seems to mysteriously lose its definition.

In[1]:= {$Version, $VersionNumber, $ReleaseNumber}
Out[1]= {"10.0 for Mac OS X x86 (64-bit) (December 4, 2014)", 10., 2}

In[2]:= a = {Missing[], 1, 2, 3}
Out[2]= {Missing[], 1, 2, 3}

In[3]:= DeleteMissing[a]
Out[3]= DeleteMissing[{Missing[], 1, 2, 3}]

In[4]:= Definition@DeleteMissing
Out[4]= Definition[DeleteMissing]

This looks to be the exact same issue from here:

Please report it to Wolfram Support.

As a workaround, you can turn off the Suggestions Bar by going to Preferences -> Interface and unchecking Show Suggestions Bar After Last Output. After turning off the Suggestions Bar, it is also necessary to Quit and relaunch the kernel for the problem to go away.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
3

This is an extension to Szabolcs' answer. I would have explained it in 2nd comment to his answer, but it is a little too complicated to be a comment.

There is another complication in regard to reproducing this problem. It is essential that the assignment

a = {Missing[], 1, 2, 3} ;

be evaluated before a DeleteMissing expression is successfully evaluated and the suggestion bar must up come at its completion.

Starting with a freshly loaded kernel, the suggestions bar enabled, and all the code in one cell.

a = {Missing[], 1, 2, 3} ;
DeleteMissing[a]
{1, 2, 3}

will work.

Quitting from and restarting the kernel and making two separate cells.

a = {Missing[], 1, 2, 3} ; (* evaluate this cell first and separately *)

DeleteMissing[a]
DeleteMissing[{Missing[], 1, 2, 3}]

reproduces the OP's problem exactly.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257