Re: Package writing
- To: mathgroup at smc.vnet.net
- Subject: [mg67332] Re: Package writing
- From: albert <awnl at arcor.de>
- Date: Sun, 18 Jun 2006 05:13:36 -0400 (EDT)
- References: <e6lhqr$nfs$1@smc.vnet.net><e6oq7b$si8$1@smc.vnet.net> <e6r395$n8c$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Marek, > I have to say that I do not know what the autocreate-package > functionality is but I know that when I save a notebook with > initialization cells they are being written into an .m file and I > relied on that method to create the package. that's what I meant. > That is exactly what I do. Please see my other reply to another message > in that thread which I just submitted. I outline all the steps I do > after opening my notebook untill I can see that the package is not > working. unfortunately didn't find that post yet. > I set the directory so that my .m file is written in that location. hm, AFAIK the .m file is alway written to the directory where the .nb file lives, no matter what the Directory is set to. Never thought about it really, but keep in mind that the saving of the .m file is done by the frontend, not the kernel, and with SetDirectory you set the working directory of the kernel... > I did try PrependTo at some point but that did not solve my problem. > I will have a look and check if there are some other files with the > same name in the directories included in $path variable. if there are no other files with the same name, it doesn't make a difference at all, I think. >> Check the context and definitions of these symbols with: >> ??functioname >> >> This will give you the right pointers, I'm pretty sure... > > I am not sure if I know what to expect from that command so here are > the first two lines of the output after executing ??BcgSubtract > > BcgSubtract[data,n] tries to estimate the background and subtracts it > from \ > the input data file. > BcgSubtract[DataAnalysis`Private`data_, DataAnalysis`Private`fr_ : 20.] > := > Module[{DataAnalysis`Private`temp, DataAnalysis`Private`m, > > and further down I see basically my module with DataAnalysis`Private` > appended to each and every variable. Does that look reasonable? yes, looks correct. So obviously the symbols are available along with their definitions. I can't see any reason why they shouldn't work.. > No editing. I do have BeginPackage[] and EndPackage[] in my notebook. That's strange. This is why: Needs["PackageName`"] looks for a file PackageName.m (and some other extensions) to load. If it finds it, it will load it. If the file PackageName.m does not create the context PackageName` Needs will complain (but Get[] would not). For that reason you should definitly get an error message if you do Needs["DD`"] when the file DD.m doesn't contain a BeginPackage["DD`"]... >> Wrong guess: the package in AutoLoad will be loaded, even without an >> explicit Needs for it whenever a new kernel is started. That's the >> purpose of the AutoLoad-directory after all and the name should be a hint >> for that. For the purpose you are (miss)using AutoLoad you should better >> use the directory ~/.Mathematica/Applications, which is designed (AFAIK) >> to store personally installed (third-party) packages, where third party >> can of course be yourself. > > Yes I agree that the name of that directory is very suggestive. > However if I open Mathematica and have fresh, clean blanck notebook in > front of me non of the functiones from my package (a copy of which is > in .Mathematica/AutoLoad directory) is recognized (The autocomplition > does not work). It only works after executing Needs[] commands. Is > there something wrong with my Mathematica? I am using version 5.1 on > Gentoo Linux box. I just tried it and atuoloading obviously only works if you have a full directory-structure for a package in Autoload, just a packagefile will not be loaded. Whether that is the desired behaviour I don't know but there is nothing to worry about your installation I guess... When writing this I have another question: does you kernel run on the same machine as the frontend does? Are they seeing the same directory structure? Any notebook can have a Kernel-definitions associated, maybe the one for DataAnalysis.nb is different from the default? > It is probably something simple I am missing here. If You don't mind > could You please go to my website at www.physics.mun.ca/~marek and I > will post my notebook there so that You could grab it and play with it. > Please keep in mind that it is my first package so thing might not be > done 100% the "Mathematica" way. > Look for DataAnalysis.nb link on the front page I have downloaded it, copied to ~/Mathematica/Packages, changed the extension to $Path to: AppendTo[$Path, ToFileName[{$HomeDirectory,"Mathematica","Packages"}]] and everything works as expected. hm. The only thing I realized is that you are calling e.g. DeconvolveData with just one argument, but it expects exactly two. Did you have another definition which works with one argument in an earlier version that gets loaded with a default notebook? If I change the tests to calls of DeconvolveData with an additional arguments they seem to work... When checking for other versions of your package, do you know the following: FileNames["DataAnalysis.m", $Path] the first filename in the resulting list is the one that Needs will load. Maybe you want to try this with a fresh notebook and the DataAnalysis.nb and see if there is a difference... Something else: are you sure you want cellgrouping to be set to manual? Your sections are arranged somewhat irregular when closing the subgroups, at least to my taste :-). Maybe you want to just change Cells-> CellGrouping->Automatic. Makes the closing of subgroups correspond to the structure much better, I think... albert
- Follow-Ups:
- Re: Re: Package writing
- From: Bruce Miller <brucem@wolfram.com>
- Re: Re: Package writing