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
3 votes
1 answer
82 views

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

For certain persistence locations, such as "Notebook" or "FrontEndSession", ...
1 vote
2 answers
109 views

How to write Boxes to a notebook with NotebookWrite?

I would like to write Boxes to a Cell to a notebook (e.g., FractionBox, SuperscriptBox, etc). Here is what I've tried: ...
0 votes
1 answer
106 views

How do contexts work exactly? Is there anything special about Private` or Internal` context?

Suppose I begin a package: BeginPackage["MyPackage`"]; Before running this command in a fresh kernel, the context and path were: ...
5 votes
1 answer
135 views

Weird symbol shadowing from GraphicsRasterInformationPatch` when loading NCAlgebra`

When doing ...
0 votes
0 answers
23 views

This script included in a package has some error leading to one variable having context different from others

The package modt ...
2 votes
1 answer
69 views

How do I make all the external contexts accessible within subcontexts of my package?

I have a package file MyPackage.wl it has the following commands: ...
6 votes
1 answer
206 views

Symbols leak into Global context when using Information

Bug introduced before 12.1.0, fixed in 13.3.0 [CASE:4972508] When debugging I found the following peculiar behaviour of Information: ...
1 vote
0 answers
39 views

Autocomplete for package in notebook with context "Unique To This Notebook"

I have the setting that my notebooks their context is unique for each notebook to avoid accidental lingering definitions. I really need this because I'm often distracted and e.g. overwrite files when ...
1 vote
2 answers
136 views

Is there a fast method of clearing symbols in the sub-contexts named by other symbols?

When writing packages I met the following problem. The way I name helper functions is like ...
3 votes
1 answer
102 views

Autocomplete doesn't work when the CellContext is set to be Notebook (Mathematica 13.3)

I am using mathematica 13.3. When the CellContext option is "Global" the autocomplete works fine. I would like to have individual variable in each notebook, so I use the following command: <...
2 votes
2 answers
109 views

Avoid context mark in Plot labels in package

Minimal example: ...
4 votes
0 answers
78 views

Temporary symbol leaks into public context?

This phenomenon has confused me a long time. Consider the following package example, ...
9 votes
1 answer
125 views

Dealing with over eager shadowing messages

...
0 votes
0 answers
63 views

Unable to use a function from Get with Encode

I am trying to create a proprietary function as discussed in this link: How to distribute proprietary Mathematica code So I create a function and dump it into a file ...
2 votes
1 answer
124 views

Why does using a variable name as pattern name determine its context?

Checking the context of a fresh variable inside Begin-End, it gives the enclosing context. ...
3 votes
2 answers
120 views

Inconsistent behaviour of availability of variables when re-entering `Context`

I am quite confused about Context. I have a long semi-manual signal processing task. I already did that for one signal and I need to do it for another one. I want ...
2 votes
1 answer
123 views

How to delete a word set in a text?

I have a setence: ...
1 vote
2 answers
106 views

How do I get all the contexts that a shadowed symbol is in?

I have some shadowed symbols. How do I list all the contexts that they are in? For instance, consider symbol x which is in contexts: package1, package2 ...
0 votes
0 answers
50 views

Why Names will search all subcontexts?

My version is 13.2. When debugging I came across this peculiar feature of Names. Starting with a fresh kernel, define Then ...
2 votes
0 answers
54 views

Predict Occurs in More than One Context - Mathematica v13.2

I am receiving an error message in Mathematica 13.2 that the system function Predict appears in more than one context: one of the definitions is shadowed. This shouldn't be happening, of course. In ...
1 vote
2 answers
113 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): ...
4 votes
1 answer
71 views

problem using package to verify solution of ode with Association, Naming scope/context handling [duplicate]

I learning how to use packages. I found a big problem. Here is description of the problem is, then a MWE is given. This small package takes in an ode and ...
0 votes
1 answer
81 views

Why do we have to write context name when re-Begin[] a same context?

as the following picture shows, when I Begin[] a same context(same name), why i use the function yjn[](defined in the previous same name context) still have to write the context name? similar ...
1 vote
1 answer
135 views

How can I use FeynCalc in ParallelTable or ParallelSum?

I want to speed up a FeynCalc calculation. However I found out that it doesn't seem to work in ParallelSum or ParallelTable. MWE:...
0 votes
0 answers
22 views

Replacing System` definitions in a context whilst still maintaing acces to them [duplicate]

Given the system operator TensorContract I can define a new one, TensorContractLazy with the attribute ...
4 votes
2 answers
309 views

The problem with "Symbol appears in multiple contexts" when loading package with same function name in subpackages

There is a similar question about this, 8 years ago!, but the answer there does not really give what to do. The answer just says yes one can use same function name in different packages but has use ...
5 votes
1 answer
107 views

How do I remove the context from help messages

When using ?? I get the results which the context included. While technically accurate it makes the code difficult to read. The following ...
18 votes
4 answers
2k views

Strategies for avoiding and handling shadowing

When dealing with namespaces in Mathematica (BeginPackage, $ContextPath ...) one is unavoidably confronted with the problem of ...
1 vote
0 answers
102 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 ...
1 vote
0 answers
33 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 ...
0 votes
0 answers
131 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 ...
1 vote
0 answers
138 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 ...
8 votes
1 answer
141 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: ...
0 votes
1 answer
51 views

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

Here's a minimal example: ...
11 votes
1 answer
274 views

NotebookEvaluate breaks notebook's context

Bug introduced in 10.4.1 or earlier and persists through 12.0 A support case with the identification [CASE:3813108] was created [...] I have forwarded an incident report to our developers with the ...
1 vote
0 answers
60 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 ...
0 votes
1 answer
77 views

Unexpected context change

I have a strange problem with Mathematica (10.1.0 for Microsoft Windows (64-bit) (March 24, 2015)). Namely when I evaluate expression ...
15 votes
1 answer
418 views

Potential pollution of Global` context in fresh kernel

Bug introduced in 10.0.0 and fixed in 10.0.1 The bug is also present in 12.2.0 and resolved in 12.3.0 on Mac OS X x86 (64-bit). If I evaluate, with a fresh kernel ...
2 votes
1 answer
108 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....
0 votes
1 answer
70 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... ...
1 vote
0 answers
63 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 ...
2 votes
1 answer
1k views

packages will not load [closed]

I have a package at /Users/me/Desktop/Mathematica/MyPackages/SamplePackage.m. It looks like this: ...
2 votes
0 answers
51 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 ...
0 votes
1 answer
247 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] ...
0 votes
0 answers
34 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 ...
6 votes
1 answer
89 views

Context Manipulation within Scoping Constructs

In the following the full context form of Test is not required as "Aaa`" is added to ...
1 vote
1 answer
44 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 ...
1 vote
0 answers
36 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 ...
1 vote
0 answers
57 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 ...
0 votes
0 answers
64 views

wrong syntax in very short package

Here is a very short package ...

1
2 3 4 5