Questions tagged [contexts]

Questions about contexts, which are used in Mathematica to organize defined symbols and avoid conflict between symbols that would otherwise have the same name. They are created when packages are loaded.

Filter by
Sorted by
Tagged with
1 vote
0 answers
71 views

What's the meaning of Global?

I'm calculating an integral, Integrate[(t e^(-z t) e^(-q t))/(1-e^(-t)), t], and the result is ...
user avatar
  • 121
2 votes
0 answers
37 views

Once[…, "location"] adds $CellContext` to all global symbols

For certain persistence locations, such as "Notebook" or "FrontEndSession", ...
user avatar
  • 205
0 votes
1 answer
45 views

How to organise definitions that contain named parameters

I have lots of definitions of (usually numeric) quantities that depend on parameters; they're mostly matrices (in the actual code, there are many more definitions): ...
user avatar
  • 205
0 votes
0 answers
17 views

Context problems with ParallelTable and Import/Export

I work with notebooks with contexts unique to each notebook and I want to compute a list of functions $f(z,w)$ via ParallelTable and save them to files in NotebookA ...
user avatar
  • 1,169
1 vote
0 answers
28 views

How to make import and export (or equivalent) work with unique notebook contexts

I currently have my notebook's default context set to "Unique to this notebook", which is useful for when I'm doing multiple projects. However, whenever I try to use e.g ...
user avatar
  • 31
0 votes
0 answers
66 views

Package Functions Not Evaluated

Edit: To address the issue raised by MarcoB, I did the following: Added a new global variable gblCopperCoin to the dispatchtables.mx file Created a very simple new package function ...
user avatar
1 vote
0 answers
112 views

Spelunking yields <<kernel function>> [closed]

This is in the spirit of the old but excellent thread: What is the most convenient way to read definitions of in-memory symbols when we don't have the source files? (Spelunking tools) Using ...
user avatar
  • 313
7 votes
1 answer
127 views

What Does Compile`SetIterate Do?

The list of compilable functions (given by Compile`CompilerFunctions[] // Sort) shows one of the more interesting- and core-sounding functions: ...
user avatar
0 votes
1 answer
42 views

In DynamicModule, InputField does not display the update when its variable updates through PopupWindow. How to fix this?

Here's a minimal example: ...
user avatar
  • 53
1 vote
0 answers
54 views

How to avoid repeated nested loading of packages? [closed]

Suppose my main program depends on functions provided by package A and B, while package B also loads package A "privately". Now package A can be accessed from the main program via the ...
user avatar
  • 489
2 votes
1 answer
62 views

shadowing problem with options of a package

So here is my problem. I am writing a software with mathematica, that uses an external package as a resource. They are some libraries for numerical integration, the CUBA libraries. http://www.feynarts....
user avatar
0 votes
1 answer
63 views

Why is loading a list of contexts with Map Get not working?

I wish to automate the loading of packages by using Map and Get but Mathematica doesn't seem to like it. How can I make this work? This is how packages are normally loaded... ...
user avatar
  • 1,861
1 vote
0 answers
43 views

DeclarePackage causes shadowing problem in packages

The purpose of DeclarePackage is to load a package only when one of the package variables is needed. This works well when the variable is needed in a notebook but ...
user avatar
  • 81
6 votes
1 answer
85 views

Context Manipulation within Scoping Constructs

In the following the full context form of Test is not required as "Aaa`" is added to ...
user avatar
1 vote
1 answer
40 views

Strange behaviour of SubValues of a definition in a context

First we define a context: Begin["Ctx`"]; ClearAll[f]; f[m_][n_] := n // (Range /* Append[m]); End[]; We can check that ...
user avatar
  • 4,777
1 vote
0 answers
32 views

Importing equations generated in subpackage to be solved in another subpackage

I have a package which contains two subpackages: one ("`MOTSimulator`MOTGenerator") which generates a systems of differential equations of the form ...
user avatar
  • 11
1 vote
0 answers
54 views

Begin[] again (V12.1)

Some questions related to $Context and $ContextPath have already been asked and answered, but I still cannot fully grasp the ...
user avatar
0 votes
0 answers
50 views

wrong syntax in very short package

Here is a very short package ...
user avatar
  • 1,110
1 vote
0 answers
58 views

How to understand BeginPackage and Begin properly?

Using Get to evaluate these three .wl: First: ...
user avatar
1 vote
1 answer
38 views

What is my current scope if I change `Inspector>Cell options>Evaluation options>CellContext` to "Notebook"?

I mean I made this change: Now, Clear["Global`*"] and Names["Global`*"] are not working anymore. I tried ...
user avatar
  • 973
2 votes
1 answer
925 views

packages will not load [closed]

I have a package at /Users/me/Desktop/Mathematica/MyPackages/SamplePackage.m. It looks like this: ...
user avatar
  • 101
9 votes
1 answer
186 views

What is the correct to have package A use package B in its private section without making B visible to the user?

V 12.1 on windows. I am loading pkg2, which in its Private section loads pkg1 in order to call one of its function. After ...
user avatar
  • 112k
4 votes
2 answers
76 views

Move definition from one context to Global`

Suppose we have the following package ABC.wl. BeginPackage["ABC`"] Begin["DEF`"] f1 = 0; f2[x_] := x + 1 End[] EndPackage[] ...
user avatar
  • 43
0 votes
1 answer
125 views

How to load expressions into a notebook with a different context

So because I wanted my multiple notebooks to not interfere with each other, I start them with: SetOptions[EvaluationNotebook[], CellContext -> Notebook] ...
user avatar
4 votes
0 answers
42 views

Details about using packages with Wolfram Player

Is there a definitive document that describes the differences between what's allowed in Mathematica and Wolfram Player? I'm seeing differences in behavior between references to variables in packages (...
user avatar
2 votes
0 answers
48 views

Is there a function that reverts or undoes the effects of Needs? [duplicate]

Needs is used to load packages. Is there a function that cleans all the Definitions and ...
user avatar
  • 8,377
1 vote
0 answers
139 views

Numerical Derivative ND doesn't work [closed]

I have entered the following code from the ND documentation, and get the wrong answer. ...
user avatar
2 votes
0 answers
56 views

Share package functions without sharing context

I'm trying to find a solution to a problem that I've been struggling with for a while. I asked a variant of the question here: Automatically load init.m without sharing CellContext, but think I've ...
user avatar
5 votes
1 answer
85 views

What is the proper way of setting ` CellContext -> CellGroup` in the Wolfram Cloud Notebook?

I want a different evaluation context for different sections of my Notebook.Mike Honeychurch suggested to me than changing the CellContext to ...
user avatar
1 vote
2 answers
92 views

How to keep symbol bindings local to a Notebook section?

I'm using the Notebook on Wolfram-Cloud as a ... well ... notebook to keep notes about the topic I'm studying and to answer exercises. I usually keep one notebook file per chapter, with course notes ...
user avatar
6 votes
2 answers
138 views

Operators without built-in meaning are incompatible with parallel evaluation

Mathematica has a useful set of Operators Without Built-In Meanings. For example: CenterDot, CircleDot, ...
user avatar
  • 7,676
1 vote
0 answers
51 views

ClassifierFunction output dependent on current $ContextPath

I'm trying to use Classify to predict heads in a Mathematica expression from the heads of its arguments, which may be functions whose heads are not on the current <...
user avatar
2 votes
2 answers
111 views

How to make a contextual variable?

I have a question that would be trivial in OOP, but I am a newbie to programming in Mathematica, so I'm wondering how to deal with it. Basically, I want to create a package which basically involves a ...
user avatar
  • 301
1 vote
1 answer
77 views

Context issues when using NDSolve and rule substitutions in a package [duplicate]

I have a .wl package and a demo .nb notebook. The package file is testPackage.wl and it ...
user avatar
  • 253
13 votes
4 answers
1k views

What is the accessibility of a package's `Private` context variables?

I've been reading up on how Mathematica handles contexts, $Context, $ContextPath, and a few of the tutorials they have on ...
user avatar
8 votes
0 answers
66 views

Dealing with over eager shadowing messages

...
user avatar
  • 133k
4 votes
1 answer
78 views

Difference between $Context and Evaluate[Context[]] using DumpSave

If I were to type both individually with // FullForm, It would seem that both are the same: However, in the context for example of a dumpsave: ...
user avatar
  • 1,217
6 votes
1 answer
114 views

DumpSave and Notation package

I tried to follow the answer in How to save/load (export/import) symbolized variables?. In my case, I would add the code: ...
user avatar
  • 1,217
8 votes
0 answers
114 views

Current $Context of a given notebook

nb = CreateDocument[{Dynamic@$Context}, CellContext -> Notebook] It will show Notebook$$22$93500` or something similar. How ...
user avatar
  • 133k
6 votes
1 answer
899 views

Symbol appears in multiple contexts when loading package

I'm building a Mathematica application "APPStestI" that contains three packages: SUBappsA.m, SUBappsB.m, SUBappsC.m and APPStestI.m. Where APPStestI.m is the main package; SUBappsA.m and SUBappsB.m ...
user avatar
2 votes
1 answer
55 views

What's the difference between $Context<>"*" and "`*"?

When set context unique to this notebook: ClearAll @@ { $Context<>"*" } Clear["`*"] can both clear the variables I assigned. I just wonder what's the ...
user avatar
2 votes
1 answer
85 views

Loading MultivariateStatistics` changes colour of some multivariate distributions to red in notebook. Should I be worried?

I need to use the pdf of a Wishart distribution which is only defined in the package MultivariateStatistics`. However, after loading the package, some or all of the ...
user avatar
7 votes
1 answer
981 views

How to list all user-defined symbols?

I create a lot of symbols, and then I move on to my next set of manipulations. I noticed that symbols from prior sessions are still around. I have no idea how many symbols are in my context, but there ...
user avatar
5 votes
1 answer
119 views

Why does my Package not work when I use ParallelEvaluate?

I am developing a package in Mathematica for finding the conductivity of magnetic materials. The most important and time consuming processes are EigenSystem[] calls. I want to make the code modular so ...
user avatar
0 votes
0 answers
32 views

How can I Get[] a file and keep it in a given context? [duplicate]

I have a large MX file, which I need to Get before running my analysis. The following code puts the symbol in the ...
user avatar
  • 4,777
10 votes
1 answer
179 views

Attempts at backwards compatibility

I have written a package in Mathematica 11, and I would like to provide some backwards compatibility to earlier versions. An example is the function Echo. ...
user avatar
  • 1,268
3 votes
0 answers
28 views

Problem with contexts [duplicate]

Starting a fresh kernel and writing the following set of commands: Define a new context temp and a variable name x in it. <...
user avatar
  • 8,377
1 vote
0 answers
50 views

NotebookEvaluate within cell with CellContext->Notebook

I've encountered the following issue with NotebookEvaluate (note the grouping into 3 distinct cells): ...
user avatar
  • 25.1k
8 votes
1 answer
106 views

How can I use CurrentValue in packages as it generates symbols in current context?

I just found that CurrentValue[$FrontEnd,"ScreenInformation"] will generate (some of) the symbols it uses as keys in the current context of the first evaluation (it ...
user avatar
  • 23.1k
4 votes
1 answer
103 views

ThrowAway Environment and Scoping

I want to be able to Get a .wl file. Run some functions (who will do their job working on some separate files that are being written away). And then return to some clean slate so that I can repeat ...
user avatar
  • 3,613