7
You can use Get/@ FileNames["save*"].
answered Aug 29 '18 at 14:35
Henrik Schumacher
84.8k66 gold badges131131 silver badges240240 bronze badges
6
There are several issues. First of all Context[] is the same here and can be replaced with $Context to make the example clearer. Now:
DumpSave is HoldRest so in case of symbol = 2 it can save that definition instead of seeing 2.
DumpSave["file", symbol] will save defnitions of symbol. So will DumpSave["file", $Context]. It will save information that $...
5
The function that does the actual calculation:
fcalc[n_] := n^2
make file names:
SetDirectory[NotebookDirectory[]];
makeFileName[n_] := "cachefile_" <> ToString[n] <> ".wl"
The function that you call from the rest of the code:
Clear[f];
f[n_] := f[n] = Module[{name, F},
(* is there a cached version? *)
name = makeFileName[n];
If[...
5
Get /@ StringTemplate["save``"] /@ Range[1, 5]
4
Notice that DumpSave has attribute HoldRest which prevents evaluation of all but its first argument.
The documentation of Evaluate states:
You can use Evaluate to override HoldFirst etc. attributes of built-in
functions.
Evaluate only overrides HoldFirst etc. attributes when it appears directly as the head of the function argument that would ...
answered Feb 3 '19 at 17:39
Henrik Schumacher
84.8k66 gold badges131131 silver badges240240 bronze badges
2
I suspect that
Files written by DumpSave cannot be exchanged between operating systems that differ in $SystemWordLength.
which is quoted from the documentation article on DumpSace, is relevant to your problem. Evaluated $SystemWordLength on both computers. Are they different?
1
guidance to your comment:
define some user functions sin,cos
data
= Table[{x, Sin[x], Cos[x]}, {x, Subdivide[0, 2 Pi, 50]}];
sin = Interpolation[data[[All, {1, 2}]]];
cos = Interpolation[data[[All, {1, 3}]]];
save the functions
DumpSave["sincos.mx", {sin, cos}]
Clear[sin,cos] (* new session*)
load function
Get["sincos.mx"]
now the ...
1
The step data is stored in the interpolating function:
sol = NDSolveValue[{D[u[t, x], t] ==
0.1 D[u[t, x], x, x] + u[t, x] D[u[t, x], x],
u[0, x] == Cos[2 Pi x], u[t, 0] == u[t, 1]},
u, {t, 0, 1}, {x, 0, 1}, Method -> "StiffnessSwitching"];
sol["Coordinates"][[1]]
{0.`, 0.06800128840268457`, 0.09489195680748204`, \
0.13502467607112256`, 0....
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
dumpsave × 18files-and-directories × 5
save × 4
get × 4
contexts × 3
export × 2
notebooks × 2
plotting × 1
functions × 1
import × 1
evaluation × 1
table × 1
interpolation × 1
symbols × 1
crash × 1
custom-notation × 1
arbitrary-precision × 1
binary × 1
memoization × 1
version-11 × 1
format × 1
version-11.3 × 1
notation × 1
file-transfer × 1
localsymbol × 1