Skip to content

Commit

Permalink
Fix issue with mypy and use ubuntu-20.04 for testing
Browse files Browse the repository at this point in the history
Python 3.7 is not supported anymore in the latest
ubuntu used in the GitHub action; use ubuntu-20.04
instead.

The package is now tested on Python v3.12 and v3.13.
  • Loading branch information
damar-wicaksono committed Dec 9, 2024
1 parent 17eba54 commit a5ca0ce
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: tox -e typecheck
test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python:
Expand All @@ -54,6 +54,10 @@ jobs:
toxenv: "py39"
- version: "3.11"
toxenv: "py311"
- version: "3.12"
toxenv: "py312"
- version: "3.13"
toxenv: "py313"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
These are the lower bound, upper bound, and the mid-point (i.e., modal value),
respectively.
The density value at the modal value is computed such that the are under
The density value at the modal value is computed such that the area under
the distribution is 1.0.
"""

Expand Down Expand Up @@ -238,6 +238,6 @@ def icdf(
yy[idx_nan] = np.nan

# Check if values are within the set bounds
yy = postprocess_icdf(yy, lower_bound, upper_bound)
yy_post = postprocess_icdf(yy, lower_bound, upper_bound)

return yy
return yy_post
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ def icdf(
yy = lower_bound + np.diff(parameters) * xx

# Check if values are within the set bounds
yy = postprocess_icdf(yy, lower_bound, upper_bound)
yy_post = postprocess_icdf(yy, lower_bound, upper_bound)

return yy
return yy_post
16 changes: 11 additions & 5 deletions tests/core/prob_input/test_univariate_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ def univariate_input(
# to avoid awkward yet unrealistic values)
name = create_random_alphanumeric(8)
distribution = request.param
if request.param == "uniform":
if distribution == "uniform":
parameters = np.sort(np.round(np.random.rand(2), decimals=5))
elif request.param == "beta":
elif distribution == "beta":
parameters = np.sort(np.round(np.random.rand(4), decimals=5))
elif distribution == "exponential":
# Single parameter, must be strictly positive
parameters = 1 + np.round(np.random.rand(1), decimals=5)
parameters = (1 + np.round(np.random.rand(1), decimals=5)).astype(
np.float64
)
elif distribution == "triangular":
parameters = np.sort(1 + 2 * np.round(np.random.rand(2), decimals=5))
# Append the mid point
Expand All @@ -49,9 +51,13 @@ def univariate_input(
parameters = np.insert(parameters, 1, np.random.rand(1))
elif distribution == "lognormal":
# Limit the size of the parameters
parameters = 1 + np.round(np.random.rand(2), decimals=5)
parameters = (1 + np.round(np.random.rand(2), decimals=5)).astype(
np.float64
)
else:
parameters = 5 * np.round(np.random.rand(2), decimals=5)
parameters = (5 * np.round(np.random.rand(2), decimals=5)).astype(
np.float64
)
parameters[1] += 1.0

specs = {
Expand Down

0 comments on commit a5ca0ce

Please sign in to comment.