drux 0.2__tar.gz → 0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drux
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: Drux: Drug Release Analysis Framework
5
5
  Home-page: https://github.com/openscilab/drux
6
- Download-URL: https://github.com/openscilab/drux/tarball/v0.2
6
+ Download-URL: https://github.com/openscilab/drux/tarball/v0.3
7
7
  Author: Drux Development Team
8
8
  Author-email: drux@openscilab.com
9
9
  License: MIT
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
23
24
  Classifier: Intended Audience :: Developers
24
25
  Classifier: Intended Audience :: Education
25
26
  Classifier: Intended Audience :: End Users/Desktop
@@ -53,6 +54,7 @@ Dynamic: summary
53
54
 
54
55
 
55
56
  <div align="center">
57
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/logo.png" width="350">
56
58
  <h1>Drux: Drug Release Analysis Framework</h1>
57
59
  <br/>
58
60
  <a href="https://badge.fury.io/py/drux"><img src="https://badge.fury.io/py/drux.svg" alt="PyPI version"></a>
@@ -116,9 +118,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
116
118
 
117
119
  ### PyPI
118
120
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
119
- - Run `pip install drux==0.2`
121
+ - Run `pip install drux==0.3`
120
122
  ### Source code
121
- - Download [Version 0.2](https://github.com/openscilab/drux/archive/v0.2.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
123
+ - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
122
124
  - Run `pip install .`
123
125
 
124
126
  ## Supported Models
@@ -175,6 +177,7 @@ where:
175
177
  - $c_s (\frac{mg}{cm^3})$ is the solubility of the drug in the polymer (carrier)
176
178
 
177
179
  ⚠️ The Higuchi model assumes that $c_0 \ge c_s$
180
+
178
181
  #### Applications
179
182
  1. Matrix Tablets
180
183
  2. Hydrophilic polymer matrices
@@ -182,6 +185,26 @@ where:
182
185
  4. Semisolid Systems
183
186
  5. Implantable Drug delivery systems
184
187
 
188
+ ### Weibull
189
+ Weibull model is an empirical model used to describe drug release kinetics from various pharmaceutical dosage forms. It is characterized by a flexible empirical equation that captures various release kinetics.
190
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
191
+
192
+ $$
193
+ M_t = M \left(1 - e^{-at^b}\right)
194
+ $$
195
+
196
+ where:
197
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t$
198
+ - $M (mg)$ is the total amount of drug released at infinite time
199
+ - $a$ is the scale parameter (related to the release rate)
200
+ - $b$ is the shape parameter (indicates the release mechanism)
201
+
202
+ #### Applications
203
+ 1. Controlled-release modeling
204
+ 2. Dissolution profiling
205
+ 3. Comparative studies
206
+ 4. Vivo predictions
207
+
185
208
  ## Usage
186
209
  ### Zero-Order Model
187
210
  ```python
@@ -210,6 +233,16 @@ model.plot(show=True)
210
233
  ```
211
234
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/higuchi_plot.png" alt="Higuchi Plot">
212
235
 
236
+ ### Weibull Model
237
+
238
+ ```python
239
+ from drux import WeibullModel
240
+ model = WeibullModel(M=1, a=0.095, b=0.7)
241
+ model.simulate(duration=100, time_step=1)
242
+ model.plot(show=True)
243
+ ```
244
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
245
+
213
246
  ## Issues & bug reports
214
247
 
215
248
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -230,6 +263,7 @@ You can also join our discord server
230
263
  <blockquote>4- R. Vaju and K. V. Murthy, "Development and validation of new discriminative dissolution method for carvedilol tablets," <i>Indian Journal of Pharmaceutical Sciences</i>, vol. 73, no. 5, pp. 527–536, Sep. 2011.</blockquote>
231
264
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
232
265
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
266
+ <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
233
267
 
234
268
  ## Show your support
235
269
  ### Star this repo
@@ -248,6 +282,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
248
282
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
249
283
 
250
284
  ## [Unreleased]
285
+ ## [0.3] - 2025-12-08
286
+ ### Added
287
+ - Weibull model
288
+ - Logo
289
+ - `__repr__` method for models
290
+ ### Changed
291
+ - `Python 3.14` added to `test.yml`
251
292
  ## [0.2] - 2025-09-27
252
293
  ### Added
253
294
  - Zero-order model
@@ -264,6 +305,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
264
305
  - Higuchi model
265
306
 
266
307
 
267
- [Unreleased]: https://github.com/openscilab/drux/compare/v0.2...dev
308
+ [Unreleased]: https://github.com/openscilab/drux/compare/v0.3...dev
309
+ [0.3]: https://github.com/openscilab/drux/compare/v0.2...v0.3
268
310
  [0.2]: https://github.com/openscilab/drux/compare/v0.1...v0.2
269
311
  [0.1]: https://github.com/openscilab/drux/compare/48548f0...v0.1
@@ -1,4 +1,5 @@
1
1
  <div align="center">
2
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/logo.png" width="350">
2
3
  <h1>Drux: Drug Release Analysis Framework</h1>
3
4
  <br/>
4
5
  <a href="https://badge.fury.io/py/drux"><img src="https://badge.fury.io/py/drux.svg" alt="PyPI version"></a>
@@ -62,9 +63,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
62
63
 
63
64
  ### PyPI
64
65
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
65
- - Run `pip install drux==0.2`
66
+ - Run `pip install drux==0.3`
66
67
  ### Source code
67
- - Download [Version 0.2](https://github.com/openscilab/drux/archive/v0.2.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
68
+ - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
68
69
  - Run `pip install .`
69
70
 
70
71
  ## Supported Models
@@ -121,6 +122,7 @@ where:
121
122
  - $c_s (\frac{mg}{cm^3})$ is the solubility of the drug in the polymer (carrier)
122
123
 
123
124
  ⚠️ The Higuchi model assumes that $c_0 \ge c_s$
125
+
124
126
  #### Applications
125
127
  1. Matrix Tablets
126
128
  2. Hydrophilic polymer matrices
@@ -128,6 +130,26 @@ where:
128
130
  4. Semisolid Systems
129
131
  5. Implantable Drug delivery systems
130
132
 
133
+ ### Weibull
134
+ Weibull model is an empirical model used to describe drug release kinetics from various pharmaceutical dosage forms. It is characterized by a flexible empirical equation that captures various release kinetics.
135
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
136
+
137
+ $$
138
+ M_t = M \left(1 - e^{-at^b}\right)
139
+ $$
140
+
141
+ where:
142
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t$
143
+ - $M (mg)$ is the total amount of drug released at infinite time
144
+ - $a$ is the scale parameter (related to the release rate)
145
+ - $b$ is the shape parameter (indicates the release mechanism)
146
+
147
+ #### Applications
148
+ 1. Controlled-release modeling
149
+ 2. Dissolution profiling
150
+ 3. Comparative studies
151
+ 4. Vivo predictions
152
+
131
153
  ## Usage
132
154
  ### Zero-Order Model
133
155
  ```python
@@ -156,6 +178,16 @@ model.plot(show=True)
156
178
  ```
157
179
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/higuchi_plot.png" alt="Higuchi Plot">
158
180
 
181
+ ### Weibull Model
182
+
183
+ ```python
184
+ from drux import WeibullModel
185
+ model = WeibullModel(M=1, a=0.095, b=0.7)
186
+ model.simulate(duration=100, time_step=1)
187
+ model.plot(show=True)
188
+ ```
189
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
190
+
159
191
  ## Issues & bug reports
160
192
 
161
193
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -176,6 +208,7 @@ You can also join our discord server
176
208
  <blockquote>4- R. Vaju and K. V. Murthy, "Development and validation of new discriminative dissolution method for carvedilol tablets," <i>Indian Journal of Pharmaceutical Sciences</i>, vol. 73, no. 5, pp. 527–536, Sep. 2011.</blockquote>
177
209
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
178
210
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
211
+ <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
179
212
 
180
213
  ## Show your support
181
214
  ### Star this repo
@@ -5,5 +5,6 @@ from .params import DRUX_VERSION
5
5
  from .higuchi import HiguchiModel, HiguchiParameters
6
6
  from .zero_order import ZeroOrderModel, ZeroOrderParameters
7
7
  from .first_order import FirstOrderModel, FirstOrderParameters
8
+ from .weibull import WeibullModel, WeibullParameters
8
9
 
9
10
  __version__ = DRUX_VERSION
@@ -34,6 +34,10 @@ class FirstOrderModel(DrugReleaseModel):
34
34
  self._parameters = FirstOrderParameters(k=k, M0=M0)
35
35
  self._plot_parameters["label"] = "First-Order Model"
36
36
 
37
+ def __repr__(self):
38
+ """Return a string representation of the First-Order model."""
39
+ return f"drux.FirstOrderModel(k={self._parameters.k}, M0={self._parameters.M0})"
40
+
37
41
  def _model_function(self, t: float) -> float:
38
42
  """
39
43
  Calculate the drug release at time t using the first-order model.
@@ -43,6 +43,13 @@ class HiguchiModel(DrugReleaseModel):
43
43
  self._parameters = HiguchiParameters(D=D, c0=c0, cs=cs)
44
44
  self._plot_parameters["label"] = "Higuchi Model"
45
45
 
46
+ def __repr__(self):
47
+ """Return a string representation of the Higuchi model."""
48
+ return (
49
+ f"drux.HiguchiModel(D={self._parameters.D}, "
50
+ f"c0={self._parameters.c0}, cs={self._parameters.cs})"
51
+ )
52
+
46
53
  def _model_function(self, t: float) -> float:
47
54
  """
48
55
  Calculate the drug release at time t using the Higuchi model.
@@ -32,3 +32,10 @@ ERROR_FIRST_ORDER_RELEASE_RATE = "Release rate (k) must be non-negative."
32
32
  ERROR_FIRST_ORDER_INITIAL_AMOUNT = (
33
33
  "Entire releasable amount of drug (M0) must be non-negative."
34
34
  )
35
+
36
+ # Error messages for Weibull
37
+ ERROR_WEIBULL_SCALE_PARAMETER = "Scale parameter (a) must be positive."
38
+ ERROR_WEIBULL_SHAPE_PARAMETER = "Shape parameter (b) must be positive."
39
+ ERROR_WEIBULL_INITIAL_AMOUNT = (
40
+ "Entire releasable amount of drug (M) must be non-negative."
41
+ )
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Drux parameters and constants."""
3
3
 
4
- DRUX_VERSION = "0.2"
4
+ DRUX_VERSION = "0.3"
@@ -0,0 +1,72 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Drux Weibull model implementation."""
3
+
4
+ from .base_model import DrugReleaseModel
5
+ from .messages import (
6
+ ERROR_WEIBULL_SCALE_PARAMETER,
7
+ ERROR_WEIBULL_INITIAL_AMOUNT,
8
+ ERROR_WEIBULL_SHAPE_PARAMETER,
9
+ )
10
+ from dataclasses import dataclass
11
+ from math import exp
12
+
13
+
14
+ @dataclass
15
+ class WeibullParameters:
16
+ """
17
+ Parameters for the Weibull model based on physical formulation.
18
+
19
+ Attributes:
20
+ M (float): entire releasable amount of drug (normally M > 0) (mg)
21
+ a (float): scale factor
22
+ b (float): shape factor
23
+ """
24
+
25
+ M: float
26
+ a: float
27
+ b: float
28
+
29
+
30
+ class WeibullModel(DrugReleaseModel):
31
+ """Simulator for the Weibull drug release model using analytical expressions based on concentration conditions."""
32
+
33
+ def __init__(self, M: float, a: float, b: float) -> None:
34
+ """
35
+ Initialize the Weibull model with the given parameters.
36
+
37
+ :param M: entire releasable amount of drug (normally M > 0) (mg)
38
+ :param a: scale factor
39
+ :param b: shape factor
40
+ """
41
+ super().__init__()
42
+ self._parameters = WeibullParameters(M=M, a=a, b=b)
43
+ self._plot_parameters["label"] = "Weibull Model"
44
+
45
+ def __repr__(self):
46
+ """Return a string representation of the Weibull model."""
47
+ return f"drux.WeibullModel(M={self._parameters.M}, a={self._parameters.a}, b={self._parameters.b})"
48
+
49
+ def _model_function(self, t: float) -> float:
50
+ """
51
+ Calculate the drug release at time t using the Weibull model.
52
+
53
+ Formula:
54
+ - General case: Mt = M * (1 - exp(-a*t ** b))
55
+ :param t: time (s)
56
+ """
57
+ M = self._parameters.M
58
+ a = self._parameters.a
59
+ b = self._parameters.b
60
+
61
+ Mt = M * (1 - exp(-a * t**b))
62
+
63
+ return Mt
64
+
65
+ def _validate_parameters(self) -> None:
66
+ """Validate the parameters of the Weibull model."""
67
+ if self._parameters.M < 0:
68
+ raise ValueError(ERROR_WEIBULL_INITIAL_AMOUNT)
69
+ if self._parameters.a <= 0:
70
+ raise ValueError(ERROR_WEIBULL_SCALE_PARAMETER)
71
+ if self._parameters.b <= 0:
72
+ raise ValueError(ERROR_WEIBULL_SHAPE_PARAMETER)
@@ -34,6 +34,10 @@ class ZeroOrderModel(DrugReleaseModel):
34
34
  self._parameters = ZeroOrderParameters(k0=k0, M0=M0)
35
35
  self._plot_parameters["label"] = "Zero-Order Model"
36
36
 
37
+ def __repr__(self):
38
+ """Return a string representation of the Zero-Order model."""
39
+ return f"drux.ZeroOrderModel(k0={self._parameters.k0}, M0={self._parameters.M0})"
40
+
37
41
  def _model_function(self, t: float) -> float:
38
42
  """
39
43
  Calculate the drug release at time t using the zero-order model.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drux
3
- Version: 0.2
3
+ Version: 0.3
4
4
  Summary: Drux: Drug Release Analysis Framework
5
5
  Home-page: https://github.com/openscilab/drux
6
- Download-URL: https://github.com/openscilab/drux/tarball/v0.2
6
+ Download-URL: https://github.com/openscilab/drux/tarball/v0.3
7
7
  Author: Drux Development Team
8
8
  Author-email: drux@openscilab.com
9
9
  License: MIT
@@ -20,6 +20,7 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
23
24
  Classifier: Intended Audience :: Developers
24
25
  Classifier: Intended Audience :: Education
25
26
  Classifier: Intended Audience :: End Users/Desktop
@@ -53,6 +54,7 @@ Dynamic: summary
53
54
 
54
55
 
55
56
  <div align="center">
57
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/logo.png" width="350">
56
58
  <h1>Drux: Drug Release Analysis Framework</h1>
57
59
  <br/>
58
60
  <a href="https://badge.fury.io/py/drux"><img src="https://badge.fury.io/py/drux.svg" alt="PyPI version"></a>
@@ -116,9 +118,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
116
118
 
117
119
  ### PyPI
118
120
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
119
- - Run `pip install drux==0.2`
121
+ - Run `pip install drux==0.3`
120
122
  ### Source code
121
- - Download [Version 0.2](https://github.com/openscilab/drux/archive/v0.2.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
123
+ - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
122
124
  - Run `pip install .`
123
125
 
124
126
  ## Supported Models
@@ -175,6 +177,7 @@ where:
175
177
  - $c_s (\frac{mg}{cm^3})$ is the solubility of the drug in the polymer (carrier)
176
178
 
177
179
  ⚠️ The Higuchi model assumes that $c_0 \ge c_s$
180
+
178
181
  #### Applications
179
182
  1. Matrix Tablets
180
183
  2. Hydrophilic polymer matrices
@@ -182,6 +185,26 @@ where:
182
185
  4. Semisolid Systems
183
186
  5. Implantable Drug delivery systems
184
187
 
188
+ ### Weibull
189
+ Weibull model is an empirical model used to describe drug release kinetics from various pharmaceutical dosage forms. It is characterized by a flexible empirical equation that captures various release kinetics.
190
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
191
+
192
+ $$
193
+ M_t = M \left(1 - e^{-at^b}\right)
194
+ $$
195
+
196
+ where:
197
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t$
198
+ - $M (mg)$ is the total amount of drug released at infinite time
199
+ - $a$ is the scale parameter (related to the release rate)
200
+ - $b$ is the shape parameter (indicates the release mechanism)
201
+
202
+ #### Applications
203
+ 1. Controlled-release modeling
204
+ 2. Dissolution profiling
205
+ 3. Comparative studies
206
+ 4. Vivo predictions
207
+
185
208
  ## Usage
186
209
  ### Zero-Order Model
187
210
  ```python
@@ -210,6 +233,16 @@ model.plot(show=True)
210
233
  ```
211
234
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/higuchi_plot.png" alt="Higuchi Plot">
212
235
 
236
+ ### Weibull Model
237
+
238
+ ```python
239
+ from drux import WeibullModel
240
+ model = WeibullModel(M=1, a=0.095, b=0.7)
241
+ model.simulate(duration=100, time_step=1)
242
+ model.plot(show=True)
243
+ ```
244
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
245
+
213
246
  ## Issues & bug reports
214
247
 
215
248
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -230,6 +263,7 @@ You can also join our discord server
230
263
  <blockquote>4- R. Vaju and K. V. Murthy, "Development and validation of new discriminative dissolution method for carvedilol tablets," <i>Indian Journal of Pharmaceutical Sciences</i>, vol. 73, no. 5, pp. 527–536, Sep. 2011.</blockquote>
231
264
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
232
265
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
266
+ <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
233
267
 
234
268
  ## Show your support
235
269
  ### Star this repo
@@ -248,6 +282,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
248
282
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
249
283
 
250
284
  ## [Unreleased]
285
+ ## [0.3] - 2025-12-08
286
+ ### Added
287
+ - Weibull model
288
+ - Logo
289
+ - `__repr__` method for models
290
+ ### Changed
291
+ - `Python 3.14` added to `test.yml`
251
292
  ## [0.2] - 2025-09-27
252
293
  ### Added
253
294
  - Zero-order model
@@ -264,6 +305,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
264
305
  - Higuchi model
265
306
 
266
307
 
267
- [Unreleased]: https://github.com/openscilab/drux/compare/v0.2...dev
308
+ [Unreleased]: https://github.com/openscilab/drux/compare/v0.3...dev
309
+ [0.3]: https://github.com/openscilab/drux/compare/v0.2...v0.3
268
310
  [0.2]: https://github.com/openscilab/drux/compare/v0.1...v0.2
269
311
  [0.1]: https://github.com/openscilab/drux/compare/48548f0...v0.1
@@ -8,6 +8,7 @@ drux/first_order.py
8
8
  drux/higuchi.py
9
9
  drux/messages.py
10
10
  drux/params.py
11
+ drux/weibull.py
11
12
  drux/zero_order.py
12
13
  drux.egg-info/PKG-INFO
13
14
  drux.egg-info/SOURCES.txt
@@ -16,4 +17,5 @@ drux.egg-info/requires.txt
16
17
  drux.egg-info/top_level.txt
17
18
  tests/test_first_order.py
18
19
  tests/test_higuchi.py
20
+ tests/test_weibull.py
19
21
  tests/test_zero_order.py
@@ -33,14 +33,14 @@ setup(
33
33
  name='drux',
34
34
  packages=[
35
35
  'drux', ],
36
- version='0.2',
36
+ version='0.3',
37
37
  description='Drux: Drug Release Analysis Framework',
38
38
  long_description=read_description(),
39
39
  long_description_content_type='text/markdown',
40
40
  author='Drux Development Team',
41
41
  author_email='drux@openscilab.com',
42
42
  url='https://github.com/openscilab/drux',
43
- download_url='https://github.com/openscilab/drux/tarball/v0.2',
43
+ download_url='https://github.com/openscilab/drux/tarball/v0.3',
44
44
  keywords="drug-release drug-delivery mathematical-modeling simulation kinetics",
45
45
  project_urls={
46
46
  'Source': 'https://github.com/openscilab/drux',
@@ -59,6 +59,7 @@ setup(
59
59
  'Programming Language :: Python :: 3.11',
60
60
  'Programming Language :: Python :: 3.12',
61
61
  'Programming Language :: Python :: 3.13',
62
+ 'Programming Language :: Python :: 3.14',
62
63
  'Intended Audience :: Developers',
63
64
  'Intended Audience :: Education',
64
65
  'Intended Audience :: End Users/Desktop',
@@ -26,6 +26,12 @@ def test_invalid_parameters():
26
26
  FirstOrderModel(M0=M0, k=-k).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
27
27
 
28
28
 
29
+ def test_repr():
30
+ model = FirstOrderModel(M0=M0, k=k)
31
+ repr_str = repr(model)
32
+ assert repr_str == f"drux.FirstOrderModel(k={k}, M0={M0})"
33
+
34
+
29
35
  def test_first_order_simulation(): # Reference: https://europepmc.org/article/pmc/3425064
30
36
  model = FirstOrderModel(M0=M0, k=k)
31
37
  profile = model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
@@ -115,6 +115,12 @@ def test_higuchi_release_rate_error():
115
115
  model.get_release_rate()
116
116
 
117
117
 
118
+ def test_repr():
119
+ model = HiguchiModel(D=D, c0=C0, cs=CS)
120
+ repr_str = repr(model)
121
+ assert repr_str == f"drux.HiguchiModel(D={D}, c0={C0}, cs={CS})"
122
+
123
+
118
124
  def test_higuchi_time_for_release(): # Reference: https://www.wolframalpha.com/input?i=solve+for+t+in+sqrt%2810%5E%28-6%29*0.5*%282*1.5-0.5%29*t%29+%3D+0.5*sqrt%2810%5E%28-6%29*0.5*%282*1.5-0.5%29*1000%29
119
125
  model = HiguchiModel(D=D, c0=C0, cs=CS)
120
126
  model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
@@ -0,0 +1,141 @@
1
+ """Tests for the Weibull model implementation in drux package."""
2
+
3
+ from pytest import raises
4
+ from numpy import isclose
5
+ from re import escape
6
+ from math import exp
7
+ from drux import WeibullModel
8
+
9
+ TEST_CASE_NAME = "Weibull model tests"
10
+ M, a, b = 1, 0.095, 0.7
11
+ SIM_DURATION, SIM_TIME_STEP = 100, 1
12
+ RELATIVE_TOLERANCE = 1e-1
13
+
14
+
15
+ def test_weibull_parameters():
16
+ model = WeibullModel(M=M, a=a, b=b)
17
+ assert model._parameters.M == M
18
+ assert model._parameters.a == a
19
+ assert model._parameters.b == b
20
+
21
+
22
+ def test_invalid_parameters():
23
+ with raises(ValueError, match=escape("Entire releasable amount of drug (M) must be non-negative.")):
24
+ WeibullModel(M=-M, a=a, b=b).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
25
+
26
+ with raises(ValueError, match=escape("Scale parameter (a) must be positive.")):
27
+ WeibullModel(M=M, a=-a, b=b).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
28
+
29
+ with raises(ValueError, match=escape("Shape parameter (b) must be positive.")):
30
+ WeibullModel(M=M, a=a, b=-b).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
31
+
32
+
33
+ def test_repr():
34
+ model = WeibullModel(M=M, a=a, b=b)
35
+ repr_str = repr(model)
36
+ assert repr_str == f"drux.WeibullModel(M={M}, a={a}, b={b})"
37
+
38
+
39
+ def test_weibull_simulation(): # Reference: https://www.mdpi.com/2073-4360/13/17/2897
40
+ model = WeibullModel(M=M, a=a, b=b)
41
+ profile = model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
42
+ actual_release = [M * (1 - exp(-a * t ** b)) for t in range(0, SIM_DURATION+SIM_TIME_STEP, SIM_TIME_STEP)]
43
+ assert all(isclose(p, r, rtol=RELATIVE_TOLERANCE) for p, r in zip(profile, actual_release))
44
+
45
+
46
+ def test_weibull_simulation_errors():
47
+ model = WeibullModel(M=M, a=a, b=b)
48
+
49
+ with raises(ValueError, match="Duration and time step must be positive values"):
50
+ model.simulate(duration=-100, time_step=10)
51
+
52
+ with raises(ValueError, match="Duration and time step must be positive values"):
53
+ model.simulate(duration=100, time_step=-10)
54
+
55
+ with raises(ValueError, match="Time step cannot be greater than duration"):
56
+ model.simulate(duration=10, time_step=20)
57
+
58
+
59
+ def test_weibull_plot1():
60
+ model = WeibullModel(M=M, a=a, b=b)
61
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
62
+ fig, ax = model.plot()
63
+ assert fig is not None
64
+ assert ax is not None
65
+ assert ax.get_title() == model._plot_parameters["title"]
66
+ assert ax.get_xlabel() == model._plot_parameters["xlabel"]
67
+ assert ax.get_ylabel() == model._plot_parameters["ylabel"]
68
+ assert [text.get_text() for text in ax.get_legend().get_texts()] == [model._plot_parameters["label"]]
69
+
70
+
71
+ def test_weibull_plot2():
72
+ model = WeibullModel(M=M, a=a, b=b)
73
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
74
+ fig, ax = model.plot(title="test-title", xlabel="test-xlabel", ylabel="test-ylabel", label="test-label")
75
+ assert fig is not None
76
+ assert ax is not None
77
+ assert ax.get_title() == "test-title"
78
+ assert ax.get_xlabel() == "test-xlabel"
79
+ assert ax.get_ylabel() == "test-ylabel"
80
+ assert [text.get_text() for text in ax.get_legend().get_texts()] == ["test-label"]
81
+
82
+
83
+ def test_weibull_plot_error():
84
+ model = WeibullModel(M=M, a=a, b=b)
85
+
86
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
87
+ model.plot()
88
+
89
+ model._time_points = [0] # manually set time points to simulate error (TODO: it will be caught with prior errors)
90
+ # manually set a too short profile to simulate error (TODO: it will be caught with prior errors)
91
+ model._release_profile = [0.0]
92
+ with raises(ValueError, match="Release profile is too short to calculate release rate."):
93
+ model.plot()
94
+
95
+
96
+ def test_weibull_release_rate(): # Reference: https://www.wolframalpha.com/input?i=get+the+derivative+of+%28M+*+%281+-+exp%28-+%28%28t+%2F+r%29+**+beta%29%29%29%29+with+respect+to+t
97
+ small_timestep = 0.001 # smaller time step for better accuracy in numerical derivative
98
+ small_duration = 10
99
+ model = WeibullModel(M=M, a=a, b=b)
100
+ model.simulate(duration=small_duration, time_step=small_timestep)
101
+ rate = model.get_release_rate().tolist()
102
+ import numpy as np
103
+ actual_rate = [
104
+ (M*b*a) * t**(b - 1) * exp(-a * t**b)
105
+ for t in np.arange(small_timestep, small_duration + small_timestep, small_timestep)
106
+ ] # avoid t=0 to prevent division by zero
107
+ assert all(isclose(r, ar, rtol=1e-1) for r, ar in zip(rate[2:], actual_rate[1:])) # skip first two points due to numerical derivative inaccuracies
108
+
109
+
110
+ def test_weibull_release_rate_error():
111
+ model = WeibullModel(M=M, a=a, b=b)
112
+
113
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
114
+ model.get_release_rate()
115
+
116
+ model._time_points = [0] # manually set time points to simulate error (TODO: it will be caught with prior errors)
117
+ # manually set a too short profile to simulate error (TODO: it will be caught with prior errors)
118
+ model._release_profile = [0.0]
119
+ with raises(ValueError, match="Release profile is too short to calculate release rate."):
120
+ model.get_release_rate()
121
+
122
+
123
+ def test_weibull_time_for_release(): # Reference: https://www.wolframalpha.com/input?i=solve+for+t+in+%281+-+exp%28-0.095+*+t+**+0.7%29%29+%3D+0.8*0.908
124
+ model = WeibullModel(M=M, a=a, b=b)
125
+ model.simulate(duration=SIM_DURATION, time_step=1)
126
+ tx = model.time_for_release(0.8 * model._release_profile[-1])
127
+ assert isclose(tx, 42, rtol=1e-2)
128
+
129
+
130
+ def test_weibull_time_for_release_error():
131
+ model = WeibullModel(M=M, a=a, b=b)
132
+
133
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
134
+ model.time_for_release(0.5)
135
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
136
+
137
+ with raises(ValueError, match="Target release must be non-negative."):
138
+ model.time_for_release(-0.1)
139
+
140
+ with raises(ValueError, match="Target release exceeds maximum release of the simulated duration."):
141
+ model.time_for_release(model._release_profile[-1] + 0.1)
@@ -26,6 +26,12 @@ def test_invalid_parameters():
26
26
  ZeroOrderModel(M0=M0, k0=-k0).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
27
27
 
28
28
 
29
+ def test_repr():
30
+ model = ZeroOrderModel(M0=M0, k0=k0)
31
+ repr_str = repr(model)
32
+ assert repr_str == f"drux.ZeroOrderModel(k0={k0}, M0={M0})"
33
+
34
+
29
35
  def test_zero_order_simulation(): # Reference: https://europepmc.org/article/pmc/3425064
30
36
  model = ZeroOrderModel(M0=M0, k0=k0)
31
37
  profile = model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes