Skip to content
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

Update #32

Closed
wants to merge 57 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
aa03da7
Bug fix use of initial_guesses in grid_minimization
Apr 20, 2021
c88fc83
Bug fix grid_minimization, bounds for intial_guesses
Apr 21, 2021
587f02c
Update settingup.rst
jaclark5 Jan 10, 2024
563c9c6
Update calculation_types.py
jaclark5 Jan 10, 2024
74fc3c1
Update __init__.py
jaclark5 Jan 10, 2024
4cfc9ae
Update startfitting.rst
jaclark5 Jan 10, 2024
f3872f4
Update saft.py
jaclark5 Jan 10, 2024
d2763a4
Update Aassoc.py
jaclark5 Jan 10, 2024
4121f17
Update saft.py
jaclark5 Jan 10, 2024
0ae9db6
Update saft.py
jaclark5 Jan 10, 2024
83c8ed6
propagate Aassoc square_epsilonHB
jaclark5 Jan 10, 2024
4e42973
Update Aassoc.py docstring
jaclark5 Jan 10, 2024
dc0757d
Update Aassoc.py: add use of rc and rc cross_library
jaclark5 Jan 10, 2024
b52f0d7
Update TLVE.py, docstring
jaclark5 Jan 10, 2024
379c93f
Update flash.py, docstring
jaclark5 Jan 10, 2024
ac0c405
Update CI.yaml
jaclark5 Sep 26, 2023
2d1c29d
Update CI.yaml
jaclark5 Sep 27, 2023
fc0d1ec
Update setup.py
jaclark5 Sep 27, 2023
3f41b33
Update README.md
jaclark5 Sep 27, 2023
0516804
Update README.md
jaclark5 Sep 27, 2023
2ad401c
Update setup.py
jaclark5 Sep 27, 2023
6c66691
Delete despasito/tests/test_.py
jaclark5 Sep 27, 2023
54c2517
Merge branch 'master' into update
jaclark5 Jan 10, 2024
86bc04a
Update liquid_density.py, docstring
jaclark5 Jan 10, 2024
ef94754
Update saturation_properties.py, docstring
jaclark5 Jan 10, 2024
605f70e
Update solubility_parameter.py, docstring
jaclark5 Jan 10, 2024
4c11270
Merge branch 'update' into neg_assoc
jaclark5 Jan 10, 2024
d2ba5a0
Bug fix cython Xika_6
jaclark5 Jan 12, 2024
2e52faf
Merge branch 'update' into neg_assoc
jaclark5 Jan 12, 2024
e02205c
Update installation instructions to ensure compilation of cython
jaclark5 Jan 12, 2024
e64340e
Bug fix rd_
jaclark5 Jan 12, 2024
43907b1
Merge branch 'update' into neg_assoc
jaclark5 Jan 12, 2024
9c5fb4e
Added negative sign to Fklab
jaclark5 Jan 25, 2024
465918d
Update to align with literature treatment
jaclark5 Jan 30, 2024
899ffce
Bug fix association site bonding volume
jaclark5 Feb 7, 2024
95911b7
Bug fix saft gamma mie association site processing
jaclark5 Feb 8, 2024
34af137
Make fitting errors more descriptive. Improve code format.
jaclark5 Feb 11, 2024
1b3ed0e
Merge branch 'update' into neg_assoc
jaclark5 Feb 11, 2024
e333936
Add freeze_support
jaclark5 Feb 16, 2024
d9a886d
remove neg assoc
jaclark5 Feb 16, 2024
ae114cb
Merge branch 'neg_assoc' into update
jaclark5 Feb 16, 2024
2423d29
Resolve pickling issue saft.gamma_mie
jaclark5 Feb 16, 2024
18f4c58
Update settingup doc
May 4, 2024
f911903
Merge branch 'update' of https://github.com/jaclark5/despasito into u…
May 4, 2024
e994dd6
Add paper
May 11, 2024
f0a9416
Add github action to compile paper
May 11, 2024
5ec0a6e
update github miniconda reference
May 11, 2024
98d8cf7
Update paper.bib
May 11, 2024
248168f
Update github actions
May 11, 2024
57920e6
Update actions
May 11, 2024
dd607c9
remove fortran, fix tests
May 19, 2024
6b9e521
Update github-ci
Jun 29, 2024
704bbf8
Update readthedocs
Jun 29, 2024
36800b6
Update readthedocs requirements
Jun 29, 2024
1752b69
Resolve code quality testing
Jun 29, 2024
bbc09fe
update conda env
Jun 29, 2024
097e155
Fix formatting
Jun 30, 2024
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
137 changes: 70 additions & 67 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,84 +18,87 @@ on:
# (from https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule)
- cron: "0 0 * * *"

jobs:
linux:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get install gfortran
- run: gfortran --version

windows:
runs-on: windows-latest
steps:
- run: choco install mingw

jobs:
test:
name: Test on ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v4

# Not relevant now, but may be needed when f2py issues are solved, for now only numba
# - name: Set up msys for Windows
# if: matrix.os == 'windows-latest'
# uses: msys2/setup-msys2@v2
# with:
# update: true
# install: >-
# mingw-w64-x86_64-gcc-fortran
# mingw-w64-x86_64-gcc

- uses: actions/checkout@v2

- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a
- name: Additional info about the build
shell: bash
run: |
uname -a
df -h
ulimit -a

# More info on options: https://github.com/conda-incubator/setup-miniconda
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/test_env.yaml
activate-environment: test
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true
# More info on options: https://github.com/conda-incubator/setup-miniconda
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
environment-file: devtools/conda-envs/test_env.yaml
activate-environment: test
auto-update-conda: false
auto-activate-base: false
show-channel-urls: true
condarc: |
channels:
- conda-forge
create-args: >-
python=${{ matrix.python-version }}

- name: Testing Dependencies
shell: bash -l {0}
run: |
python -m pip install -U pytest pytest-cov codecov

- name: Install gfortran on mac
if: matrix.os == 'macOS-latest'
shell: bash -l {0}
run: |
conda install -c conda-forge gfortran_osx-64
- name: Testing Dependencies
shell: bash -l {0}
run: |
python -m pip install -U pytest pytest-cov codecov

- name: Install package
# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps -vvv
conda list
- name: Install package
# conda setup requires this special shell
shell: bash -l {0}
run: |
python -m pip install -e . --no-deps -vvv
conda list

- name: Run tests
shell: bash -l {0}
run: |
ls -a despasito/equations_of_state/saft/compiled_modules
pytest -vvv --cov=despasito --cov-report=xml --color=yes despasito/tests/
- name: Run tests
shell: bash -l {0}
run: |
ls -a despasito/equations_of_state/saft/compiled_modules
pytest -vvv --cov=despasito --cov-report=xml --color=yes despasito/tests/

- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}

- name: Flake8
shell: bash -l {0}
run: |
python -m flake8 despasito --count --ignore=E741,W503 --max-line-length=92 --show-source --statistics

- name: CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
flags: unittests
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
paper:
runs-on: ubuntu-latest
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
journal: joss
# This should be the path to the paper within your repo.
paper-path: paper/paper.md
- name: Upload
uses: actions/upload-artifact@v3
with:
name: paper
# This is the output path where Pandoc will write the compiled
# PDF. Note, this should be the same directory as the input
# paper.md
path: paper/paper.pdf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
__pycache__/
*.py[cod]
*$py.class
.DS_Store

# C extensions
*.so
Expand Down
13 changes: 5 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements

#conda:
# environment: devtools/conda-envs/readthedocs_env.yaml
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": [],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ DESPASITO
[![GitHub Actions Build Status](https://github.com/jaclark5/despasito/workflows/CI/badge.svg)](https://github.com/jaclark5/despasito/actions?query=workflow%3ACI)
[![codecov](https://codecov.io/gh/jaclark5/DESPASITO/branch/master/graph/badge.svg)](https://codecov.io/gh/jaclark5/DESPASITO/branch/master)
[![Documentation Status](https://readthedocs.org/projects/despasito/badge/?version=latest)](https://despasito.readthedocs.io/en/latest/?badge=latest)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/jaclark5/despasito.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/jaclark5/despasito/context:python)

DESPASITO: Determining Equilibrium State and Parametrization Application for SAFT, Intended for Thermodynamic Output

Expand Down Expand Up @@ -44,7 +43,7 @@ Options

* Step 1: Install the prerequisites listed above.
* Step 2: Download the master branch from our github page as a zip file, or clone it with git via ``git clone https://github.com/jaclark5/despasito`` to your working directory.
* Step 3: Install with ``pip install despasito/.``, or change directories and run ``pip install .``.
* Step 3: Install with ``pip install despasito/.``, or change directories and run ``pip install -e .``.

**NOTE** If [pip](https://pip.pypa.io/en/stable/) is unavailable, follow the instructions outlined [here](https://pip.pypa.io/en/stable/installing/) for installation.

Expand Down
43 changes: 26 additions & 17 deletions despasito/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""
DESPASITO
DESPASITO: Determining Equilibrium State and Parametrization Application for SAFT, Intended for Thermodynamic Output
DESPASITO: Determining Equilibrium State and Parametrization Application for SAFT,
Intended for Thermodynamic Output
"""

# Add imports here
from .main import run
import os
import logging
import logging.handlers

# Handle versioneer
from ._version import get_versions
Expand All @@ -14,10 +16,6 @@
__git_revision__ = versions["full-revisionid"]
del get_versions, versions

import logging
import logging.handlers
import os

logger = logging.getLogger()
logger.setLevel(30)

Expand All @@ -26,16 +24,26 @@ def initiate_logger(console=None, log_file=None, verbose=30):
"""
Initiate a logging handler if more detail on the calculations is desired.

This function is useful when DESPASITO is used as an imported package. If a handler of the given type is already present, nothing is done, as is the case when the input file schema is used. If either handler is given a value of False, the handler of that type is removed.
This function is useful when DESPASITO is used as an imported package. If a handler
of the given type is already present, nothing is done, as is the case when the
input file schema is used. If either handler is given a value of False, the handler
of that type is removed.

Parameters
----------
console : bool, Optional, default=None
Initiates a stream handler to print to a console. If True, this handler is initiated. If it is False, then any StreamHandler is removed.
Initiates a stream handler to print to a console. If True, this handler is
initiated. If it is False, then any StreamHandler is removed.
log_file : bool/str, Optional, default=None
If log output should be recorded in a file, set this keyword to either True or to a name for the log file. If True, the file name 'despasito.log' is used. Note that if a file with the same name already exists, it will be deleted.
If log output should be recorded in a file, set this keyword to either True or
to a name for the log file. If True, the file name 'despasito.log' is used.
Note that if a file with the same name already exists, it will be deleted.
verbose : int, Optional, default=30
The verbosity of logging information can be set to any supported representation of the `logging level <https://docs.python.org/3/library/logging.html#logging-levels>`_.
The verbosity of logging information can be set to any supported representation
of the
`logging level <LOGGER>`_.

.. _LOGGER: https://docs.python.org/3/library/logging.html#logging-levels
"""

logger.setLevel(verbose)
Expand All @@ -50,7 +58,7 @@ def initiate_logger(console=None, log_file=None, verbose=30):
handler_console = tmp

# Set up logging to console
if console and handler_console == None:
if console and handler_console is None:
console_handler = logging.StreamHandler() # sys.stderr
console_handler.setFormatter(
logging.Formatter("[%(levelname)s](%(name)s): %(message)s")
Expand All @@ -59,14 +67,14 @@ def initiate_logger(console=None, log_file=None, verbose=30):
logger.addHandler(console_handler)
elif console:
logger.warning("StreamHandler already exists")
elif handler_console == False:
elif handler_console is not None:
handler_console.close()
logger.removeHandler(handler_console)

# Rotating File Handler
if log_file is not None and handler_logfile == None:
if log_file is not None and handler_logfile is None:

if type(log_file) != str:
if not isinstance(log_file, str):
log_file = "despasito.log"

if os.path.isfile(log_file):
Expand All @@ -75,13 +83,14 @@ def initiate_logger(console=None, log_file=None, verbose=30):
log_file_handler = logging.handlers.RotatingFileHandler(log_file)
log_file_handler.setFormatter(
logging.Formatter(
"%(asctime)s [%(levelname)s](%(name)s:%(funcName)s:%(lineno)d): %(message)s"
"%(asctime)s [%(levelname)s](%(name)s:%(funcName)s:%(lineno)d): "
+ "%(message)s"
)
)
log_file_handler.setLevel(verbose)
logger.addHandler(log_file_handler)
elif log_file:
logger.warning("RotatingFileHandler already exists")
elif handler_logfile == False:
elif not handler_logfile:
handler_logfile.close()
logger.removeHandler(handler_logfile)
4 changes: 2 additions & 2 deletions despasito/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
parser = get_parser()
args = parser.parse_args()

## Extract arguments
# Extract arguments
if args.verbose == 0:
args.verbose = 20
elif args.verbose < 4:
Expand Down Expand Up @@ -56,7 +56,7 @@
kwargs["numba"] = args.numba
logging.info("Use Cython: {}".format(args.cython))
kwargs["cython"] = args.cython
logging.info("Pure Python (no Fortran): {}".format(args.python))
logging.info("Pure Python: {}".format(args.python))
kwargs["python"] = args.python

kwargs["MultiprocessingObject"] = MultiprocessingJob(ncores=args.ncores)
Expand Down
8 changes: 4 additions & 4 deletions despasito/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
dirname = os.path.basename(root)
if dirname.startswith(parentdir_prefix):
return {
"version": dirname[len(parentdir_prefix) :],
"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
"dirty": False,
"error": None,
Expand Down Expand Up @@ -190,7 +190,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG) :] for r in refs if r.startswith(TAG)])
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
Expand All @@ -207,7 +207,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
for ref in sorted(tags):
# sorting will prefer e.g. "2.0" over "2.0rc1"
if ref.startswith(tag_prefix):
r = ref[len(tag_prefix) :]
r = ref[len(tag_prefix):]
if verbose:
print("picking %s" % r)
return {
Expand Down Expand Up @@ -307,7 +307,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
tag_prefix,
)
return pieces
pieces["closest-tag"] = full_tag[len(tag_prefix) :]
pieces["closest-tag"] = full_tag[len(tag_prefix):]

# distance: number of commits since tag
pieces["distance"] = int(mo.group(2))
Expand Down
Loading
Loading