Skip to content

236 support ubuntu 2404#237

Closed
kwabenantim wants to merge 28 commits intomasterfrom
236-support-ubuntu-2404
Closed

236 support ubuntu 2404#237
kwabenantim wants to merge 28 commits intomasterfrom
236-support-ubuntu-2404

Conversation

@kwabenantim
Copy link
Member

@kwabenantim kwabenantim commented Mar 18, 2026

Moved to #238

@kwabenantim kwabenantim self-assigned this Mar 18, 2026
@kwabenantim
Copy link
Member Author

kwabenantim commented Mar 20, 2026

test_clamping.test_interpolation_clamp

Failing test_clamping.test_interpolation_clamp at the assertions in lookup_data_table_1 in the generated model:

This test fails both with Python 3.6 on the master branch and with Python 3.10 on this branch.

On the master branch, it seems to pass only because it is ignoring assertion errors:

Initialising test_model_interpolation.txt
  Initialising BasicLibrary.txt
running protocol test_model_interpolation.txt ...
running simulation sim
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_2'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_2'
AssertionError
AssertionError
Exception ignored in: 'model.lookup_data_table_1'
AssertionError
cdef np.ndarray _data_table_1 = np.array([0, 3000, 9000, 6000, 6900, 6000])

cdef double lookup_data_table_1(var_protocol__derived2_converted):
    """Look up data from interpolation_test_derived.csv."""
    assert var_protocol__derived2_converted >= 0
    assert var_protocol__derived2_converted <= 0.014999999999999999
    cdef double offset_over_step = (var_protocol__derived2_converted - 0) * 333.33333333333331
    cdef unsigned index = <unsigned>(offset_over_step)
    cdef double y1 = _data_table_1[index]
    cdef double y2 = _data_table_1[index + 1]
    return y1 + (offset_over_step - index) * (y2 - y1)

lookup_data_table_2 is similar (but doesn't fail):

cdef np.ndarray _data_table_2 = np.array([0, 3000, 9000, 6000, 6900, 6000])

cdef double lookup_data_table_2(var_protocol__table_key_converted):
    """Look up data from interpolation_test_derived.csv."""
    assert var_protocol__table_key_converted >= 0
    assert var_protocol__table_key_converted <= 0.014999999999999999
    cdef double offset_over_step = (var_protocol__table_key_converted - 0) * 333.33333333333331
    cdef unsigned index = <unsigned>(offset_over_step)
    cdef double y1 = _data_table_2[index]
    cdef double y2 = _data_table_2[index + 1]
    return y1 + (offset_over_step - index) * (y2 - y1)

Calculation of var_protocol__derived2_converted:

var_V = ((1.0 * var_time) if (0.001 * var_time <= 0.003 and 0.001 * var_time >= 0) else ((-3.0 + 2.0 * var_time) if (0.001 * var_time >= 0.003 and 0.001 * var_time <= 0.006) else ((21.000000000000004 - 2.0000000000000004 * var_time) if (0.001 * var_time >= 0.006 and 0.001 * var_time <= 0.0075) else ((6.0) if (0.001 * var_time >= 0.0075 and 0.001 * var_time <= 0.009) else ((3.300000000000001 + 0.29999999999999993 * var_time) if (0.001 * var_time >= 0.009 and 0.001 * var_time <= 0.012) else ((-1.3877787807814457e-17 + 1.0 * var_time) if (0.001 * var_time >= 0.012 and 0.001 * var_time <= 0.014) else (float('nan'))))))))

var_protocol__table_key = 5.0 + var_V

var_protocol__table_key_converted = 0.001 * var_protocol__table_key

var_protocol__interp = 0.001 * lookup_data_table_2(var_protocol__table_key_converted)

var_protocol__derived2 = ((-1.0) if (var_protocol__table_key > 14.0) else (((var_protocol__interp) if (var_protocol__table_key < 11.0) else (-2.0))))

var_protocol__derived2_converted = 0.001 * var_protocol__derived2

Some examples:

var_V 0.0
var_protocol__table_key 5.0
var_protocol__table_key_converted 0.005
var_protocol__interp 6.999999999999999
var_protocol__derived2 6.999999999999999
var_protocol__derived2_converted 0.006999999999999999

var_V 1.0
var_protocol__table_key 6.0
var_protocol__table_key_converted 0.006
var_protocol__interp 9.0
var_protocol__derived2 9.0
var_protocol__derived2_converted 0.009000000000000001

var_V 2.0
var_protocol__table_key 7.0
var_protocol__table_key_converted 0.007
var_protocol__interp 8.000000000000002
var_protocol__derived2 8.000000000000002
var_protocol__derived2_converted 0.008000000000000002

var_V 3.0
var_protocol__table_key 8.0
var_protocol__table_key_converted 0.008
var_protocol__interp 7.0
var_protocol__derived2 7.0
var_protocol__derived2_converted 0.007

var_V 5.0
var_protocol__table_key 10.0
var_protocol__table_key_converted 0.01
var_protocol__interp 6.3
var_protocol__derived2 6.3
var_protocol__derived2_converted 0.0063

Values produced for var_protocol__derived2_converted:

 0.006999999999999999
 0.009000000000000001
 0.008000000000000002
 0.007
 0.0063
 -0.002  # <--- Error!

If var_protocol__derived2_converted == -0.002,

  • this means var_protocol__derived2 == -2,
  • which makes it likely that 11 <= var_protocol__table_key <= 14
  • which means 6 <= var_V <= 9
  • which means 7.5 <= var_time <= 9.0

So this is probably failing when var_V is set to 6 from time 7.5 to 9.0

It is possible that the interpolation calculations are not correct.

offset_over_step = (var_protocol__derived2_converted - 0) * 333.33333333333331
index = <unsigned>(offset_over_step)
y1 = _data_table_1[index]
y2 = _data_table_1[index + 1]
return y1 + (offset_over_step - index) * (y2 - y1)

so

offset_over_step = -0.6666666666666666
index == 0
y1 == 0
y2 == 3000
y1 + (offset_over_step - index) * (y2 - y1) == -2000.0

This is not correct

var_time

@kwabenantim
Copy link
Member Author

kwabenantim commented Mar 23, 2026

test_python_reproducibility

Failing for some test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant