Advanced Capstone 2.3 and 2.4

My test results are failing for tests 2.3.2 - 2.4 and I don’t know why. My code seems to be correct. For 2.3.2 - 2.3.4, it gives me a type error and it does not specify any error for 2.4. Following are the error messages:

quizItem success description error

exercise2.1 Pass “check if race day in process” “”
exercise2.1 Pass “have correct schema” “”
exercise2.2 Pass “check if lap table in process” “”
exercise2.2 Pass “only contains data for 2nd Jan 2020” “”
exercise2.2 Pass “contain all columns for 2nd Jan 2020” “”
exercise2.3 Pass “not allowed to use select keyword” “”
exercise2.3 Fail “return correct values for temp” “type”
exercise2.3 Fail “return correct values for wind” “type”
exercise2.3 Fail “return correct values for all” “type”
exercise2.4 Fail “when given the wrong option return error "<mysensor> is not a valid option for mysensor - valid options include temptyrewindall"” “”
exercise2.5 Pass “func should return same result as before” “”
exercise2.5 Fail “.viz.createDashboard should run in half the time” “”

 

Here is my function .f1.checkSensor for reference:

{[raceTab;lapTable;mysensor]
dict:temptyrewindall!(“temp*”;“tyre*”;“wind*”;“e”);
if[0b=mysensor in dict;.Q.trp[{ $(mysensor)," is not a valid option for mysensor - valid options include temptyrewindall" }]];
benchmark:?[lapTable;enlist(like;sensorId;dict[mysensor]);enlist[sensorId]!enlist(sensorId);enlist[benchmarkValue]!enlist(avg;sensorValue)]; <br>chk:?[raceTab;<br>enlist(like;sensorId;dict[mysensor]);
enlist[sensorId]!enlist(sensorId);
enlist[avgValue]!enlist(avg;sensorValue),enlist[stdDevValue]!enlist(avg;sensorValue)];
chk:update diffValue:“F”$.Q.f’[5;abs[benchmarkValue-avgValue]]
from benchmark lj chk;
chk:update diffFlag:?[(diffValue>1);0b;1b],
stdFlag:?[(stdDevValue>1.5);0b;1b]
from chk;
chk
}

Please correct my code and advise me why I might be getting errors

Hi  ,

Have you tried stepping through your code line by line?

The reason 2.4 is passing but 2.3.2 - 2.3.4 are failing is because the wrong input exits the function on line 3 but the correct inputs continue through and then throw a type error on line 5. 

You’ll need to look each part of your functional select to ensure there are no mismatch errors. 

I have corrected the line below if you need some help: 

chk:?[raceTab;enlist(like;sensorId;dict[mysensor]);enlist[sensorId]!enlist(sensorId);(enlist[avgValue]!enlist(avg;sensorValue)),enlist[stdDevValue]!enlist(avg;`sensorValue)];

Hope this helps,

Laura

 

When I run test function, all 4 tests for the function pass but when I run testsection[`exercise2], all tests from 2.3.2 and 2.4 are still failing.

Hi  ,

Can you clarify what you mean when you say “run test function” vs the testsection?  Are your tests failing with the same `type error or a different error now?

Have you redefined the .f1.checksensor function with the corrected syntax?

If you are still having issues and not sure why, feel free to send me your code via DM or email lkerr@kx.com and I will try to find out what’s going wrong.

Thanks,

Laura

I have redefined the function with the correct syntax. By “run test function” I mean right clicking on the function in workspace and selecting run tests. by testsection I mean executing the testsection[`exercise2] query on scratchpad. Hence, the tests are passing when testing the function, but are failing when testing the section. 

The failed tests do not specify any errors now:

quizItem success description error

exercise2.1 Pass “check if race day in process” “”
exercise2.1 Pass “have correct schema” “”
exercise2.2 Pass “check if lap table in process” “”
exercise2.2 Pass “only contains data for 2nd Jan 2020” “”
exercise2.2 Pass “contain all columns for 2nd Jan 2020” “”
exercise2.3 Pass “not allowed to use select keyword” “”
exercise2.3 Fail “return correct values for temp” “”
exercise2.3 Fail “return correct values for wind” “”
exercise2.3 Fail “return correct values for all” “”
exercise2.4 Fail “when given the wrong option return error "<mysensor> is not a valid option for mysensor - valid options include temptyrewindall"” “”
exercise2.5 Pass “func should return same result as before” “”
exercise2.5 Fail “.viz.createDashboard should run in half the time” “”

 

Hi  , 

Thanks for sending over the screenshots.

It looks like your function is defined in the workspace correctly, but potentially a different version of it is defined in memory in your scratchpad.

You can check this by running “.f1.checkSensor” in your scratch pad.

If the incorrect version is in memory, you can fix this by opening up the function and making a small edit and saving it, or redefine the function in your scratchpad to the correct version.

Let me know if that helps! 

Thanks,

Laura

I double checked that the correct version is in memory and it is still not working. Also, I am now suddenly getting a fail message for 2.2.3 as well without any error message.

Hi  ,

If you can send me your markdown I will test the full code and see what is happening.

Thanks,

Laura

Thanks for sending your code via DM.

Hope the changes I suggested have resolved the failing tests now.

Thanks,

Laura