Skip to content

Support Ubuntu 24.04#238

Open
kwabenantim wants to merge 32 commits intodevelopfrom
236-support-ubuntu-2404
Open

Support Ubuntu 24.04#238
kwabenantim wants to merge 32 commits intodevelopfrom
236-support-ubuntu-2404

Conversation

@kwabenantim
Copy link
Member

@kwabenantim kwabenantim commented Mar 23, 2026

Supports #236

Merging into develop branch for now. Failing tests were already failing and will be addressed by #239 and #240

Changes

  • Drop Python 2 support, add support for Python 3.10+
    • Move as much configuration as possible to pyproject.toml
    • Convert Python 2 code to Python 3 e.g. old-style print statements
    • Replace pkg_resources with importlib
    • Update deprecated pyparsing syntax
    • Bump up all dependencies to versions supported in Python 3.10+
  • Drop Sundials 2.x support, add support for 3.x to 7.x
    • Convert deprecated Cython IF directives to C preprocessor directives
    • Update Sundials wrappers with conditional compilation for different versions
  • Update GitHub Actions
  • Update README

Failing tests

  • test_clamping.test_interpolation_clamp
  • test_python_reproducibility

@kwabenantim
Copy link
Member Author

kwabenantim commented Mar 23, 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 when run with pytest 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

What is in lookup_data_table_1:

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

test_python_reproducibility

Failing for some test cases.

@kwabenantim kwabenantim linked an issue Mar 23, 2026 that may be closed by this pull request
9 tasks
Copy link
Contributor

@jonc125 jonc125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not reviewing properly but from a quick look through I didn't see anything that concerned me.

@kwabenantim kwabenantim requested a review from jonc125 March 24, 2026 06:17
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.

Support Ubuntu 24.04 LTS

2 participants