cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Capstone 2.3

anduhau
New Contributor II

Hello! I have checked previous posts on this question, but still have not managed to figure out the issue, as I get the mismatched type error on the function and 3/4 tests failed. My guess is that the error is due to the wrong datatype for the 3rd sensor parameter, but I worked both with symbol and string and got the same error (a screenshot of the code and error is attached - the whole code can be seen inside the spoiler tag).

Spoiler
.f1.checkSensor{[raceTab; lapTab; mySensor]
    sensorFilter:`temp`tyre`wind`all!("temp*";"tyre*";"wind*";"*e*");
    // Get avg benchmark values from historical lap data
    benchmark: ?[lapTab;
                enlist(in;`sensorId;(sensorFilter;enlist mysensor));
                (enlist `sensorId)!enlist `sensorId;
                (enlist `benchmarkValue)!enlist (avg;`sensorValue)];
    chk: ?[raceTab;
            (enlist(in;`sensorId;(sensorFilter;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
    }

 

1 ACCEPTED SOLUTION

Laura
Community Manager Community Manager
Community Manager

Hi @anduhau , 

Are you running this within the markdown file itself?

I would suggest copying your code into the scratchpad as you're able to run the code line-by-line and see more clearly what is going wrong. 

When you click the "play" button under the code blocks in the markdown file, it is running the entire code block, so you are not able to pinpoint which line is breaking. 

Let me know how you get on.

Laura

View solution in original post

7 REPLIES 7

Laura
Community Manager Community Manager
Community Manager

Hi @anduhau ,

Not sure if it's a typo or not, but the first thing I noticed was your parameters don't match what is in the function - mySensor vs mysensor.

The next thing I could see was your where clause within your functional statement for benchmark isn't correct. One way to help you create functional statements is to use parse e.g. 

parse "select from table where sym=`ABC"

This will give you the correct structure and you can swap out the values for what you need. 

Also ensure you're using the correct condition, you have used "in" where "like" may be more appropriate. 

(The change you make for benchmark will also need to be corrected for chk)

Hope this helps!

Laura 

anduhau
New Contributor II

Dear Laura, 

Thank you for your suggestion! I parsed the command as well for the benchmark whereclause statement and retrieved the output on the terminal (screenshot attached). However, I do not understand where I got it wrong - the parse output and the code seem to match (apart from the added enlist keywords at least).

anduhau
New Contributor II

Note: I also added 

sensorFilter[mySensor] 

this line as a replacement for my 3rd argument in the where-clause, but with the same result. 

Laura
Community Manager Community Manager
Community Manager

Hi @anduhau ,

You will need to change it for both benchmark and chk.

If your function statement is still failing, I would advise stepping through the code and ensuring each part of your functional statement is working. You can do this by "nulling" the other parts e.g. to test the where clause:

benchmark: ?[lapTab;enlist(like;`sensorId;sensorFilter[mysensor]);0b;()];

Then replace the whereclause with () and populate the columns with your code to test that part, and so on. 

Hope this helps.

Laura

anduhau
New Contributor II

Dear Laura,

I deleted all the clauses to simply retrieve the table, as follows:

benchmark: ?[lapTab;();0b;()];

chk: ?[raceTab;();0b;()];

However, even so, I get the mismatched types error - I truly do not know what to do on this, as I have spent the whole weekend working on this issue (screenshot attached). 

Laura
Community Manager Community Manager
Community Manager

Hi @anduhau , 

Are you running this within the markdown file itself?

I would suggest copying your code into the scratchpad as you're able to run the code line-by-line and see more clearly what is going wrong. 

When you click the "play" button under the code blocks in the markdown file, it is running the entire code block, so you are not able to pinpoint which line is breaking. 

Let me know how you get on.

Laura

anduhau
New Contributor II

Thank you for your help!! I have figured it out and the tests for 2.3 and 2.4 work