KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums KX Academy Advanced capstone project exercise 2.4

  • Advanced capstone project exercise 2.4

    Posted by holly on March 18, 2025 at 7:32 am

    Hi there,

    Im currently working on ex 2.4 for Advanced Capstone, however i was failed to get this exercise to pass

    I got every exercised passed instead of this one 

    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 Pass “return correct values for temp” “”
    exercise2.3 Pass “return correct values for wind” “”
    exercise2.3 Pass “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 `temp`tyre`wind`all\”” “”
    exercise2.5 Pass “func should return same result as before” “”
    exercise2.5 Pass “`p attribute exists” “” </p><p><br></p><p>I couldnt find where is error causing, as i saw the result of error message is returning as expected. Please see the screenshot below for the .f1.checkSensor</p><p><br></p><p>my code for error trapping <br>if[0b=mysensor in key this_dict; .Q.trp[‘string[mySensor],” is not a valid option for mysensor – valid options include `temp`tyre`wind`all”]]; </p><p><br></p><p>To run:</p><p>.f1.checkSensor[raceDay;lapTable;`temperature] // should error

    Result return:

    “temperature is not a valid option for mysensor – valid options include `temp`tyre`wind`all”

    holly replied 1 week, 5 days ago 2 Members · 4 Replies
  • 4 Replies
  • mwoods

    Administrator
    March 18, 2025 at 10:12 am

    Can you paste your code for this question here please? Looks good at a glance so could be something small that needs tweaking

    • holly

      Member
      March 18, 2025 at 12:06 pm

      {[raceTab;lapTab;mySensor]

      // Get avg benchmark values from historical lap data // THESE

      this_dict: `temp`tyre`wind`all!(“temp*”;”tyre*”;”wind*”;”[a-z]*”);

      if [0b=mySensor in key this_dict;.Q.trp[‘string [mySensor], ” is not a valid option for mysensor – valid options include `temp `tyre `wind `all”]];

      if[not mySensor in key[this_dict];’string[mySensor],” is not a valid option for mysensor – valid options include `temp`tyre`wind`all”];

      benchmark:?[lapTab;();(enlist `sensorId)!enlist `sensorId;(enlist `benchmarkValue)!enlist (avg;`sensorValue)] ;

      chk:?[raceTab;();(enlist `sensorId)!enlist `sensorId;`avgValue`stdDevValue!((avg;`sensorValue);(dev;`sensorValue))] ;

      chk:![lj[benchmark;chk];();0b;(enlist `diffValue)!enlist ($;”F”;(.Q.f’;5;(abs;(-;`benchmarkValue;`avgValue))))] ;</p><p>chk:![chk;();0b;`diffFlag`stdFlag!((?;(>;`diffValue;1);0b;1b);(?;(>;`stdDevValue;1.5);0b;1b))];</p><p>chk:?[chk;enlist(like;`sensorId;this_dict[mySensor]);0b;()];

      chk

      }

  • mwoods

    Administrator
    March 18, 2025 at 12:29 pm

    Replied in DM

  • holly

    Member
    March 19, 2025 at 6:44 am

    it works now, thank you very much 

Log in to reply.