The following issue is now resolved -- with thanks going to @Eric Rimbey for pointing out my mis-use of the form Needs["context" -> "alias"]
prevented my paclet symbols from being loaded into $Context. Attached is the working example where using Needs["context"]
solves my issue.
The original question follows.
In my paclet, I have a function that extracts relevant symbols from an equation to return a sorted symbols list. But my implementation strategy fails when anyone calls my paclet function from a different namespace context. Is there a means of creating a function were I can add a blank sequence for the context? Or, is there a more generalized strategy for handing symbols between different contexts?
Implementation:
pSort[ M ] = 1;
pSort[ w[id_] ] := 100 + id;
pSort[ A[id_] ] := 200 + id;
extractSymbols[ equation_ ] :=
Block[{varsAndCosVars, deDupedAndAll},
varsAndCosVars = (Variables @ equation) /. (Cos[vars_] :> Variables @ vars);
deDupedAndAll =
DeleteCases[DeleteDuplicates[Flatten[varsAndCosVars]], t]];
Test:
testEq1 = A[2]*Cos[w[2]*t] + A[1]*Cos[w[1]*t] + M;
Sort[extractSymbols @ testEq1, pSort[#1] < pSort[#2] &]
Expected Result:
{M, w[1], w[2], A[1], A[2]}
Problem: While the above does work in the paclet context space, it fails when extractSymbols is invoked from another context where the Symbols in the equation are unique to caller's context space.
Attachments: