Skip to content

Commit

Permalink
Use ThrowError instead of Throw
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Feb 20, 2012
1 parent a6d92e9 commit 7840f15
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Tools/CodeGen/CalculationFunction.m
Expand Up @@ -811,7 +811,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be

If[OptionValue[ProhibitAssignmentToGridFunctionsRead] &&
gfsInBoth =!= {},
Throw["The calculation " <> ToString@lookup[cleancalc, Name] <>
ThrowError["The calculation " <> ToString@lookup[cleancalc, Name] <>
" has the grid functions " <> ToString[gfsInBoth] <>
" on both the left hand side and the right hand side. This is" <>
" not allowed with the option" <>
Expand All @@ -831,7 +831,7 @@ pathalogical enough (e.g. {s1 -> s2, s2 -> s1} would not be
gfsDifferentiatedAndOnLHS = Intersection[gfsDifferentiated, gfsInLHS];

If[gfsDifferentiatedAndOnLHS =!= {},
Throw["The calculation " <> ToString@lookup[cleancalc, Name] <>
ThrowError["The calculation " <> ToString@lookup[cleancalc, Name] <>
" has both assignments to, and derivatives of, the grid functions " <>
ToString[gfsDifferentiatedAndOnLHS] <>
". This is not allowed, as it gives results which are dependent" <>
Expand Down
2 changes: 1 addition & 1 deletion Tools/CodeGen/CodeGenCactus.m
Expand Up @@ -86,7 +86,7 @@
DefFn[
DataType[] :=
If[dataType === Symbol["datatype"],
Throw["DataType: Have not set a data type"],
ThrowError["DataType: Have not set a data type"],
dataType]];

DefFn[
Expand Down
16 changes: 8 additions & 8 deletions Tools/CodeGen/Differencing.m
Expand Up @@ -200,7 +200,7 @@ A GridFunctionDerivative (GFD) is an expression of the form
paramsInOps = Union@Flatten@Map[Cases[derivOps, #, Infinity] &, intParamNames];

If[Length[paramsInOps] > 1,
Throw["Cannot have more than one integer parameter in the list of partial derivative definitions"]];
ThrowError["Cannot have more than one integer parameter in the list of partial derivative definitions"]];

If[paramsInOps === {},
Map[DerivativeOperatorVerify, derivOps];
Expand Down Expand Up @@ -261,7 +261,7 @@ A GridFunctionDerivative (GFD) is an expression of the form
CheckStencil[derivOps_, eqs_, name_, zeroDims_, intParams_] :=
Module[{psUsed, p},
psUsed = parametersUsedInOps[derivOps, intParams];
If[Length[psUsed] > 1, Throw["Too many parameters in partial derivatives"]];
If[Length[psUsed] > 1, ThrowError["Too many parameters in partial derivatives"]];
If[psUsed === {},
CheckStencil[derivOps,eqs,name,zeroDims],
p = psUsed[[1]];
Expand All @@ -285,7 +285,7 @@ A GridFunctionDerivative (GFD) is an expression of the form
StencilSize[derivOps_, eqs_, name_, zeroDims_, intParams_] :=
Module[{psUsed, p},
psUsed = parametersUsedInOps[derivOps, intParams];
If[Length[psUsed] > 1, Throw["Too many parameters in partial derivatives"]];
If[Length[psUsed] > 1, ThrowError["Too many parameters in partial derivatives"]];
If[psUsed === {},
StencilSize[derivOps,eqs,name,zeroDims],
p = psUsed[[1]];
Expand Down Expand Up @@ -514,7 +514,7 @@ A GridFunctionDerivative (GFD) is an expression of the form
result = Replace[result, _Symbol -> 1, {-1}];

If[!And@@Map[NumericQ, result],
Throw["Stencil width is not numeric in "<>ToString[componentDerivOp]]];
ThrowError["Stencil width is not numeric in "<>ToString[componentDerivOp]]];
result]];

(* Farm out each term of a difference operator *)
Expand Down Expand Up @@ -585,13 +585,13 @@ A GridFunctionDerivative (GFD) is an expression of the form
If[MatchQ[ips, List[ (_ ? NumberQ) ...]],
Return[{name[indPatterns] -> expr/.zeroDimRules}]];

Throw["DerivativeOperatorToComponents: Expecting indices which are symbolic patterns or numbers"];
ThrowError["DerivativeOperatorToComponents: Expecting indices which are symbolic patterns or numbers"];
]];

DerivativeOperatorVerify[derivOp_] :=
If[!MatchQ[derivOp, pd_[_Pattern ...] -> expr_?DerivativeOperatorRHSVerify] &&
!MatchQ[derivOp, pd_[_ ? NumberQ ...] -> expr_?DerivativeOperatorRHSVerify],
Throw["Derivative operator definition failed verification: ", ToString[derivOp]]];
ThrowError["Derivative operator definition failed verification: ", ToString[derivOp]]];

DerivativeOperatorRHSVerify[expr_] :=
Module[{allAtoms, symbols},
Expand Down Expand Up @@ -730,10 +730,10 @@ A GridFunctionDerivative (GFD) is an expression of the form

expandDerivOpOverParameters[op_, intParams_] :=
Module[{usedParams},
If[Head[op] =!= Rule, Throw["Invalid partial derivative",op]];
If[Head[op] =!= Rule, ThrowError["Invalid partial derivative",op]];
usedParams = Select[intParams, Cases[op, getParamName[#], Infinity] =!= {} &];
If[Length[usedParams] > 1,
Throw["Partial derivatives can only depend on a single parameter"]];
ThrowError["Partial derivatives can only depend on a single parameter"]];
If[usedParams === {},
{op},
expandDerivOpOverParameter[op, usedParams[[1]]]]];
Expand Down
4 changes: 2 additions & 2 deletions Tools/CodeGen/Jacobian.m
Expand Up @@ -79,7 +79,7 @@
lhss = Map[First, eqs];
positions = Map[Position[lhss, #, {1}, 1] &, shortsUsed];
MapThread[If[Length[#2] === 0,
Throw["Shorthand " <> ToString[#1] <> " used in derivative " <> ToString[deriv] <>
ThrowError["Shorthand " <> ToString[#1] <> " used in derivative " <> ToString[deriv] <>
" but not defined in calculation"]] &, {shortsUsed, positions}];
positions2 = Map[#[[1,1]] &, positions];
position = If[Length[positions2] === 0, 1, Max[positions2]+1];
Expand Down Expand Up @@ -160,7 +160,7 @@
Module[{int},
int = Intersection[allGroupVariables[groups], allGroupVariables[JacobianGroups[]]];
If[int =!= {},
Throw["Error: Some group variables conflict with reserved Jacobian variable names: " <> ToString[int]]]];
ThrowError["Error: Some group variables conflict with reserved Jacobian variable names: " <> ToString[int]]]];

(* These gridfunctions are only given local variable copies if the use_jacobian variable is true *)
JacobianConditionalGridFunctions[] :=
Expand Down
2 changes: 1 addition & 1 deletion Tools/CodeGen/TensorTools.m
Expand Up @@ -562,7 +562,7 @@
x;

makeSum[x_] :=
Throw["Expression " <> ToString[x] <>
ThrowError["Expression " <> ToString[x] <>
" is not recognized, and tensor indices will not be expanded"];

sumComponentsOfDummyIndex[x_, i_] :=
Expand Down
6 changes: 3 additions & 3 deletions Tools/CodeGen/Thorn.m
Expand Up @@ -425,7 +425,7 @@
ConditionalOnParameter[parameter, value, u],

If[condition != {},
Throw["Unrecognized conditional structure", condition],
ThrowError["Unrecognized conditional structure", condition],
u]]],
u];

Expand All @@ -447,7 +447,7 @@
ConditionalOnParameter[parameter, value, x],

If[condition != {},
Throw["Unrecognized conditional structure", condition],
ThrowError["Unrecognized conditional structure", condition],
x]],
x]],
v, conditions],
Expand Down Expand Up @@ -499,7 +499,7 @@
Module[{calc = First[calcs],bodyFunction},

If[!MatchQ[include, _List],
Throw["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]];
ThrowError["CreateSetterSource: Include should be a list but is in fact " <> ToString[include]]];

SetDataType[If[OptionValue[UseVectors],"CCTK_REAL_VEC", "CCTK_REAL"]];

Expand Down
11 changes: 2 additions & 9 deletions Tools/CodeGen/xTensorKranc.m
Expand Up @@ -120,17 +120,10 @@
Return[group]
];

ReflectionSymmetries[x___]:= Throw["ReflectionSymmetries error: "<>ToString[x]];
CreateGroupFromTensor[x___]:= Throw["CreateGroupFromTensor error: "<>ToString[x]];
ReflectionSymmetries[x___]:= ThrowError["ReflectionSymmetries error: "<>ToString[x]];
CreateGroupFromTensor[x___]:= ThrowError["CreateGroupFromTensor error: "<>ToString[x]];

CheckTensors[expr_] := Validate[expr];

End[];
EndPackage[];







0 comments on commit 7840f15

Please sign in to comment.