Tag Info

33

Short answer The local variables of the form varname$... are used by the system, and it is unwise to use symbols with such names as local variables. With, like many other lexical scoping constructs, performs excessive renamings, often even in cases where it isn't strictly necessary. This probably has to do with efficiency - full analysis may be more costly. ... 33 There are two processes running. The first process is the FrontEnd. The FrontEnd receives your keypresses and renders text and plots. The second process is the Kernel. The Kernel receives commands to perform calculations, stores the states of variables, and does pretty much all the calculating. When you press Alt-., the FrontEnd immediately receives ... 29 You should consider using the sandbox functionality. You can create a subkernel and put it in sandbox mode this way: link = LinkLaunch[First[$CommandLine]<> " -wstp -noicon"]; LinkWrite[link, Unevaluated@EvaluatePacket[DeveloperStartProtectedMode[]]]; You can then interact with this subkernel using the standard LinkWrite and LinkRead functions. If ...

20

You could launch a different kernel and use that to run the computation. You will be controlling this "slave kernel" from another Mathematica session. This will allow you to script even quitting and restarting the slave kernel. Using parallel tools This is simpler and I recommend trying this approach first. Launch a single kernel: kernel = ...

19

You need to daemonize your script: nohup math -script test.txt 0<&- &>/dev/null & Now this will run as a background process with no output captured. If your script does indeed produce output, just replace /dev/null with the filename. In order to daemonize something you need to disconnect all the automatically connected streams (stdin, ...

17

This can be relatively easily done using extremely useful $FrontEnd option "ClearEvaluationQueueOnKernelQuit" introduced by Chris Degnen. Usage Print @$SessionID quitAndEvaluate[ Print @ $SessionID ] 25183094379509806957 25183094575602627552 quitAndEvaluate[] will restart kernel without aby additional tasks. It may be useful if you want to ... 16 I have been solving exactly the same problem about 2 years ago (http://community.wolfram.com/groups/-/m/t/125587?p_p_auth=aZGMz5bs). Students are uploading piece of Mathematica (Wolfram Language) code which is run by a testing script (in Mathematica) and the results are compared with a reference solution. To prevent the students to run potentially dangerous ... 16 One approach would be to run the evaluation in a second kernel which is controlled from a main kernel through MathLink/WSTP. Then your main kernel can detect if the MathLink connection dies. You can implement this manually (a lot of work), or you can try to do it using the parallel computing tools, where much of the groundwork is already laid down. In ... 16 Apparently, Throw is deactivated during kernel initialization. The following function can determine if Throw is inoperative: throwInoperativeQ[] := CheckAll[Catch[Throw[False]], # /. Null -> True &] The undocumented function CheckAll is used here because Check also appears to be unreliable when Throw is inoperative. If we make the assumption that ... 16 The kernel crashes due to stack overflow. It is not safe to recurse too deeply. Increasing$RecursionLimit to values that are too great (and actually recursing that deep) risks a crash. (So yes, in a way it's due to insufficient memory, but it has nothing to do with memoization. It is due to insufficient stack space.) From the documentation: On most ...

15

You can use GNU screen to make a sort of persistent terminal that allows you to resume work wherever you left off. Take a look at the many tutorials available. It's not completely clear from your question whether the better solution is this, or nohup (see Stefan's answer). Use nohup if your workflow is non-interactive: log in, start a batch job that ...

15

There is a setting in Mathematica that controls whether it can access the internet. Go to Preferences -> Internet Connectivity and uncheck "Allow the Wolfram System to access the Internet". Disabling this will disable some features that depend on internet access, such as Wolfram|Alpha queries. This setting can also be controlled by the $AllowInternet ... 14 You cannot Quit kernel while evaluation is still running: the Quit[] command will be placed in the queue and executed only after finishing of evaluation of all the previous inputs. In contrast, Evaluation ► Quit Kernel will quit the kernel immediately even if it is still running. UPDATE As Kuba noticed in the comments, via "Preemptive" link it is ... 14 After some spelunking, I found a file which contains a lot of initialization code, including reading the kernel init.m file, loading Autoload packages, loading anything set with the -initfile option, starting the paclet manager (which may autoload packages), and many other things. It is SystemFiles/Kernel/SystemResources/$SystemID/sysinit.m Towards the ...

14

This bug has been fixed by a paclet update. This would be applied automatically whenever the functionality is used in a new kernel (as long as the paclet manager has updated its local site index, which typically happens once per session). To force an immediate installation, evaluate PacletSiteUpdate /@ PacletSites[]; PacletInstall["FFmpegTools"] which ...

13

Updated This happens because your DynamicModule returns a dynamic object of which x is passed on to the front-end before the scheduled task starts, so the front-end-x cannot be modified anymore by any process (more details at the end). The problem can be further simplified. This works: RemoveScheduledTask@ScheduledTasks[]; DynamicModule[{x = 0}, ...

13

Assuming FrontEnd survives, prepare 3 cells: (*init cell, won't be needed later*) state = CurrentValue[EvaluationNotebook[], {"TaggingRules", "state"}] = 0; SetOptions[ #, {CellTags -> {"Procedure"}, ShowCellTags -> True} ]& /@ {NextCell[], NextCell @ NextCell[]}; CurrentValue[$FrontEndSession, "... 13 Update Leaving my original answer below for historical purposes, however it only applies up until version 11.1.1. As of version 11.2.0, the kernel startup initialization has been overhauled and this example (as well as others) now works correctly: placing the URLFetch call in init.m does result in an output like <!doctype html> <html lang="en" ... 13 It's a type of otherwise harmless bug that tends to come and go with versions. I would suggest to report it to Wolfram, but also not to worry about it. Notice that the symbols have no associated definitions, which means that they will not interfere with your code. A potential way in which such a situation can arise is the following. Imagine you put Sqr[x_] ... 12 You can use FileNameJoin to assemble file names in a robust and platform-independent way. This will solve the difficulties with the trailing /. You can also use AbsoluteFileName to bring a path to canonical form. This works only with paths that exist. For example, to compare Directory[] and NotebookDirectory[], you can use AbsoluteFileName@Directory[] ===... 12 Now that the workaround has worked for me for days without crash, let me put it as an answer myself. The crash (at least in my case) is because of the kernel tries to connect to internet and something wrong happened there. To solve the problem, uncheck Preference -> Internet Conectivity -> Allow the Wolfram System to access the Internet 12 Here's an approach to fix the code behind Terminal - Execute the following code to restore the functionality of the package: << Terminal ExportString["", "TTY"]; DownValues@SystemConvertBitmapDumpExportTTY = DownValues@SystemConvertBitmapDumpExportTTY /. { TextStyle -> LabelStyle, HoldPattern[pre : (data_ = _[___, gr_, "... 11 In Mathematica 11.3 or later, use Iconize. It creates a short display form of a large expression that can be copied to elsewhere within the notebook, can be saved with the notebook, and can be used in the same way as the fully displayed version of that expression. Typically one would save a notebook with a cell that assigns an iconized version of a large ... 11 The crash may be avoided by turning off the Suggestions Bar. The reason is that one of the computations attempted by the predictive interface in the background, namely Solve[(0.000092742725 - 0.000015933052*I)* E^((0. + 3.1934271000000003*^-10*I)*t) - (0.0000981431 + 0.0001437239*I)* E^((0. + 1.4229429000000001*^-9*I)*t) + (0.0057300369 - ... 11 I had this problem and the solution was to turn off the Suggestions Bar in the preferences. 10 Update: I maintain the latest version of this function on my blog. SaveToCell is a convenience-minded implementation of Vitaliy's idea. The code is at the end. Description SaveToCell[var] creates an input cell that re-assigns the value of var. The right-hand-side of the assignment is displayed concisely in the notebook. Usage example range = Range[... 10 As I said in my comments, it is hard to implement this correctly if you aim for some advanced Dynamic features that work in the command line. However, you can surely use the carriage-return trick on the command line. The only obstacle here is that Print puts everything on a new line. However, if you write directly to stdout, you don't have this problem. ... 10 The remote batch job submission functionality in version 12.2 of Mathematica makes it easy to run batch jobs on cloud services like AWS Batch. See this example illustrating a trivial job using multi-core parallel computation: In[1]:= job = RemoteBatchSubmit[ RemoteBatchSubmissionEnvironment[...], {$ProcessorCount, ParallelEvaluate[\$KernelID]}, ...

9

This turns out to be easy. In Windows 7: Add C:\Program Files\Wolfram Research\Mathematica\9.0\ to the path. Write procedures for what you want to do in The Wolfram Language, and save in a .m file. Add MathKernel.exe -script filename.m to the Windows Task Scheduler. Specify that the job runs in the directory containing the .m file. That seems to be it. by ...

9

Thanks to the link to "Copying one symbol into another" in jkuczm's comment, I found a partial answer with LanguageExtendedDefinition. For instance: LanguageExtendedDefinition[Log] LanguageDefinitionList[Log->{ OwnValues->{}, SubValues->{}, UpValues->{}, DownValues->{}, NValues->{}, FormatValues->{HoldPattern[MakeBoxes[Log[BoxForm`...

Only top voted, non community-wiki answers of a minimum length are eligible