Data referencing functionality within a testlist

Issue #402 resolved
Philip Au created an issue

Upon investigation of upgrading to 0.2.8 to, I have found the method that I use for referencing data no longer works.

Currently I have 1 test item that are coded as follows, where jig_std_6x and jig_std_10x are treated as “local” variables within the testlist.

Standard data test0 ===========================

get_std_6x = {

get_std_10x = {

std_data = 1

current_machine = META["unit_number"]

jig_std_6x = get_std_6x[current_machine]
jig_std_10x = get_std_10x[current_machine]


test1 ==========

test1 = jig_std_6x

test2 ==========

test 2 = jig_std_10x

In the new version, I cannot reference test1 and test2 whereas it works perfectly fine in 0.2.8.



Comments (5)

  1. Randle Taylor

    Hi Philip,

    I think this issue is a result of unintended behaviour in earlier versions, so this kind of thing worked by accident rather on purpose. Prior to the latest version, calculations would share the same context (variable values) between all the composite calculations so if you set a variable in one calculation, that same variable would be available in other calculations. I can’t remember the exact problem, but this caused issues when people used the same variable names in different calculations. The calculation context is now “cleaned up” between calculations and your jig_std_{6|10}x variables will be eliminated between calculations. Sorry, I didn’t realize there were people using this behaviour.

    Unfortunately I don’t think there’s a direct translation to 0.3.x from that, sorry, I know that might be frustrating. Likely the simplest thing is to remove the Standard data test0 and replace test1 with:

    get_std_6x = {
    test1 = get_std_6x[META["unit_number"]]

    and test2 with:

    get_std_10x = {
    test2 = get_std_10x[META["unit_number"]]

    would that work for you?

  2. Philip Au reporter

    Hi Randle,

    The way that's you've described is exactly what I've been doing, but this "accidental method works well since I can centralize all the standard data (Nd, jig standards, kq, tpr, etc) into one variable and access it accordingly. So if there was a change to be made, I can update a master list instead of having to hunt for it in individual tests. Do you have any suggestions on how I go about doing that? I was thinking possibly setup a dummy testlist with all these entries and then access it via sql code inside the py snippets.

    Thanks, Philip

  3. Randle Taylor

    Hi @Philip Au , My apolgies, I never saw your resonse to this issue. Bitbucket didn’t send me the notification email I think 😞

    If this is calibration factors / infrequently updated data then yes, I normally recommend setting up a test list to record calibration factors and then using composite tests to fetch the proper calibration factor. For example, for ion chamber calibration factors, I usually set up a unit for each Ion Chamber, and then assign a “Calibration Factor” test list to it. Then in other test lists, I add a multiple choice test list with a list of ion chambers to select from. Then you can use a composite test to fetch the latest calibration factor with a procedure like this:

    from import TestInstance
    latest = TestInstance.objects.filter(
    if latest:
        N_dw = latest.value
        N_dw = None

    Hope that makes sense.

  4. Philip Au reporter

    Hi Randle,

    No worries, I was so busy that I had no time to look into it as well.

    I saw on the google group that someone else had done something similar and am glad to see this is what you suggest as well. I will model it accordingly and revamp my tests.

    Thanks and have a nice weekend! Philip

  5. Log in to comment