Skip to main content

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
69 views

Problem defining Function inside Module to verify ODE solution [duplicate]

I modified the question. It turns out this problem has nothing to do with using a package. New style or standard style./ Same problem shows in a normal module in notebook. This is the most bizzar ...
Nasser's user avatar
  • 149k
6 votes
1 answer
236 views

On the new package style. Conflict using the same name in the parent and in the child packages

I am learning the new package style as current one is not working for me. I know it is probably not a good idea to use something with no official Wolfram documentation and not officially released. But ...
Nasser's user avatar
  • 149k
4 votes
2 answers
222 views

How to keep private package function private when adding package name to function name inside the package?

I like to call my package private functions using mypkg`functionName[...] i.e. add an explicit mypkg to each call. This ...
Nasser's user avatar
  • 149k
3 votes
1 answer
102 views

How to make my OOP class work inside a package?

I like to use this simple OOP setup in Mathematica that I learned from reading posts here over the years and playing around with it. This makes a Class and implement basic OOP (nothing fancy like ...
Nasser's user avatar
  • 149k
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 ...
florin's user avatar
  • 1,982
2 votes
1 answer
70 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: ...
user13892's user avatar
  • 9,651
0 votes
1 answer
127 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: ...
user13892's user avatar
  • 9,651
5 votes
1 answer
139 views

Weird symbol shadowing from GraphicsRasterInformationPatch` when loading NCAlgebra`

When doing ...
Gravifer's user avatar
  • 894
1 vote
0 answers
41 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 ...
Gert's user avatar
  • 1,620
3 votes
1 answer
119 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: <...
Oliver Redman's user avatar
2 votes
2 answers
112 views

Avoid context mark in Plot labels in package

Minimal example: ...
LittleCat1's user avatar
4 votes
0 answers
82 views

Temporary symbol leaks into public context?

This phenomenon has confused me a long time. Consider the following package example, ...
Lacia's user avatar
  • 2,557
0 votes
0 answers
65 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 ...
IntroductionToProbability's user avatar
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. ...
Jineon Baek's user avatar
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 ...
atapaka's user avatar
  • 4,006
2 votes
1 answer
128 views

How to delete a word set in a text?

I have a setence: ...
SAC's user avatar
  • 1,335
1 vote
2 answers
107 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 ...
podge cassidy's user avatar
1 vote
2 answers
115 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: ...
Craig Carter's user avatar
  • 4,675
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 ...
Lacia's user avatar
  • 2,557
2 votes
0 answers
60 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 ...
MMAUser's user avatar
  • 409
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 ...
Nasser's user avatar
  • 149k
0 votes
1 answer
82 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 ...
Aerterliusi's user avatar
1 vote
2 answers
138 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 ...
Lacia's user avatar
  • 2,557
1 vote
1 answer
145 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:...
infinitezero's user avatar
  • 1,441
0 votes
0 answers
23 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 ...
user3257842's user avatar
4 votes
2 answers
381 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 ...
Nasser's user avatar
  • 149k
5 votes
1 answer
109 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 ...
Daniel Geisler's user avatar
6 votes
1 answer
207 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: ...
Lacia's user avatar
  • 2,557
1 vote
0 answers
118 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 ...
N.S.'s user avatar
  • 121
3 votes
1 answer
92 views

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

For certain persistence locations, such as "Notebook" or "FrontEndSession", ...
Deniz's user avatar
  • 235
1 vote
2 answers
118 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): ...
Deniz's user avatar
  • 235
1 vote
0 answers
35 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 ...
w.ice's user avatar
  • 31
0 votes
0 answers
138 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 ...
Jonathan Kinlay's user avatar
1 vote
0 answers
146 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 ...
qreus's user avatar
  • 343
8 votes
1 answer
144 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: ...
Just Some Old Man's user avatar
0 votes
1 answer
53 views

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

Here's a minimal example: ...
jWey's user avatar
  • 73
1 vote
0 answers
62 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 ...
felix's user avatar
  • 569
2 votes
1 answer
111 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....
Giorgio Busoni's user avatar
0 votes
1 answer
71 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... ...
Jules Manson's user avatar
  • 2,467
1 vote
0 answers
67 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 ...
HannesK's user avatar
  • 81
6 votes
1 answer
90 views

Context Manipulation within Scoping Constructs

In the following the full context form of Test is not required as "Aaa`" is added to ...
Ronald Monson's user avatar
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 ...
Shredderroy's user avatar
  • 5,331
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 ...
crich's user avatar
  • 11
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 ...
Florian Hamamelis's user avatar
0 votes
0 answers
66 views

wrong syntax in very short package

Here is a very short package ...
florin's user avatar
  • 1,982
1 vote
0 answers
89 views

How to understand BeginPackage and Begin properly?

Using Get to evaluate these three .wl: First: ...
IRA_Mikado's user avatar
1 vote
1 answer
52 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 ...
vasili111's user avatar
  • 1,235
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: ...
Brandon's user avatar
  • 101
9 votes
1 answer
407 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 ...
Nasser's user avatar
  • 149k
5 votes
2 answers
89 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[] ...
Markus's user avatar
  • 53

1
2 3 4 5