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.

30 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12 votes
0 answers
233 views

Autocomplete of non-global functions

In Mathematica 9 and 10 they added autocompletion. Out of the box this works great, but when I set the CellContext to "Notebook" ...
Anders's user avatar
  • 121
8 votes
0 answers
135 views

Current $Context of a given notebook

nb = CreateDocument[{Dynamic@$Context}, CellContext -> Notebook] It will show Notebook$$22$93500` or something similar. How ...
Kuba's user avatar
  • 137k
7 votes
0 answers
118 views

Does one need to be careful about loading multiple (many) contexts or packages in the same session?

I have a number of large pieces of precomputed data which I am considering putting into individual packages in order to load them (via DeclarePackage) and unload ...
Tobias Hagge's user avatar
  • 1,382
6 votes
0 answers
123 views

How is CellContext->CellGroup supposed to work?

After reading the documentation on the subject, I still cannot get CellContext->CellGroup to work. Here's a simple example. (Unfortunately, I cannot easily ...
kjo's user avatar
  • 11.7k
4 votes
0 answers
79 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,323
4 votes
0 answers
48 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 (...
Stanley Rabinowitz's user avatar
4 votes
0 answers
72 views

Building the $Context from a stack of Begin and BeginPackage

Assume I'm reading a package file and want to know the current $Context while going serially through the file. I want to do this by inspecting the arguments of each ...
halirutan's user avatar
  • 113k
3 votes
1 answer
84 views

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

For certain persistence locations, such as "Notebook" or "FrontEndSession", ...
Deniz's user avatar
  • 235
3 votes
0 answers
153 views

Get context from notebook

The function Context[] returns the context of the Notebook the function is called in. Is there a function where we can specify e.g a Notebook object and retrieve ...
Lou's user avatar
  • 3,832
3 votes
0 answers
178 views

Shadowing issue with DeleteDuplicatesBy

I have been running a function in Mathematica 10 with the command, DeleteDuplicatesBy. The function was working great until one day I started to get an error with ...
hmm1050's user avatar
  • 101
3 votes
0 answers
170 views

Setting individual CellContext for each notebook loses autocomplete suggestions

I'm running Mathematica 9.0.1 under OS X. In order to have separate contexts for each of my notebooks, I used the instructions in the last part of the accepted answer from the following link: Is ...
Aky's user avatar
  • 2,719
2 votes
0 answers
55 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
2 votes
0 answers
65 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 ...
KHAAAAAAAAN's user avatar
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 ...
Gert's user avatar
  • 1,530
1 vote
0 answers
107 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
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 ...
w.ice's user avatar
  • 31
1 vote
0 answers
65 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
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
1 vote
0 answers
87 views

How to understand BeginPackage and Begin properly?

Using Get to evaluate these three .wl: First: ...
IRA_Mikado's user avatar
1 vote
0 answers
55 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 <...
lirtosiast's user avatar
1 vote
0 answers
65 views

NotebookEvaluate within cell with CellContext->Notebook

I've encountered the following issue with NotebookEvaluate (note the grouping into 3 distinct cells): ...
Lukas Lang's user avatar
  • 34.1k
1 vote
0 answers
121 views

Strange Behavior with Private Contexts in 10.0.1

I have noticed the following weird behavior when creating Private Context in V 10.0.1, a behavior not present in V 10.0.0. ...
RunnyKine's user avatar
  • 33.1k
1 vote
0 answers
166 views

NMaximize with matrix input

I defined function f[x_, fixed_] := {...}. Here x is an $M\times N$ matrix. I want to maximize $f$ with respect to $x$. I have ...
Cheng Chou's user avatar
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,798
0 votes
0 answers
64 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
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,323
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 ...
Jonathan Kinlay's user avatar
0 votes
0 answers
64 views

wrong syntax in very short package

Here is a very short package ...
florin's user avatar
  • 1,798
0 votes
0 answers
217 views

How can I cleanly distribute definitions of system functions?

I have a package that redefines a system symbol, and I am struggling to find a clean solution that will ensure that those redefinitions will still work inside a parallelized environment. The core ...
Emilio Pisanty's user avatar