Skip to content

Commit

Permalink
Update supported Python versions in CI (#228)
Browse files Browse the repository at this point in the history
* add missing CHANGELOG.rst

* fix missing 3.9

* now windows wheels for 3.9

* make nosetests and coverage work correctly

* update release notes

Co-authored-by: Moritz E. Beber <[email protected]>
  • Loading branch information
cdiener and Midnighter authored Mar 16, 2021
1 parent a7c02b2 commit e7728cd
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 63 deletions.
34 changes: 0 additions & 34 deletions .coveragerc

This file was deleted.

16 changes: 5 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
exclude:
# Lacking swiglpk wheels for this combination.
- os: macos-latest
python-version: '3.5'
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -35,14 +31,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install tox tox-gh-actions codecov
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox -- --cov-report=xml
run: tox -- --cover-xml
- name: Report coverage
run: codecov
# uses: codecov/codecov-action@v1
# with:
# fail_ci_if_error: true
shell: bash
run: bash <(curl -s https://codecov.io/bash)

release:
needs: test
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======

Next Release
------------
* removed support for Python 3.5
* added support for Python 3.9
* enabled code coverage in tox
* support symengine 0.7.0

1.4.7
-----
* fix: except AttributeError when setting tolerance on cloned Configuration
* enable cloning models between solver interfaces that do not support the same set of tolerance parameters
2 changes: 2 additions & 0 deletions src/optlang/expression_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _parse_linear_expression(expression, expanded=False, **kwargs):
"""
offset = 0
constant = None
expression = expression.expand()

if expression.is_Add:
coefficients = expression.as_coefficients_dict()
Expand Down Expand Up @@ -108,6 +109,7 @@ def _parse_quadratic_expression(expression, expanded=False):
linear_coefficients = {}
quadratic_coefficients = {}
offset = 0
expression = expression.expand()

if expression.is_Number: # Constant expression, no coefficients
return float(expression), linear_coefficients, quadratic_coefficients
Expand Down
8 changes: 5 additions & 3 deletions src/optlang/tests/abstract_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,15 +604,15 @@ def test_change_constraint_bounds(self):

def test_initial_objective(self):
self.assertEqual(self.model.objective.expression, 1.0 * self.model.variables["R_Biomass_Ecoli_core_w_GAM"])

def test_set_objective_in_constructor(self):
var = self.interface.Variable("x", ub=5)
obj = self.interface.Objective(var, direction="max")
model = self.interface.Model(objective=obj, variables=[var])
model.optimize()
self.assertIs(model.objective, obj)
self.assertAlmostEqual(model.objective.value, 5)


def test_optimize(self):
self.model.optimize()
Expand Down Expand Up @@ -752,6 +752,8 @@ def test_clone_model_without_json(self):
self.assertEquals(len(cloned_model.variables), len(self.model.variables))
self.assertEquals(len(cloned_model.constraints), len(self.model.constraints))
cloned_model.optimize()
print(cloned_model.objective.expression)
print(cloned_model.objective.value)
self.assertAlmostEqual(cloned_model.objective.value, opt)

def test_remove_variable_not_in_model_raises(self):
Expand Down Expand Up @@ -961,7 +963,7 @@ def test_implicitly_convert_milp_to_lp(self):
model.remove(var3)
model.optimize()
self.assertAlmostEqual(model.reduced_costs["x"], 0)

def test_change_constraint_name(self):
model = self.model
const = model.constraints[0]
Expand Down
34 changes: 19 additions & 15 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[tox]
envlist = isort, black, flake8, safety, docs, py27, py3{5,6,7,8}-symengine
envlist = isort, black, flake8, safety, docs, py27, py3{6,7,8,9}-symengine

[gh-actions]
python =
2.7: safety, py27
3.5: safety, py35, py35-symengine
3.6: safety, py36, py36-symengine
3.7: safety, py37, py37-symengine
3.8: safety, py38, py38-symengine
3.9: safety, py39, py39-symengine

;[testenv]
;deps =
Expand All @@ -30,7 +30,7 @@ deps =
symengine: symengine
passenv = CI
commands =
nosetests src/optlang/tests -vv
nosetests -c tox.ini src/optlang/tests {posargs}

[testenv:isort]
skip_install = True
Expand Down Expand Up @@ -93,25 +93,29 @@ markers =
; src/optlang
; */site-packages/optlang

;[coverage:run]
;branch = true
;parallel = true
;omit =
; src/optlang/_version.py
[coverage:run]
branch = true
parallel = true
omit =
src/optlang/_version.py
src/optlang/tests/*

;[coverage:report]
;exclude_lines =
;# Have to re-enable the standard pragma
; pragma: no cover
;precision = 2
;omit =
; src/optlang/_version.py
[coverage:report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
precision = 2
omit =
src/optlang/_version.py
src/optlang/tests/*

[flake8]
max-line-length = 130
exclude =
__init__.py
_version.py
gurobi_interface.py
cplex_interface.py
src/optlang/tests/*
# The following conflict with `black` which is the more pedantic.
ignore =
Expand Down

0 comments on commit e7728cd

Please sign in to comment.