Skip to content

Commit

Permalink
Final unit tests and code tweaks for 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jdunkerley committed Aug 7, 2017
1 parent b9ccdb8 commit eaa3b53
Show file tree
Hide file tree
Showing 7 changed files with 973 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AlteryxAbacus/AlteryxAbacus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern "C" long _declspec(dllexport) _stdcall ReportError(int nNumArgs, FormulaA
{
pReturnValue->nVarType = nNumArgs > 2 ? pArgs[2].nVarType : 1;

if (nNumArgs < 1 || pArgs[0].nVarType != 1 || pArgs[0].isNull == 0 || pArgs[0].dVal != 0) {
if (nNumArgs < 1 || pArgs[0].nVarType != 1 || pArgs[0].isNull != 0 || pArgs[0].dVal != 0) {
return AlteryxAbacusUtils::ReturnError((nNumArgs < 2 || pArgs[1].nVarType == 1) ? L"Reporting An Error!" : pArgs[1].pVal, pReturnValue, nNumArgs, pArgs);
}

Expand Down
4 changes: 2 additions & 2 deletions AlteryxAbacus/ChiSquaredDistribution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" long _declspec(dllexport) _stdcall ChiDist(int nNumArgs, FormulaAddIn
else {
chi_squared_distribution<double> s(floor(pArgs[1].dVal));
pReturnValue->isNull = 0;
pReturnValue->dVal = (1.0 - cdf(s, pArgs[0].dVal));
pReturnValue->dVal = 1.0 - cdf(s, pArgs[0].dVal);
}

return AlteryxAbacusUtils::ReturnSuccess(nNumArgs, pArgs);
Expand Down Expand Up @@ -58,7 +58,7 @@ extern "C" long _declspec(dllexport) _stdcall ChiInv(int nNumArgs, FormulaAddInD
else {
chi_squared_distribution<double> s(floor(pArgs[1].dVal));
pReturnValue->isNull = 0;
pReturnValue->dVal = -quantile(s, pArgs[0].dVal);
pReturnValue->dVal = quantile(s, 1.0 - pArgs[0].dVal);
}

return AlteryxAbacusUtils::ReturnSuccess(nNumArgs, pArgs);
Expand Down
263 changes: 263 additions & 0 deletions MathUtils.Test/ChiDistTest.yxmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
<?xml version="1.0"?>
<AlteryxDocument yxmdVer="11.3">
<Nodes>
<Node ToolID="1">
<GuiSettings Plugin="AlteryxBasePluginsGui.Formula.Formula">
<Position x="150" y="54" />
</GuiSettings>
<Properties>
<Configuration>
<FormulaFields>
<FormulaField expression="CHIDIST(X, [NumOfDegree])" field="Actual" size="8" type="Double" />
</FormulaFields>
</Configuration>
<Annotation DisplayMode="0">
<Name />
<DefaultAnnotationText><![CDATA[Actual = CHIDIST(X, [NumOfDegree])
]]></DefaultAnnotationText>
<Left value="False" />
</Annotation>
</Properties>
<EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxFormula" />
</Node>
<Node ToolID="2">
<GuiSettings Plugin="AlteryxBasePluginsGui.TextInput.TextInput">
<Position x="54" y="54" />
</GuiSettings>
<Properties>
<Configuration>
<NumRows value="24" />
<Fields>
<Field name="X" />
<Field name="NumOfDegree" />
<Field name="Expected" />
</Fields>
<Data>
<r>
<c>50</c>
<c>60</c>
<c>0.817896084</c>
</r>
<r>
<c>52</c>
<c>60</c>
<c>0.759261834</c>
</r>
<r>
<c>54</c>
<c>60</c>
<c>0.693465455</c>
</r>
<r>
<c>56</c>
<c>60</c>
<c>0.622610306</c>
</r>
<r>
<c>58</c>
<c>60</c>
<c>0.549170885</c>
</r>
<r>
<c>60</c>
<c>60</c>
<c>0.475716986</c>
</r>
<r>
<c>62</c>
<c>60</c>
<c>0.404652179</c>
</r>
<r>
<c>64</c>
<c>60</c>
<c>0.338005865</c>
</r>
<r>
<c>66</c>
<c>60</c>
<c>0.277301371</c>
</r>
<r>
<c>68</c>
<c>60</c>
<c>0.223504873</c>
</r>
<r>
<c>70</c>
<c>60</c>
<c>0.177045452</c>
</r>
<r>
<c>72</c>
<c>60</c>
<c>0.137887601</c>
</r>
<r>
<c>18</c>
<c>25</c>
<c>0.842390716</c>
</r>
<r>
<c>19</c>
<c>25</c>
<c>0.797120545</c>
</r>
<r>
<c>20</c>
<c>25</c>
<c>0.746825306</c>
</r>
<r>
<c>21</c>
<c>25</c>
<c>0.692609666</c>
</r>
<r>
<c>22</c>
<c>25</c>
<c>0.635744028</c>
</r>
<r>
<c>23</c>
<c>25</c>
<c>0.577563369</c>
</r>
<r>
<c>24</c>
<c>25</c>
<c>0.519373571</c>
</r>
<r>
<c>25</c>
<c>25</c>
<c>0.462373663</c>
</r>
<r>
<c>26</c>
<c>25</c>
<c>0.407598691</c>
</r>
<r>
<c>27</c>
<c>25</c>
<c>0.35588453</c>
</r>
<r>
<c>28</c>
<c>25</c>
<c>0.307853266</c>
</r>
<r>
<c>29</c>
<c>25</c>
<c>0.263916007</c>
</r>
</Data>
</Configuration>
<Annotation DisplayMode="0">
<Name />
<DefaultAnnotationText />
<Left value="False" />
</Annotation>
</Properties>
<EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxTextInput" />
</Node>
<Node ToolID="3">
<GuiSettings Plugin="AlteryxBasePluginsGui.Filter.Filter">
<Position x="270" y="54" />
</GuiSettings>
<Properties>
<Configuration>
<Expression><![CDATA[Abs([Expected]-[Actual])>1e-3
]]></Expression>
<Mode>Custom</Mode>
</Configuration>
<Annotation DisplayMode="0">
<Name />
<AnnotationText>Verify versus Excel Ref Set</AnnotationText>
<DefaultAnnotationText><![CDATA[Abs([Expected]-[Actual])>1e-3
]]></DefaultAnnotationText>
<Left value="False" />
</Annotation>
</Properties>
<EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxFilter" />
</Node>
<Node ToolID="4">
<GuiSettings Plugin="AlteryxBasePluginsGui.Test.Test">
<Position x="414" y="54" />
</GuiSettings>
<Properties>
<Configuration>
<Tests>
<Test>
<Name>No Rows</Name>
<Connection>#1</Connection>
<Type>RecCountValue</Type>
<Value>0</Value>
</Test>
</Tests>
<DontReportSubsequent value="True" />
</Configuration>
<Annotation DisplayMode="0">
<Name />
<DefaultAnnotationText>No Rows</DefaultAnnotationText>
<Left value="False" />
</Annotation>
</Properties>
<EngineSettings EngineDll="AlteryxBasePluginsEngine.dll" EngineDllEntryPoint="AlteryxTest" />
</Node>
</Nodes>
<Connections>
<Connection>
<Origin ToolID="1" Connection="Output" />
<Destination ToolID="3" Connection="Input" />
</Connection>
<Connection>
<Origin ToolID="2" Connection="Output" />
<Destination ToolID="1" Connection="Input" />
</Connection>
<Connection name="#1">
<Origin ToolID="3" Connection="True" />
<Destination ToolID="4" Connection="Input" />
</Connection>
</Connections>
<Properties>
<Memory default="True" />
<GlobalRecordLimit value="0" />
<TempFiles default="True" />
<Annotation on="True" includeToolName="False" />
<ConvErrorLimit value="10" />
<ConvErrorLimit_Stop value="False" />
<CancelOnError value="False" />
<DisableBrowse value="False" />
<EnablePerformanceProfiling value="False" />
<DisableAllOutput value="False" />
<ShowAllMacroMessages value="False" />
<ShowConnectionStatusIsOn value="True" />
<ShowConnectionStatusOnlyWhenRunning value="True" />
<ZoomLevel value="0" />
<LayoutType>Horizontal</LayoutType>
<MetaInfo>
<NameIsFileName value="True" />
<Name>ChiDistTest</Name>
<Description />
<RootToolName />
<ToolVersion />
<ToolInDb value="False" />
<CategoryName />
<SearchTags />
<Author />
<Company />
<Copyright />
<DescriptionLink actual="" displayed="" />
<Example>
<Description />
<File />
</Example>
</MetaInfo>
<Events>
<Enabled value="True" />
</Events>
</Properties>
</AlteryxDocument>
Loading

0 comments on commit eaa3b53

Please sign in to comment.