The Stack Overflow podcast is back! Listen to an interview with our new CEO.
5 replaced http://stackoverflow.com/ with https://stackoverflow.com/
source | link

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussionthis discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

4 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. herehere) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

3 Fixed a typo
source | link

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

SerializatingSerializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializating in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

You seem to be out of luck (although I will be happy to be proven wrong). This is a rather subtle point, related to the Temporary attribute and garbage-collection. I will just share a few observations. First, note that after loading of .mx file on a fresh kernel, the variable is not found anywhere, it is not among the living:

<< "interpolation.mx"
names = Flatten[Names[# <> "*"] & /@ Contexts[]];
Flatten@StringCases[names, ___ ~~ "interpolation" ~~ ___]

{"Manipulate`Dump`interpolationToAnimation", 
   "Manipulate`Dump`interpolationToManipulate"}

Here is one way to make it persist:

Module[{interpolation},
  ClearAll[interpolation];
  interpolation = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

Now it will be found. By using ClearAll, I removed the Temporary attribute from interpolation. Interestingly, another way to do this is to define a DownValue rather than an OwnValue for it:

Module[{interpolation}, 
  interpolation[1] = Interpolation[Range[10]];
  DumpSave["interpolation.mx", interpolation];
]

In this case, too, it can be found, since garbage-collection of Module-generated variables works differently for DownValues.

I can not fully explain why this affected the code for DumpSave, which is still inside Module. One guess I have is that it gets recorded by DumpSave all right, with all attributes, including Temporary. Then, when you load it, it probably gets garbage-collected immediately after creation, due to this attribute.

Serializing in this manner using Module is also bad (although I am myself guilty of having done this, e.g. here) for another reason: Module-generated variables are only guaranteed to be unique within a single Mathematica session. It is better to use some custom code to generate variables with names guaranteed to be unique for all sessions (which is easy to do. I recommend to read this discussion).

2 added 18 characters in body
source | link
1
source | link