Skip to content

Commit 435b911

Browse files
committed
Merge branch 'master' of github.com:bjodah/chempy
2 parents 689a843 + c3c528a commit 435b911

25 files changed

+371
-345
lines changed

.ci/_source_common_env.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export CACHE_ROOT=$(pwd)/cache-ci
2+
export PYTHONUSERBASE=$CACHE_ROOT/pyusrb
3+
export CPATH=$SUNDIALS_ROOT/include:/usr/include/suitesparse:${CPATH:-} # sunlinsol_klu.h includes "klu.h"
4+
export CPLUS_INCLUDE_PATH=${Boost_ROOT}/include
5+
export LIBRARY_PATH=$SUNDIALS_ROOT/lib
6+
export LD_LIBRARY_PATH=$SUNDIALS_ROOT/lib
7+
8+
source $(compgen -G "/opt-3/cpython-v3.*-apt-deb/bin/activate")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
. .ci/_source_common_env.sh
4+
if [ ! -d $PYTHONUSERBASE ]; then mkdir -p $PYTHONUSERBASE; fi
5+
6+
python -m pip install --cache-dir $CACHE_ROOT/pip_cache --upgrade-strategy=eager --upgrade cython
7+
python -m pip install --cache-dir $CACHE_ROOT/pip_cache -e .[all]
8+
python -c "import pycvodes; import pyodesys; import pygslodeiv2" # debug this CI config
9+
git fetch -tq
10+
#python setup.py sdist # test pip installable sdist (checks MANIFEST.in)
11+
python -m build --sdist # test pip installable sdist (checks MANIFEST.in)
12+
git archive -o dist/chempy-head.zip HEAD # test pip installable zip (symlinks break)

.ci/run-02-test-suite.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
. .ci/_source_common_env.sh
4+
5+
bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'
6+
./scripts/run_tests.sh --cov chempy --cov-report html
7+
./scripts/coverage_badge.py htmlcov/ htmlcov/coverage.svg
8+
cp -r htmlcov/ dist/*.* deploy/public_html/branches/${CI_COMMIT_BRANCH}/
9+
./.ci/grep-for-merge-blocking-token.sh
10+
export CHEMPY_DEPRECATION_FILTER=ignore
11+
python3 -m virtualenv /tmp/test_sdist
12+
python3 -m virtualenv /tmp/test_git_archive
13+
cd deploy/public_html/branches/${CI_COMMIT_BRANCH}
14+
unset CHEMPY_SKIP_NO_TESTS # I can't get pip to install extras when using local file...
15+
bash -c "\
16+
source /tmp/test_sdist/bin/activate \
17+
; pip install \
18+
--cache-dir $CACHE_ROOT/pip_cache \
19+
file://$(realpath $(eval ls chempy-*.tar.gz))#chempy[all] pytest \
20+
; pytest --pyargs chempy"
21+
22+
bash -c "\
23+
source /tmp/test_git_archive/bin/activate\
24+
; pip install \
25+
--cache-dir $CACHE_ROOT/pip_cache \
26+
file://$(realpath chempy-head.zip)#chempy[all] pytest\
27+
; pytest --pyargs chempy"

.ci/run-03-render-notebooks.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
. .ci/_source_common_env.sh
4+
5+
./scripts/render_notebooks.sh
6+
mv index.html index.ipynb.html
7+
cp -r index.* examples/ "deploy/public_html/branches/${CI_COMMIT_BRANCH}"

.woodpecker.yaml

Lines changed: 22 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,58 @@
1+
variables:
2+
# Developers are not expected to actually use this CI image locally, however,
3+
# using this image avoid downloading a bunch of PyPI packages for each CI run.
4+
- &ci_image 'cont-reg.bjodah.se:443/bjodah/triceratops-6:32'
5+
16
when:
2-
- event: [pull_request, tag, cron, push]
7+
- event: [push]
38

49
steps:
510

611
- name: restore-cache
7-
image: bjodah/bjodahimg20dot:21.8.a
12+
image: *ci_image
813
commands:
914
- curl ftp://chempy:$${ARTIFACTS_PASS}@$${FTP_SERVER}/cache/cache-ci.tar | tar x
1015
secrets: [ ARTIFACTS_PASS, FTP_SERVER ]
1116
when:
1217
- event: push
1318
repo: bjodah/chempy
1419

15-
- name: install
16-
image: bjodah/bjodahimg20dot:21.8.a
20+
- name: test-suite
21+
image: *ci_image
1722
environment:
18-
- CC=gcc-11
19-
- CXX=g++-11
20-
- CPLUS_INCLUDE_PATH=/opt/boost-1.77.0/include
21-
- SUNDBASE=/opt/sundials-5.7.0-release
22-
- CPATH=/usr/include/suitesparse # sunlinsol_klu.h includes "klu.h"
23+
- CHEMPY_SKIP_NO_TESTS=1
2324
commands:
24-
- export CACHE_ROOT=$(pwd)/cache-ci
25-
- export PYTHONUSERBASE=$CACHE_ROOT/pyusrb
26-
- if [ ! -d $PYTHONUSERBASE ]; then mkdir -p $PYTHONUSERBASE; fi
27-
- export CPATH=$SUNDBASE/include:$CPATH
28-
- export LIBRARY_PATH=$SUNDBASE/lib
29-
- export LD_LIBRARY_PATH=$SUNDBASE/lib
30-
- python3 -m pip install --cache-dir $CACHE_ROOT/pip_cache --user --upgrade-strategy=eager --upgrade cython
31-
- python3 -m pip install --cache-dir $CACHE_ROOT/pip_cache --user -e .[all]
32-
- python3 -c "import pycvodes; import pyodesys; import pygslodeiv2" # debug this CI config
33-
- git fetch -tq
34-
- python3 setup.py sdist # test pip installable sdist (checks MANIFEST.in)
35-
- git archive -o dist/chempy-head.zip HEAD # test pip installable zip (symlinks break)
25+
- mkdir -p deploy/public_html/branches/${CI_COMMIT_BRANCH}/
26+
- bash -l .ci/run-01-install-deps-create-sdist.sh
27+
- bash -l .ci/run-02-test-suite.sh
3628
- mkdir -p deploy/public_html/branches/${CI_COMMIT_BRANCH}
3729
- cp dist/chempy-* deploy/public_html/branches/${CI_COMMIT_BRANCH}/
3830

39-
- name: test-suite
40-
image: bjodah/bjodahimg20dot:21.8.a
41-
environment:
42-
- CC=gcc-11
43-
- CXX=g++-11
44-
- CPLUS_INCLUDE_PATH=/opt/boost-1.77.0/include
45-
- SUNDBASE=/opt/sundials-5.7.0-release
46-
- CPATH=/usr/include/suitesparse # sunlinsol_klu.h includes "klu.h"
47-
- CHEMPY_SKIP_NO_TESTS=1
48-
commands:
49-
- export CACHE_ROOT=$(pwd)/cache-ci
50-
- export PYTHONUSERBASE=$CACHE_ROOT/pyusrb
51-
- export CPATH=$SUNDBASE/include:$CPATH
52-
- export LIBRARY_PATH=$SUNDBASE/lib
53-
- export LD_LIBRARY_PATH=$SUNDBASE/lib
54-
- bash -c '[[ $(python3 setup.py --version) =~ ^[0-9]+.* ]]'
55-
- ./scripts/run_tests.sh --cov chempy --cov-report html
56-
- ./scripts/coverage_badge.py htmlcov/ htmlcov/coverage.svg
57-
- cp -r htmlcov/ deploy/public_html/branches/${CI_COMMIT_BRANCH}/
58-
- ./.ci/grep-for-merge-blocking-token.sh
59-
- export CHEMPY_DEPRECATION_FILTER=ignore
60-
- python3 -m virtualenv /tmp/test_sdist
61-
- python3 -m virtualenv /tmp/test_git_archive
62-
- cd deploy/public_html/branches/${CI_COMMIT_BRANCH}
63-
- unset CHEMPY_SKIP_NO_TESTS # I can't get pip to install extras when using local file...
64-
- bash -c "source /tmp/test_sdist/bin/activate; pip install --cache-dir $CACHE_ROOT/pip_cache file://$(realpath $(eval ls chempy-*.tar.gz))#chempy[all] pytest; pytest --pyargs chempy"
65-
- bash -c "source /tmp/test_git_archive/bin/activate; pip install --cache-dir $CACHE_ROOT/pip_cache file://$(realpath chempy-head.zip)#chempy[all] pytest; pytest --pyargs chempy"
66-
depends_on:
67-
- install
6831

6932
- name: render-notebooks
70-
image: bjodah/bjodahimg20dot:21.8.a
33+
image: *ci_image
7134
environment:
7235
- CHEMPY_DEPRECATION_FILTER=ignore
73-
- SUNDBASE=/opt/sundials-5.7.0-release
74-
- CC=gcc-11
75-
- CXX=g++-11
76-
- CPATH=/usr/include/suitesparse # sunlinsol_klu.h includes "klu.h"
7736
commands:
78-
- export PYTHONUSERBASE=$(pwd)/cache-ci/pyusrb
79-
- export CPATH=$SUNDBASE/include:$CPATH
80-
- export LIBRARY_PATH=$SUNDBASE/lib
81-
- export LD_LIBRARY_PATH=$SUNDBASE/lib
82-
- ./scripts/render_notebooks.sh
83-
- ./.ci/grep-for-binary-data.sh
84-
- mv index.html index.ipynb.html
85-
- cp -r index.* examples/ "deploy/public_html/branches/${CI_COMMIT_BRANCH}"
86-
depends_on:
87-
- install
37+
- mkdir -p deploy/public_html/branches/${CI_COMMIT_BRANCH}/
38+
- bash -l .ci/run-01-install-deps-create-sdist.sh
39+
- bash -l .ci/run-03-render-notebooks.sh
40+
- .ci/grep-for-binary-data.sh
8841

8942
- name: compile-documentation
90-
image: bjodah/bjodahimg20dot:21.8.a
43+
image: *ci_image
9144
environment:
9245
- CHEMPY_DEPRECATION_FILTER=ignore
93-
- SUNDBASE=/opt/sundials-5.7.0-release
9446
commands:
95-
- export PYTHONUSERBASE=$(pwd)/cache-ci/pyusrb
96-
- export CPATH=$SUNDBASE/include
97-
- export LIBRARY_PATH=$SUNDBASE/lib
98-
- export LD_LIBRARY_PATH=$SUNDBASE/lib
99-
- ./scripts/generate_docs.sh
47+
- bash -lc '. .ci/_source_common_env.sh; ./scripts/generate_docs.sh'
10048
- cp LICENSE doc/_build/html/
10149
- cp -r doc/_build/html/ deploy/public_html/branches/${CI_COMMIT_BRANCH}
10250
depends_on:
10351
- test-suite
10452
- render-notebooks
10553

10654
- name: rebuild-cache
107-
image: bjodah/bjodahimg20dot:21.8.a
55+
image: *ci_image
10856
commands:
10957
- find ./cache-ci/ -type f -mtime +90 -exec rm {} \;
11058
- tar cf cache-ci.tar ./cache-ci/
@@ -117,7 +65,7 @@ steps:
11765
- compile-documentation
11866

11967
- name: deploy-public-html
120-
image: bjodah/bjodahimg20dot:21.8.a
68+
image: *ci_image
12169
commands:
12270
- tar czf chempy-${CI_COMMIT_BRANCH}.tar.gz ./deploy/public_html
12371
- curl -T chempy-${CI_COMMIT_BRANCH}.tar.gz ftp://chempy:$${ARTIFACTS_PASS}@$${FTP_SERVER}/public_html/
@@ -127,5 +75,3 @@ steps:
12775
repo: bjodah/chempy
12876
depends_on:
12977
- compile-documentation
130-
131-

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2015-2018, Björn Dahlgren
1+
Copyright (c) 2015-2025, Björn Dahlgren
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ example of how ChemPy can check consistency of units:
236236
.. code:: python
237237
238238
>>> from chempy import Reaction
239-
>>> r = Reaction.from_string("H2O -> H+ + OH-; 1e-4/M/s")
239+
>>> r = Reaction.from_string("H2O -> H+ + OH-; 1e-4/M/s") # DOCTEST: +ELLIPSIS
240240
Traceback (most recent call last):
241241
...
242-
ValueError: Unable to convert between units of "1/M" and "dimensionless"
242+
ValueError: Incompatible units
243243
>>> r = Reaction.from_string("H2O -> H+ + OH-; 1e-4/s")
244244
>>> from chempy.units import to_unitless, default_units as u
245-
>>> to_unitless(r.param, 1/u.minute)
245+
>>> to_unitless(r.param, 1/u.minute).item()
246246
0.006
247247
248248
right now the ``.units`` module wraps the quantities_ package with some minor

chempy/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
ChemPy is a Python package useful for solving problems in chemistry.
4-
"""
2+
"""ChemPy is a Python package useful for solving problems in chemistry."""
53

64

75
from ._url import __url__

chempy/_solution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
>>> s1 = Solution(0.1*u.dm3, {'CH3OH': 0.1 * u.molar})
99
>>> s2 = Solution(0.3*u.dm3, {'CH3OH': 0.4 * u.molar, 'Na+': 2e-3*u.molar, 'Cl-': 2e-3*u.molar})
1010
>>> s3 = s1 + s2
11-
>>> abs(to_unitless(s3.volume - 4e-4 * u.m**3, u.dm3)) < 1e-15
11+
>>> bool(abs(to_unitless(s3.volume - 4e-4 * u.m**3, u.dm3)) < 1e-15)
1212
True
1313
>>> s3.concentrations.isclose({'CH3OH': 0.325*u.molar, 'Na+': 1.5e-3*u.molar, 'Cl-': 1.5e-3*u.molar})
1414
True
1515
>>> s4 = s3.dissolve({'CH3OH': 1*u.gram})
16-
>>> abs(s4.concentrations['CH3OH'] - (0.325 + 1/(12.011 + 4*1.008 + 15.999)/.4)*u.molar) < 1e-4
16+
>>> bool(abs(s4.concentrations['CH3OH'] - (0.325 + 1/(12.011 + 4*1.008 + 15.999)/.4)*u.molar) < 1e-4)
1717
True
1818
1919
"""

chempy/chemistry.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,15 +517,15 @@ def from_string(cls, string, substance_keys=None, globals_=None, **kwargs):
517517
True
518518
>>> r3 = Reaction.from_string("A -> B; 1/second", 'A B')
519519
>>> from chempy.units import to_unitless, default_units as u
520-
>>> to_unitless(r3.param, u.hour**-1)
520+
>>> to_unitless(r3.param, u.hour**-1).item()
521521
3600.0
522522
>>> r4 = Reaction.from_string("A -> 2 B; 'k'", 'A B')
523523
>>> r4.rate(dict(A=3, B=5, k=7)) == {'A': -3*7, 'B': 2*3*7}
524524
True
525-
>>> r5 = Reaction.from_string("A -> B; 1/molar/second", 'A B')
525+
>>> r5 = Reaction.from_string("A -> B; 1/molar/second", 'A B') # DOCTEST: +ELLIPSIS
526526
Traceback (most recent call last):
527527
...
528-
ValueError: Unable to convert between units ...
528+
ValueError: Incompatible units
529529
530530
531531
Notes

0 commit comments

Comments
 (0)