Hot answers tagged

20

I decided to take one of my large packages and Remove all symbols in the Private` context that have no definitions attached to them ... And is there any risk if only those symbols that are not used globally or that do not have definitions are carefully removed? In general, the complexity of the Mathematica language and the intricacies of the ...


11

This appears to be a difference in parsing between the frontend and the kernel. Compare (in a notebook) HoldForm[\[LeftCeiling]x\[RightCeiling] + 1] (* Ceiling[x] + 1 *) with Get[StringToStream["HoldForm[\[LeftCeiling]x\[RightCeiling] + 1]"]] (* Ceiling[x] (+1) *) where the latter has multiplication instead of addition. One possible workaround is ...


11

As a more direct answer to the question of memory we can check with a test. In[1]:= MemoryInUse[] (* Out[1]= 34093104 *) In[2]:= bunchOfSymbols = Table[Unique[], {26000}]; In[3]:= foo[Sequence @@ bunchOfSymbols] := bar; In[4]:= MemoryInUse[] (* Out[4]= 43032256 *) In[5]:= Remove @@ bunchOfSymbols; In[6]:= MemoryInUse[] (* Out[6]= 41577200 *) ...


9

I've certainly encountered this behavior before. While I can't speak authoritatively, I'd think this is as designed, although it does introduce certain inconsistency. I also think that this issue is a result of clash of cultures: the end user - oriented one from the earlier days of Mathematica, and the one coming from standard software-engineering practices. ...


8

In order for a package in Autoload to load, it must have the file Kernel/init.m. Thus, Autoload/MyPack.m will not load. Autoload/MyPack/MyPack.m will also not load. Instead, we need to have the following structure: A package file at Autoload/MyPack/Mypack.m and an initialization file for the package at Autoload/MyPack/Kernel/init.m, containing the ...


4

I think in general no one know's how to express roots of polynomials in terms of radicals, or even determine when it's possible. Quintics has been solved and there's a Mathematica package to solve them. Radicals.nb SolveQuintic[x^5 + 20 x + 32 == 0, x] For sextics I believe the most that is known is how to determine which equations can be expressed in ...


4

If you look at ?FieldDerivative you see that it contains following text NOTICE: FieldDerivative is defined only for objects with head \ QuantumField[...]. If the space-time derivative of other objects is \ wanted, the corresponding rule must be specified. I.e. FieldDerivative is used for deriving Feynman rules, but not for differentiating Lorentz ...


4

The Autoload mechanism can be used for this. Place the package in $UserBaseDirectory/Autoload or $BaseDirectory/Autoload. However, the package must follow the standard structure, and must have a Kernel/init.m file, otherwise it won't get loaded. Also keep in mind that auto-loading of packages happens only after $UserBaseDirectory/Kernel/init.m was loaded ...


3

What features I/we/developers need: allowing (only) MyPackage` to use particular non System` packages e.g. using GeneralUtilities` functions after BeginPackage["MyPackage`"] allowing user to use particular non System` packages (only) after loading MyPackage` e.g. After << MyPackage` I would like to be able to call PrintDefinitions from ...


3

This is sort of what the `Private` context is meant to be doing for you. You write that you just need more contexts that can behave like Private context for organizational purposes, and this can be achieved using subcontexts that use a `Private` mark. My normal instinct would be to put the helper functions to MainFunction inside a `Private` branch of ...


3

There are two related bugs. SubstituteSingleReplace calls RulesComplement to construct a list of rules and their opposites (so in your case b_ ** a_ :> -a ** b and -b_ ** a_ :> a ** b). Unfortunately, the function incorrectly uses Rule when given a RuleDelayed (my In[1] was loading the package): In[2]:= RulesComplement[b_ ** a_ :> -a ** b] ...


3

It returns 0 because you are doing something like: D[ Sin[Global`x1], MyP`Private`x1] (*Global` or current $Context really*) Why? You can read more in a related topic: Behavior of Remove inside a Package and in the general one I'm encouraging you to become familiar with: How symbol lookup actually works There are some tricks available to detect a ...


3

To the best of my knowledge, the answer to your question is simply: no. Meta comments: I don't think your question ought to be closed as "out of scope", since you are not actually asking for anyone to write the function for you. My suggestion would be to write the function yourself and edit the question to include your attempt, making the focus of the ...


2

It seems to me that setenv is being used here to set the values of a series of helper variables that are then used by the other functions in the code. This (is awful but) works within a single notebook because all those variables are visible to all functions. I suspect, however, that once you put the code in a package, you run into context problems. Those ...


2

I'm no expert on SciDraw, perhaps one will chime in. I'm sure the way to do what you are asking is somewhere in the accepted options, there are many of them Options@DataPlot // Length Options@FigurePanel // Length Options@Multipanel // Length (* 204 *) (* 495 *) (* 502 *) Here is the best kludge I could work out using this package without learning all ...


1

The RGTensors definition in the EDCRGTCcode.m file for that package starts as follows: RGtensors[gIN_, xIN_, opt___] := Module[ {frameOpt = 0, eIN, Ropt = True, Wopt = True, Eopt = True, idMat, eFrame, dxRul, Bmat, Amat, NP$ = False, de, k$, StrCon, γUdd, γddd, g1ddd, g2ddd, Gamddd, rmn, tmp, RUd, Rg, gg, sT, Cflat, EinSp}, Clear[ ...



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