I have created a Mathematica package that manipulates various types of input physics data into a common form of output data for further analysis. To make this process more efficient and manageable, I assign each specific set of data a different head and define the manipulation functions differently (as necessary) for each of the various heads. For example,
getX[data_AA] := data[[1]];
getY[data_AA] := data[[2]];
getZ[data_AA] := data[[3]];
getR[data_AA] := Module[{x=getX[data],y=getY[data]},Return[x^2+y^2]]
...and so on...
getR[data_BB] := data[[1]];
getPhi[data_BB] := data[[2]];
getX[data_BB] := Module[{r=getR[data],phi=getPhi[data]},Return[r*Cos[phi]]]
...and so on...
getX[data_CC] := data[[5]];
...and so on...
Accordingly, I have written functions that change the heads of the data from List (since the data are imported from files into arrays) to their respective heads so that the data can then be used as arguments in the manipulation functions like the examples above: for example,
makeAA[AAdata_] := Return[AAdata /. List -> AA]
Because I want this to all be done internally, so that one cannot simply initialize a random object in a notebook with a global head of AA and then use the manipulation functions on that arbitrarily created object (see Note below), I have made the heads private members of the module. If the data is returned, however, by the function, say,
getAAdata[filename_]
then it is displayed as
PackageName`Private`AA[PackageName`Private`AA[particle 1 data],PackageName`Private`AA[particle 2 data],...,PackageName`Private`AA[particle N data]]
instead of the more concise and, therefore, more desirable
AA[AA[particle 1 data],AA[particle 2 data],...,AA[particle N data]]
(this is especially a problem when dealing with further nested arrays).
So the question is: how can I get private objects (heads, variables, etc.) to display in outputted data without the cumbersome and cluttering "PackageName`Private`" prefix?
Note: it is not sufficient to list the heads in the public part of the package because then, even though it would solve the above problem, it would introduce an additional problem that one would be able to initialize arbitrary objects with those heads -- say, test=AA[2.1,3.2,5.4,2.3]
-- and then call getX[test]
, which will then carry out the evaluation as it would any object with head AA
. I want to reserve creating objects with those heads to other functions in the package (such as makeAA
; see above).
This problem also shows up if I don't explicitly write a usage description/tag for a function and try to get information on the function by doing
?Function
-- all the arguments and local variables are written with the "PackageName`Private`" prefix, making it rather difficult to read the body of the function.
Thank you very much for your help!