Bug using Options[]
- To: mathgroup at smc.vnet.net
- Subject: [mg16070] Bug using Options[]
- From: Dan Truong <dtruong at irisa.fr>
- Date: Tue, 23 Feb 1999 03:45:23 -0500
- Organization: IRISA, FRANCE
- Sender: owner-wri-mathgroup at wolfram.com
I am trying to use functions with optional parameters. However, it
seems that sometimes the Options[] are used even when I specify some
other input. This happens in the example below for the cs parameter,
but for example, zticks seems OK.
Note: I cut out much of the code, so definitions are not complete...
Am I doing something stupid somewhere? Could there be a global
definition
somewhere which would bypass my code? If so how could I prevent such
problems?
I do use the variable name cs often for data.
-
Block[
{i,cs,ls,as,xAxis,yAxis,zAxis,theMisses,title}
,
Clear[Stack3D];
Clear[Stack3DBody];
Options[Stack3D] := {
cs-> Evaluate[Table[i,{i,minCS,maxCS}]],
zTicks-> Table[ {i,StringJoin[ToString[N[100*i]], "%"]}, {i,0,1,0.1}
],
theMisses -> {1,0,0,1,0,1,1}
(* ... *)
};
Stack3D[opts___] := Stack3DBody[
cs /. {opts} /. Options[Stack3D],
zTicks /. {opts} /. Options[Stack3D],
theMisses /. {opts} /. Options[Stack3D]
(* ... *)
];
Stack3DBody[
cs_,
ls_,
as_,
title_,
theArray_,
xAxis_,
yAxis_,
zAxis_,
xTicks_,
yTicks_,
zTicks_,
theMisses_
] := (
theGraphics = Table[Graphics3D[Cuboid[{-1,-1,-1}]],{i,1,lastIdx,1}];
Print[
"CS ",cs , " minCS ", minCS, " maxCS ", maxCS,
];
);
];
zId = 0.8;
list3D = Stack3D[
cs->Table[x,{x,15,maxCS,1}],
zTicks-> Table[ {i,StringJoin[ToString[100*i], "%"]},
{i,0,1*zId,0.1*zId} ],
zAxis->{"Misses",0,zId},
theMisses->{1,0,0,1,0,1,1}
]
Output:
CS {3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20} minCS 3 maxCS 20
zTicks
{{0,"0%"},{0.08,"8.%"},{0.16,"16.%"},{0.24,"24.%"},{0.32,"32.%"},{0.4,"40.%"},{0.48,"48.%"},{0.56,
"56.%"},{0.64,"64.%"},{0.72,"72.%"},{0.8,"80.%"}}
The output should be:
CS {15,16,17,18,19,20} minCS 3 maxCS 20
Note that zTick goes from 0 to 80% which is good (in Options[] it'sset
from 0 to 100%).