-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CI: Test integration_tests with Python 3.9, 3.10 and 3.11 #2298
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3521244
CI: Run integration_tests with diff Python versions
Shaikh-Ubaid a531c93
TEST: Split test_statistics into two parts
Shaikh-Ubaid 4b9e63b
Include Python Libs for CPython as well
Shaikh-Ubaid f028e57
CMake: Support REQ_PY_VER flag
Shaikh-Ubaid 0081946
CI: Also test cpython_interop with diff CPython versions
Shaikh-Ubaid c5ef1af
TEST: Specify REQ_PY_VER for unsupporting tests
Shaikh-Ubaid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -312,7 +312,7 @@ endmacro(RUN_UTIL) | |
|
||
macro(RUN) | ||
set(options FAIL NOFAST NOMOD ENABLE_CPYTHON LINK_NUMPY) | ||
set(oneValueArgs NAME IMPORT_PATH COPY_TO_BIN) | ||
set(oneValueArgs NAME IMPORT_PATH COPY_TO_BIN REQ_PY_VER) | ||
set(multiValueArgs LABELS EXTRAFILES) | ||
cmake_parse_arguments(RUN "${options}" "${oneValueArgs}" | ||
"${multiValueArgs}" ${ARGN} ) | ||
|
@@ -334,6 +334,18 @@ macro(RUN) | |
set(RUN_EXTRA_ARGS ${RUN_EXTRA_ARGS} -I${CMAKE_CURRENT_SOURCE_DIR}/${RUN_IMPORT_PATH}) | ||
endif() | ||
|
||
if (RUN_REQ_PY_VER) | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1" PY_MAJOR_VERSION "${Python_VERSION}") | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\2" PY_MINOR_VERSION "${Python_VERSION}") | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1" REQ_PY_MAJOR_VERSION "${RUN_REQ_PY_VER}") | ||
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\2" REQ_PY_MINOR_VERSION "${RUN_REQ_PY_VER}") | ||
|
||
if (PY_MINOR_VERSION LESS REQ_PY_MINOR_VERSION) | ||
# remove backends from the test that depend on CPython | ||
list(REMOVE_ITEM RUN_LABELS cpython cpython_sym c_py c_sym llvm_sym llvm_py) | ||
endif() | ||
endif() | ||
|
||
if (NOT FAST) | ||
RUN_UTIL(RUN_FAIL RUN_NAME RUN_FILE_NAME RUN_LABELS RUN_EXTRAFILES RUN_NOMOD RUN_EXTRA_ARGS RUN_COPY_TO_BIN) | ||
endif() | ||
|
@@ -623,7 +635,7 @@ RUN(NAME bindpy_01 LABELS cpython c_py ENABLE_CPYTHON NOFAST COPY_TO_B | |
RUN(NAME bindpy_02 LABELS cpython c_py LINK_NUMPY COPY_TO_BIN bindpy_02_module.py) | ||
RUN(NAME bindpy_03 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_03_module.py) | ||
RUN(NAME bindpy_04 LABELS cpython c_py LINK_NUMPY NOFAST COPY_TO_BIN bindpy_04_module.py) | ||
RUN(NAME bindpy_05 LABELS llvm_py c_py ENABLE_CPYTHON COPY_TO_BIN bindpy_05_module.py) | ||
RUN(NAME bindpy_05 LABELS llvm_py c_py ENABLE_CPYTHON COPY_TO_BIN bindpy_05_module.py REQ_PY_VER 3.10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test seems to fail with |
||
RUN(NAME test_generics_01 LABELS cpython llvm c NOFAST) | ||
RUN(NAME test_cmath LABELS cpython llvm c NOFAST) | ||
RUN(NAME test_complex_01 LABELS cpython llvm c wasm wasm_x64) | ||
|
@@ -741,7 +753,8 @@ RUN(NAME generics_array_01 LABELS cpython llvm c) | |
RUN(NAME generics_array_02 LABELS cpython llvm c) | ||
RUN(NAME generics_array_03 LABELS cpython llvm c) | ||
RUN(NAME generics_list_01 LABELS cpython llvm c) | ||
RUN(NAME test_statistics LABELS cpython llvm NOFAST) | ||
RUN(NAME test_statistics_01 LABELS cpython llvm NOFAST) | ||
RUN(NAME test_statistics_02 LABELS cpython llvm NOFAST REQ_PY_VER 3.10) | ||
RUN(NAME test_str_attributes LABELS cpython llvm c) | ||
RUN(NAME kwargs_01 LABELS cpython llvm c NOFAST) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from statistics import (covariance, correlation, | ||
linear_regression) | ||
from lpython import i32, f64 | ||
|
||
|
||
eps: f64 | ||
eps = 1e-12 | ||
|
||
def test_covariance(): | ||
a: list[i32] | ||
a = [1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
b: list[i32] | ||
b = [1, 2, 3, 1, 2, 3, 1, 2, 3] | ||
j: f64 | ||
j = covariance(a, b) | ||
assert abs(j - 0.75) < eps | ||
|
||
c: list[f64] | ||
c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98] | ||
d: list[f64] | ||
d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98] | ||
k: f64 | ||
k = covariance(c, d) | ||
assert abs(k + 0.24955999999999934) < eps | ||
|
||
|
||
def test_correlation(): | ||
a: list[i32] | ||
a = [11, 2, 7, 4, 15, 6, 10, 8, 9, 1, 11, 5, 13, 6, 15] | ||
b: list[i32] | ||
b = [2, 5, 17, 6, 10, 8, 13, 4, 6, 9, 11, 2, 5, 4, 7] | ||
|
||
j: f64 | ||
j = correlation(a, b) | ||
assert abs(j - 0.11521487988958108) < eps | ||
|
||
c: list[f64] | ||
c = [2.0, 23.0, 24.55, 64.436, 5403.23] | ||
d: list[f64] | ||
d = [26.9, 75.6, 34.06, 356.89, 759.26] | ||
|
||
j = correlation(c, c) | ||
assert abs(j - 1.0) < eps | ||
|
||
j = correlation(c, d) | ||
assert abs(j - 0.9057925526720572) < eps | ||
|
||
def test_linear_regression(): | ||
c: list[f64] | ||
c = [2.74, 1.23, 2.63, 2.22, 3.0, 1.98] | ||
d: list[f64] | ||
d = [9.4, 1.23, 2.63, 22.4, 1.9, 13.98] | ||
|
||
slope: f64 | ||
intercept: f64 | ||
slope, intercept = linear_regression(c, d) | ||
|
||
assert abs(slope + 0.6098133124816717) < eps | ||
assert abs(intercept - 9.992570618707845) < eps | ||
|
||
a: list[i32] | ||
b: list[i32] | ||
a = [12, 24, 2, 1, 43, 53, 23] | ||
b = [2, 13, 14, 63, 49, 7, 3] | ||
|
||
slope, intercept = linear_regression(a, b) | ||
|
||
assert abs(slope + 0.18514007308160782) < eps | ||
assert abs(intercept - 25.750304506699152) < eps | ||
|
||
|
||
def check(): | ||
test_linear_regression() | ||
test_correlation() | ||
test_covariance() | ||
|
||
check() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This compares only the Python minor versions for now. We might need to consider Python major versions when Python
4.0.0
is released, but I guess there might probably be some time for it.