Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install numpy scipy periodictable
python setup.py install
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ For more examples, take a look at the `examples` folder.
* Using PhreeqPython on Windows requires installing [Visual C++ Redistributable 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145)

## Unit Tests
| **Mac/Linux** | **Windows** | **Coverage** |
|---|---|---|
| [![Build Status](https://travis-ci.com/Vitens/phreeqpython.svg?branch=master)](https://travis-ci.com/Vitens/phreeqpython) | [![Build status](https://ci.appveyor.com/api/projects/status/lr1jwspxdkgo85bv?svg=true)](https://ci.appveyor.com/project/abelheinsbroek/phreeqpython) | [![codecov](https://codecov.io/gh/Vitens/phreeqpython/branch/master/graph/badge.svg)](https://codecov.io/gh/Vitens/phreeqpython) |
| **Mac/Linux** and **Windows** | **Coverage** |
|---|---|
| [![Python package](https://github.com/DocMT/phreeqpython/actions/workflows/python-package.yml/badge.svg)](https://github.com/DocMT/phreeqpython/actions/workflows/python-package.yml)| [![codecov](https://codecov.io/gh/Vitens/phreeqpython/branch/master/graph/badge.svg)](https://codecov.io/gh/Vitens/phreeqpython) |


## Acknowledgements
Expand Down
11 changes: 6 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
build: false

environment:
matrix:
- PYTHON: "C:\\Python36-x64"
PYTHON_VERSION: "3.9.1"
PYTHON_ARCH: "64"
matrix:
- PYTHON: "C:\\Python38-x64"
init:
- "ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH%"
- "ECHO %PYTHON%"

install:
- "%PYTHON%/python.exe -m pip install --upgrade pip"
- "%PYTHON%/python.exe -m pip install pytest"
- "%PYTHON%/python.exe -m pip install numpy"
- "%PYTHON%/python.exe -m pip install scipy"
- "%PYTHON%/python.exe -m pip install periodictable"
- "%PYTHON%/python.exe -m pip install nose"
Expand Down
4 changes: 3 additions & 1 deletion phreeqpython/viphreeqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def bytes(str_, encoding): #pylint: disable-msg=W0613
"""Compatibilty function for Python 3.
"""
return str_
range = xrange #pylint: disable-msg=C0103
range = xrange #pylint: disable-msg=C0103 # noqa: F821
#pylint: enable-msg=W0622


Expand Down Expand Up @@ -44,6 +44,8 @@ def __init__(self, dll_path=None):
dll_name = './lib/viphreeqc.so'
elif sys.platform == 'darwin':
dll_name = './lib/viphreeqc.dylib'
elif 'emscripten' in sys.platform:
dll_name = './lib/viphreeqcwasm.so'
else:
msg = 'Platform %s is not supported.' % sys.platform
raise NotImplementedError(msg)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup
from setuptools import setup, find_packages
import os
import sys
import zipfile
Expand All @@ -11,8 +11,8 @@
author='Abel Heinsbroek',
author_email='abel.heinsbroek@vitens.nl',
license='Apache Licence 2.0',
packages=['phreeqpython'],
packages=['phreeqpython', 'phreeqpython.lib', 'phreeqpython.database'],
include_package_data=True,
zip_safe=False,
install_requires=['periodictable']
install_requires=['periodictable','numpy','scipy']
)
6 changes: 3 additions & 3 deletions tests/test_phreeqpython.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from phreeqpython import PhreeqPython, Solution
from phreeqpython import PhreeqPython, Solution, utility
from pathlib import Path
import pytest

Expand Down Expand Up @@ -39,7 +39,7 @@ def test01_basiscs(self):
assert round(sol.species_activities['Ca+2'], 5) == 0.00054

# test add_solution_simple as milligrams
sol2 = self.pp.add_solution_simple({'Ca': 40.078, 'Na': 22.99, 'MgSO4': 120.37}, units='mg')
sol2 = self.pp.add_solution_simple({'Ca': 40.078, 'Na': 22.99, 'MgSO4': utility.convert_units('MgSO4', 1, 'mmol', 'mg')}, units='mg')
# test conversion from mg to mmol
assert round(sol2.total("Ca", 'mmol'), 4) == 1
# test amount in mg
Expand All @@ -57,7 +57,7 @@ def test02_solution_functions(self):
assert round(sol.total('Cl'), 2) == 3.5
assert round(sol.total('Mg'), 2) == 1
# change solution in mgs (add and subtract)
sol.change({'Na': 11.495, 'MgCl2': -95.211}, 'mg')
sol.change({'Na': 11.495, 'MgCl2': -utility.convert_units('MgCl2', 1, 'mmol', 'mg')}, 'mg')
assert round(sol.total('Cl'), 2) == 1.5
assert round(sol.total('Mg'), 2) == 0

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_convert_units(self):
) == 39997.0
assert round(
convert_units('NaOH', 1, from_units='mol', to_units='ug'), 0
) == 39997110.0
) == 39996769.0

assert round(
convert_units('NaOH', 1, from_units='mmol', to_units='mol'), 4
Expand Down