Package Problems
- To: mathgroup at smc.vnet.net
- Subject: [mg34373] Package Problems
- From: au198295 at hotmail.com (Aaron)
- Date: Fri, 17 May 2002 06:30:57 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
I have been having trouble getting functions to work in Packages that I have created. I have had this problem on a number of occasions, some of which I have fixed (usually I have no idea why it worked when I fixed it, but I don't complain). I have included an excerpt from a package below with a particularly troublesome function that I haven't been able to fix. The package loads fine, but when I call the function I get the following error: ________________________________________________________________________ data2=MSCorrect[data]; MyPackages`gliba`Private`BestFitParameters Part::partd: Part specification MyPackages`gliba`Private`BestFitParameters[[1]] is longer than depth of object. Part::partd: Part specification MyPackages`gliba`Private`BestFitParameters[[2]] is longer than depth of object. _______________________________________________________________________ I put the packages in the Applications directory in a folder called MyPackages. The function takes a rectangular matrix of real values. If I copy the function into a notebook and compile it there it works fine. Thanks In Advance For Any Help, Aaron Here is the excerpt from the package. It contains alot more functions than this, most of which work fine. I get the same error when I use this reduced package. _______________________________________________________________________ BeginPackage["`gliba`"] GLiba::usage = "GLib is a package that serves as a chemometric toolbox for analysis of real data sets." MSCorrect::usage = "newspec = MSCorrect[tnspec]. The scatter corrected spectra (newspec) are returned from the input spectra (tnspec)." Begin["`Private`"] Needs["Statistics`DataManipulation`"] Needs["Statistics`DescriptiveStatistics`"] Needs["Statistics`LinearRegression`"] MSCorrect[tnspec_List]:= Module[{norows,nocols,temp,i,coeff,x,output,outspec}, {norows, nocols} = Dimensions[tnspec]; temp = Table[0, {2}, {nocols}]; outspec = Table[0, {norows}, {nocols}]; temp[[1]] = Mean[tnspec]; For[i = 1, i < norows + 1, ++i, temp[[2]] = tnspec[[i]]; output = Regress[Transpose[temp], {x},{x}, RegressionReport->{BestFitParameters}]; coeff = BestFitParameters /. output; Print[coeff]; outspec[[i]] = (tnspec[[i]] - coeff[[1]])/coeff[[2]]; ]; Return[outspec] ]; End[ ] EndPackage[ ]