Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
4f90204
Change unittest to pytest
daklauss Dec 3, 2024
961edf8
Remove constructors of testclasses for pytest
daklauss Jan 6, 2025
eaefbd6
Normalize flow_rate profiles before fitting
schmoelder Dec 19, 2024
ae08449
Make run methods private
schmoelder Jan 14, 2025
2706d88
Extend MPMLangmuir gamma range
ronald-jaepel Jan 14, 2025
ecb6abe
Expose option to set precision when adding variables
schmoelder Jun 26, 2024
b179337
Add option to specify (rounding) precision for transforming variables
schmoelder Jun 26, 2024
5016201
Use variable precision for transformation
schmoelder Jun 26, 2024
0357f05
Avoid double transform in _transform
ronald-jaepel Jan 21, 2025
b415222
Add functionality to round to significant digits.
ronald-jaepel Jan 21, 2025
a4e2d46
Rename TransformBase to TransformerBase
schmoelder Jan 22, 2025
1ddfd49
Remove duplicate code
schmoelder Jan 27, 2025
9f8ccfc
Call-super().__init__()-for-Simulator-classes
schmoelder Jan 20, 2025
15d7093
Formatting
schmoelder Jan 28, 2025
6c89b8f
Return Reaction object when adding to ReactionSystem
schmoelder Jan 28, 2025
582e754
Ignore checking size when instance is None
schmoelder Jan 28, 2025
a6b3047
Improve casting of floats
schmoelder Jan 28, 2025
db29163
Fix setter for SizedAggregator
schmoelder Jan 27, 2025
bfdb983
Add tests for Aggregator
schmoelder Jan 28, 2025
a624ca9
Add ProxyList/Array to allow indexed modification of aggregated prope…
schmoelder Jan 29, 2025
5979c46
Remove Height from Shape metric
schmoelder Feb 14, 2025
4074459
Remove deprecated function
schmoelder Feb 14, 2025
a4fc436
Add warning to simulator when setting n_cycles_max below n_cycles_min
ronald-jaepel Jan 22, 2025
2583c01
Change warning to Error
ronald-jaepel Feb 14, 2025
2d4cd05
Add n_cycles_batch to simulator for batching of cycle calls
ronald-jaepel Feb 14, 2025
e1c64fe
Formatting, docstrings, and type annotations
schmoelder Feb 11, 2025
d57bb9c
Call super().__init__() in FlowSheet
schmoelder Feb 14, 2025
a945d20
fixup! Add ProxyList/Array to allow indexed modification of aggregate…
schmoelder Feb 16, 2025
30bfcef
Add dependabot
schmoelder Feb 21, 2025
46d1a30
Pin libsqlite version to avoid crash
schmoelder Feb 21, 2025
03b9352
Improve fractionation performance
daklauss Feb 14, 2025
9dc6b7f
Add `ChromatographicColumnBase` class
schmoelder Feb 15, 2025
09cd34e
Add option to update_dict_recursively only for existing keys
schmoelder Feb 15, 2025
afe7f7e
Improve docstrings / type annotations
schmoelder Feb 15, 2025
ef25cf6
Add tests for recursive_dict module
schmoelder Feb 15, 2025
526383d
Add some dunder methods
schmoelder Feb 15, 2025
ed4d4aa
Remove `spatial_method` from discretization parameters
schmoelder Feb 15, 2025
2e2946c
Store value of `_q` in parameters dict
schmoelder Feb 21, 2025
603429c
Add coverage pipeline
daklauss Jan 8, 2025
363e43c
Add method to calculate Bodenstein number
schmoelder Feb 17, 2025
6acafab
fixup! Remove `spatial_method` from discretization parameters
schmoelder Feb 25, 2025
d931e33
Add tool to rename arguments in function signature
AntoniaBerger Feb 14, 2025
c0be693
Change indices to components in Reaction.__init__
AntoniaBerger Feb 14, 2025
0f461de
Handle nan's in the round_to_significant_digits function
ronald-jaepel Feb 24, 2025
12c4c5d
Use log transform for optimization variables if ub/lb >= 100
schmoelder Feb 25, 2025
0a426aa
fixup! Add ProxyList/Array to allow indexed modification of aggregate…
schmoelder Feb 25, 2025
9d6a392
Fix issue when calculating definite integral
schmoelder Mar 6, 2025
bb903fc
Improve interpolation of concentration profiles
schmoelder Feb 7, 2025
10d0d60
fixup! Remove `spatial_method` from discretization parameters
schmoelder Mar 7, 2025
94e324a
Make axial dispersion component dependent
schmoelder Mar 6, 2025
9c2598b
Add use_dll option to LWE tests in test_cadet_adapter
hannahlanzrath Feb 26, 2025
02c17a8
Add method to load OptimizationResults from file
Feb 19, 2025
f582b66
Add concentration to parameters
schmoelder Feb 25, 2025
350d05e
Improve returning default values for sized parameters
schmoelder Mar 10, 2025
7e538c6
Update UnitOperation.q setter
schmoelder Mar 12, 2025
4a05bfc
Return n_bounds = 0 if binding_model is NoBinding
schmoelder Mar 10, 2025
98d4afb
Improve testing of unit operations
schmoelder Mar 12, 2025
6ead8a8
Update hopsy
schmoelder Mar 13, 2025
f3ff2f6
Add type annotations
schmoelder Mar 13, 2025
ae234de
Move rng instantiation
schmoelder Mar 13, 2025
46a41bc
Cleanup method to compute Chebyshev center
schmoelder Mar 13, 2025
5a72bfe
Round problem before sampling
schmoelder Mar 13, 2025
35dbb9d
Formatting, docstrings and type annotations
schmoelder Mar 13, 2025
7464f41
Improve y_max in Comparator.plot_comparison()
schmoelder Mar 13, 2025
dc0e1da
Remove old file
schmoelder Mar 13, 2025
27c85c7
Add missing binding models to documentation
schmoelder Mar 14, 2025
1d60fc0
Add option to use component name for taget component in add_fractiona…
AntoniaBerger Mar 14, 2025
e896900
Add type annotations for fractionator module
AntoniaBerger Mar 14, 2025
0dd657a
fixup! Make axial dispersion component dependent
schmoelder Mar 14, 2025
1120bbf
Update tests to axial dispersion multiplexing
hannahlanzrath Mar 14, 2025
4fe0253
Explicitly set multiplex parameters
schmoelder Mar 16, 2025
fbd76ef
Adapt to CADET-Python's new run interface
ronald-jaepel Mar 18, 2025
a0be811
Improve GRM docstring
ronald-jaepel Mar 20, 2025
affa8da
Use Conda in CI and activate Windows again
hannahlanzrath Dec 9, 2024
908a5e6
fixup! Adapt to CADET-Python's new run interface
schmoelder Mar 21, 2025
fdb12e4
Move load_results method to OptimizationResults
schmoelder Mar 21, 2025
03f98f4
Fix syntax warnings for invalid escape sequence in docstrings
ronald-jaepel Nov 15, 2024
5ecbe3a
Add __all__ to optimizationProlem module
schmoelder Mar 25, 2025
9b6bea8
Use run_simulation method
schmoelder Mar 25, 2025
0a30745
Fix NumpyProxyArray in OptimizationProblem
schmoelder Mar 25, 2025
500e599
Add pairwise plot
schmoelder Mar 16, 2025
d20cc53
Add pairwise plot to plot_all of OptimizationResults
schmoelder Mar 16, 2025
59f6f2c
Add deprecation warning to corner plot
schmoelder Mar 20, 2025
1c5ed95
Use last point fulfilling purity constraints for initial values
schmoelder Mar 26, 2025
282da4a
Update COBYLA parameters in fractionation optimization
schmoelder Mar 26, 2025
b5d2de2
Formatting
schmoelder Mar 21, 2025
002a220
Add version property
schmoelder Mar 22, 2025
8ef4eea
Add timeout option to solver parameters
schmoelder Mar 21, 2025
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
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
76 changes: 76 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: coverage

on:
push:
branches:
- master
- dev
- 144-monitor-test-coverage
workflow_dispatch:
inputs:
slow:
type: boolean
description: Run with slow tests
default: false

jobs:
coverage-job:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.12"]

env:
CONDA_FILE: environment.yml

steps:
- uses: actions/checkout@v4

- name: Get Date
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
use-mamba: true
activate-environment: cadet-process
channels: conda-forge,

- name: Cache conda
uses: actions/cache@v4
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ${{ env.CONDA }}/envs
key: ${{ matrix.os }}-python_${{ matrix.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(env.CONDA_FILE) }}-${{ env.CACHE_NUMBER }}

- name: Update environment
run: |
mamba install "setuptools>=69" "pip>=24"
mamba install python=${{ matrix.python-version }}
echo "python=${{ matrix.python-version }}.*" > $CONDA_PREFIX/conda-meta/pinned
mamba env update -n cadet-process -f ${{ env.CONDA_FILE }}
if: steps.cache.outputs.cache-hit != 'true'

- name: Install
run: |
pip install -e ./[testing,coverage]

# Push event doesn't have input context => inputs.notslows is empty => false
- name: Coverage Run
run: |
if [ ${{ github.event.inputs.slow }} ]; then
pytest --cov=./CADETProcess --cov=./tests --cov-report term-missing tests
else
pytest -m "not slow" --cov=./CADETProcess --cov=./tests --cov-report term-missing tests
fi
24 changes: 12 additions & 12 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12"]
include:
# - os: windows-latest
# python-version: "3.12"
- os: windows-latest
python-version: "3.12"
- os: macos-13
python-version: "3.12"

Expand All @@ -41,9 +41,8 @@ jobs:
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
use-mamba: true
activate-environment: cadet-process
channels: conda-forge,
channels: conda-forge

- name: Cache conda
uses: actions/cache@v4
Expand All @@ -53,31 +52,32 @@ jobs:
with:
path: ${{ env.CONDA }}/envs
key: ${{ matrix.os }}-python_${{ matrix.python-version }}-${{ steps.get-date.outputs.today }}-${{ hashFiles(env.CONDA_FILE) }}-${{ env.CACHE_NUMBER }}
id: cache

- name: Update environment
run: |
mamba install "setuptools>=69" "pip>=24"
mamba install python=${{ matrix.python-version }}
conda install "setuptools>=69" "pip>=24"
conda install python=${{ matrix.python-version }}
echo "python=${{ matrix.python-version }}.*" > $CONDA_PREFIX/conda-meta/pinned
mamba env update -n cadet-process -f ${{ env.CONDA_FILE }}
conda env update -n cadet-process -f ${{ env.CONDA_FILE }}
if: steps.cache.outputs.cache-hit != 'true'

- name: Install
run: |
pip install -e ./[testing]
conda run pip install -e ./[testing]

- name: Test
run: |
python -m unittest discover -s tests
pytest tests -m "not slow" --durations=0

- name: Install pypa/build
run: |
python -m pip install build --user
conda run python -m pip install build --user

- name: Build binary wheel and source tarball
run: |
python -m build --sdist --wheel --outdir dist/ .
conda run python -m build --sdist --wheel --outdir dist/ .

- name: Test Wheel install and import
run: |
python -c "import CADETProcess; print(CADETProcess.__version__)"
conda run python -c "import CADETProcess; print(CADETProcess.__version__)"
1 change: 1 addition & 0 deletions CADETProcess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
settings = Settings()

from . import sysinfo
from . import numerics
from . import dataStructure
from . import transform
from . import plotting
Expand Down
16 changes: 8 additions & 8 deletions CADETProcess/comparison/comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from CADETProcess.dataStructure import get_nested_value
from CADETProcess.solution import SolutionBase
from CADETProcess.comparison import DifferenceBase
from CADETProcess.numerics import round_to_significant_digits


class Comparator(Structure):
Expand Down Expand Up @@ -319,10 +320,14 @@ def plot_comparison(
solution.smooth_data()
solution_sliced = metric.slice_and_transform(solution)

y_max = 1.1 * max(
np.max(solution_sliced.solution), np.max(metric.reference.solution)
)

fig, ax = solution_sliced.plot(
ax=ax,
show=False,
y_max=1.1*np.max(metric.reference.solution)
y_max=y_max,
)

plot_args = {
Expand All @@ -338,12 +343,7 @@ def plot_comparison(
ax.legend(loc=1)

m = metric.evaluate(solution_sliced, slice=False)
m = [
np.format_float_scientific(
n, precision=2,
)
for n in m
]
m = round_to_significant_digits(m, digits=2)

text = f"{metric}: "
if metric.n_metrics > 1:
Expand All @@ -356,7 +356,7 @@ def plot_comparison(
except AttributeError:
text += f"{m}"
else:
text += m[0]
text += str(m[0])

plotting.add_text(ax, text, fontsize=14)

Expand Down
80 changes: 10 additions & 70 deletions CADETProcess/comparison/difference.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from abc import abstractmethod
import copy
from functools import wraps
from warnings import warn

import numpy as np
from scipy.integrate import simpson
Expand Down Expand Up @@ -29,14 +28,6 @@
]


def squishify(*args, **kwargs):
warn(
'This function is deprecated, use sigmoid_distance.',
DeprecationWarning, stacklevel=2
)
return sigmoid_distance(*args, **kwargs)


def sigmoid_distance(measurement, target, normalization=1):
"""Calculate the distance between two values using a sigmoid function.

Expand Down Expand Up @@ -495,8 +486,9 @@ class Shape(DifferenceBase):
@wraps(DifferenceBase.__init__)
def __init__(
self, *args,
use_derivative=True, normalize_metrics=True, normalization_factor=None,
include_height=True,
use_derivative=True,
normalize_metrics=True,
normalization_factor=None,
**kwargs):
"""Initialize Shape metric.

Expand All @@ -514,10 +506,6 @@ def __init__(
normalization_factor : float, optional
Normalization factor used by the sigmoid function.
Default is None, which sets it to 1/10 of the simulation time.
include_height : bool, optional
If True, also return a metric for the height difference.
If `use_derivative` is also true, also return height differences
for the derivatives.
**kwargs : dict
Keyword arguments passed to the base class constructor.

Expand All @@ -532,13 +520,6 @@ def __init__(
"Shape currently only supports single component."
)

self.include_height = include_height
if include_height:
warn("Peak height will be removed from the Shape difference metric.", DeprecationWarning)
self.peak_height = PeakHeight(
*args, normalize=False, normalize_metrics=normalize_metrics, **kwargs
)

self.use_derivative = use_derivative
if use_derivative:
self.reference_der = self.reference.derivative
Expand All @@ -555,17 +536,6 @@ def __init__(
coordinates={'time': (self.start, self.end)}
)

self.peak_der_min = PeakHeight(
self.reference_der, *args[1:], normalize=False,
find_minima=True, normalize_metrics=normalize_metrics,
**kwargs
)
self.peak_der_max = PeakHeight(
self.reference_der, *args[1:], normalize=False,
find_minima=False, normalize_metrics=normalize_metrics,
**kwargs
)

self.normalize_metrics = normalize_metrics
if normalization_factor is None:
normalization_factor = self.reference.time[-1]/10
Expand All @@ -575,29 +545,16 @@ def __init__(
def n_metrics(self):
n_metrics = 2

if self.include_height:
n_metrics += 1

if self.use_derivative:
n_metrics += 1

if self.include_height:
n_metrics += 2

return n_metrics

@property
def labels(self):
labels = ['Pearson Correleation', 'Time offset']
if self.include_height:
labels += ["Peak Height"]
if self.use_derivative:
labels += ['Pearson Correlation Derivative']
if self.include_height:
labels += [
'Peak Minimum Derivative',
'Peak Maximum Derivative'
]
return labels

def _evaluate(self, solution):
Expand All @@ -615,9 +572,6 @@ def _evaluate(self, solution):
solution.solution_interpolated.solutions[0],
)

if self.include_height:
peak_height = self.peak_height(solution, slice=False)

if self.normalize_metrics:
offset = sigmoid_distance(
offset_original, target=0, normalization=self.normalization_factor
Expand All @@ -626,10 +580,7 @@ def _evaluate(self, solution):
offset = np.abs(offset_original)

if not self.use_derivative:
if self.include_height:
return np.array([corr, offset, peak_height[0]])
elif not self.include_height:
return np.array([corr, offset])
return np.array([corr, offset])

solution_der = solution.derivative
solution_der_sliced = self.slice_and_transform(solution_der)
Expand All @@ -641,23 +592,12 @@ def _evaluate(self, solution):
offset_original,
)

der_min = self.peak_der_min(solution_der_sliced, slice=False)
der_max = self.peak_der_max(solution_der_sliced, slice=False)

if self.include_height:
return np.array(
[
corr, offset, peak_height[0],
corr_der, der_min[0], der_max[0]
]
)
elif not self.include_height:
return np.array(
[
corr, offset,
corr_der,
]
)
return np.array(
[
corr, offset,
corr_der,
]
)


class PeakHeight(DifferenceBase):
Expand Down
1 change: 1 addition & 0 deletions CADETProcess/dataStructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@
from .cache import *
from .diskcache import *
from .nested_dict import *
from .deprecation import *
Loading
Loading