cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced capstone project exercise 2.4 and 2.5

monikagel
New Contributor II

Hi there,
I was wondering if I could receive some help regarding my code for the advanced capstone project.

I am running into issues when trying to implement the error trapping part for the function .f1.checkSensor. I added the code for my version of the function below. In here, mysensordic is a global dictionary I wrote outside the function. While I know this is not the expected practice, it does work and I don't have any issues when I pass the expected parameters for mysensor variable. I pass all the tests except the ones for error trapping. It also does not work in the code, as it just returns an empty table, so my function does not break when it is supposed to. Could someone please help me figure out where I am going wrong?

Spoiler
{[raceTab;lapTab;mysensor]

    if[0b=mysensor in key mysensordic;.Q.trp[{`$(mysensor)," is not a valid option for mysensor - valid options include `temp`tyre`wind`all" }]];
        
    // Get avg benchmark values from historical lap data
    benchmark: ?[lapTab;
                enlist(in;`sensorId;(mysensordic;enlist mysensor));
                (enlist `sensorId)!enlist `sensorId;
                (enlist `benchmarkValue)!enlist (avg;`sensorValue)];

    chk: ?[raceTab;
            (enlist(in;`sensorId;(mysensordic;enlist mysensor)));
            (enlist `sensorId)! enlist `sensorId;
            `avgValue`stdDevValue!((avg;`sensorValue);(dev;`sensorValue))];
    
    // Join historical benchmarks to new data and calculate diff 
    chk:update diffValue:"F"$.Q.f'[5;abs[benchmarkValue-avgValue]] 
        from benchmark lj chk;
    // Add flags if difference between old vs new data >1 and if standard deviation>1.5
    chk:update diffFlag:?[(diffValue>1);0b;1b],
               stdFlag:?[(stdDevValue>1.5);0b;1b]
        from chk;
    chk
    }

 

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 Fail    "func should return same result as before"                                                                                               ""   
exercise2.5 Pass    ".viz.createDashboard should run in half the time"                                                                                       ""   

 

1 ACCEPTED SOLUTION

megan_mcp
Community Manager Community Manager
Community Manager

Hi @monikagel !

From what I can see the problem is in line 3. If you replace:

.Q.trp[{`$(mysensor),

With: 

'string[mysensor],

Your function should work fine.

If you have any other issues please feel free to let me know,

Megan 🙂

View solution in original post

5 REPLIES 5

megan_mcp
Community Manager Community Manager
Community Manager

Hi @monikagel !

From what I can see the problem is in line 3. If you replace:

.Q.trp[{`$(mysensor),

With: 

'string[mysensor],

Your function should work fine.

If you have any other issues please feel free to let me know,

Megan 🙂

monikagel
New Contributor II

Hi Megan,

This did work indeed! Thank you very much for your help.

monikagel
New Contributor II

Hi @megan_mcp ! 

I have now completed and submitted my project, however, I am still not getting a certificate and it has been a few hours. I have done both the submission and the feedback form, and made sure I submit both using the same email! Could you have a look why I am not receiving my certificate please? 

megan_mcp
Community Manager Community Manager
Community Manager

Hi @monikagel,

Congratulations on completing the capstone!

I've edited this so you should have received your certificate.

Thanks,

Megan 🙂

monikagel
New Contributor II

I received it now, thank you!