pyhsp 0.1.0rc1__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.
- pyhsp-0.1.0rc1/.gitignore +52 -0
- pyhsp-0.1.0rc1/LICENSE +21 -0
- pyhsp-0.1.0rc1/PKG-INFO +105 -0
- pyhsp-0.1.0rc1/README.md +80 -0
- pyhsp-0.1.0rc1/pyHSP/__init__.py +9 -0
- pyhsp-0.1.0rc1/pyHSP/_conf.py +5 -0
- pyhsp-0.1.0rc1/pyHSP/_utils.py +120 -0
- pyhsp-0.1.0rc1/pyHSP/data/pla.json +191 -0
- pyhsp-0.1.0rc1/pyHSP/examples.py +22 -0
- pyhsp-0.1.0rc1/pyHSP/functional.py +349 -0
- pyhsp-0.1.0rc1/pyHSP/io.py +269 -0
- pyhsp-0.1.0rc1/pyHSP/pandas.py +285 -0
- pyhsp-0.1.0rc1/pyHSP/solvents.py +265 -0
- pyhsp-0.1.0rc1/pyHSP/sphere.py +1385 -0
- pyhsp-0.1.0rc1/pyHSP/types.py +15 -0
- pyhsp-0.1.0rc1/pyproject.toml +100 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Byte-compiled / optimized files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Virtual environments
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
env/
|
|
10
|
+
ENV/
|
|
11
|
+
|
|
12
|
+
# Packaging
|
|
13
|
+
build/
|
|
14
|
+
dist/
|
|
15
|
+
*.egg-info/
|
|
16
|
+
.eggs/
|
|
17
|
+
wheels/
|
|
18
|
+
|
|
19
|
+
# Test and coverage output
|
|
20
|
+
.pytest_cache/
|
|
21
|
+
.tox/
|
|
22
|
+
.nox/
|
|
23
|
+
.coverage
|
|
24
|
+
.coverage.*
|
|
25
|
+
htmlcov/
|
|
26
|
+
|
|
27
|
+
# Type-checker and linter caches
|
|
28
|
+
.mypy_cache/
|
|
29
|
+
.dmypy.json
|
|
30
|
+
dmypy.json
|
|
31
|
+
.ruff_cache/
|
|
32
|
+
|
|
33
|
+
# Jupyter
|
|
34
|
+
.ipynb_checkpoints/
|
|
35
|
+
|
|
36
|
+
# spyder
|
|
37
|
+
.spyproject/*
|
|
38
|
+
|
|
39
|
+
# Local environment files
|
|
40
|
+
.env
|
|
41
|
+
.env.*
|
|
42
|
+
!.env.example
|
|
43
|
+
|
|
44
|
+
# Editor and operating-system files
|
|
45
|
+
.idea/
|
|
46
|
+
.vscode/
|
|
47
|
+
.DS_Store
|
|
48
|
+
|
|
49
|
+
# Project-specific files
|
|
50
|
+
internal/*
|
|
51
|
+
literature/*
|
|
52
|
+
*.xlsx
|
pyhsp-0.1.0rc1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ChemicalSailor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pyhsp-0.1.0rc1/PKG-INFO
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pyhsp
|
|
3
|
+
Version: 0.1.0rc1
|
|
4
|
+
Summary: Hansen Solubility Parameter (HSP) fitting.
|
|
5
|
+
Project-URL: Documentation, https://github.com/ChemicalSailor/pyHSP#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/ChemicalSailor/pyHSP/issues
|
|
7
|
+
Project-URL: Source, https://github.com/ChemicalSailor/pyHSP
|
|
8
|
+
Author: Tom Fletcher
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: Chemistry,Hansen Solubility,Science,scikit-learn
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Requires-Dist: numpy>=2.3
|
|
21
|
+
Requires-Dist: pandas>=3
|
|
22
|
+
Requires-Dist: scikit-learn>=1.8
|
|
23
|
+
Requires-Dist: scipy>=1.18
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# pyHSP
|
|
27
|
+
pyHSP is a python package for performing fitting of Hansen Solubility Parameters.
|
|
28
|
+
|
|
29
|
+
## About Hansen Solubility Parameters (HSP)
|
|
30
|
+
[Hansen Solubility Parameters](https://en.wikipedia.org/wiki/Hansen_solubility_parameter) provide a methodology for predicting the solubility of a solute in one or more solvents based upon 3 terms, or dimensions, covering dispersion, polar and hydrogen bonding forces; for simplicity we term these dD, dP, and dH respectively. Every chemical has characteristic set of solubility parameters, defining a point in the parameter space. A solute is likely to dissolve in a solvent when the (modified) euclidean distance in the parameter space is small (like dissolves like). A cut-off distance determines if a solute is soluble or not. This is termed the 'solubility radius', as together with the dD, dP, dH terms it defines a solubility sphere.
|
|
31
|
+
|
|
32
|
+
Determining the solubility parameters of a solute is done experimentally. Dissolution trials are conducted in solvents with known solubility parameters, then each sample scored 1 for dissolved, or 0 for not dissolved. We recommend testing at least 12 different solvents. The acquired data is used to fit a sphere that attempts to accurately classify the trialled solvents. With a fitted sphere predictions can be made about the solute solubility in other solvents.
|
|
33
|
+
|
|
34
|
+
HSP has traditionally been applied to polymers, but has been successfully applied to pigments, dispersions and small molecules.
|
|
35
|
+
|
|
36
|
+
## About pyHSP
|
|
37
|
+
The fit and predict method of HSP aligns with machine learning, specifically classification. pyHSP implements a scikit-learn compatible API for fitting solubility spheres. pyHSP has been developed to introduce an alternative fitting strategy and (in the future) provide support for improvements proposed by [Louwerse et al.](https://chemistry-europe.onlinelibrary.wiley.com/doi/full/10.1002/cphc.201700408)
|
|
38
|
+
|
|
39
|
+
The focus of pyHSP is to implement fitting routines. No data is provided, save for minimal examples, and users are expected to source their own solubility parameter data. This may be revised in future versions if and when data is contributed to the repository.
|
|
40
|
+
|
|
41
|
+
### Roadmap
|
|
42
|
+
- [x] Sphere fitting using classic Hansen distance
|
|
43
|
+
- [ ] Support for donor/acceptor split hydrogen bonding term
|
|
44
|
+
- [ ] Support for Louwerse et al. improvements
|
|
45
|
+
- [ ] Visualisation
|
|
46
|
+
|
|
47
|
+
### License
|
|
48
|
+
This software is licensed under the MIT license.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
Eager beavers can check out the repository.
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
The main entry point is the `ClassicSphere` class, which is a scikit-learn classifier:
|
|
55
|
+
```
|
|
56
|
+
from pyHSP import ClassicSphere
|
|
57
|
+
|
|
58
|
+
X = ... # a 2D array-like of trial solvent HSPs, ordered dD, dP, dH
|
|
59
|
+
y = ... # solubility scores for each trial solvent; 1 = soluble, 0 = insoluble
|
|
60
|
+
|
|
61
|
+
sphere = ClassicSphere().fit(X, y)
|
|
62
|
+
|
|
63
|
+
# Fitted solubility parameters are accessed on the coefs_ attribute
|
|
64
|
+
sphere.coefs_
|
|
65
|
+
|
|
66
|
+
predictions = sphere.predict( X_other ) # predicted binary solubility
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
It is often convenient to tabulate solvent HSPs and scores in a single dataframe.
|
|
70
|
+
The pyHSP convention is to label the respective columns 'dD', 'dP', 'dH' and 'Score'.
|
|
71
|
+
HSPEstimators have a `pd` attribute for conveniently handling such dataframes:
|
|
72
|
+
```
|
|
73
|
+
import pandas as pd
|
|
74
|
+
|
|
75
|
+
data_with_scores = pd.DataFrame(..., columns=['dD, 'dP', 'dH', 'Score'])
|
|
76
|
+
|
|
77
|
+
# use the pd accessor
|
|
78
|
+
sphere.pd.fit(data_with_scores) # returns sphere
|
|
79
|
+
|
|
80
|
+
predictions = sphere.pd.predict(data_with_scores) # returns pd.Series
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
See [Introduction.ipynb](examples/Introduction.ipynb) for a more detailed introduction with real data.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Comparison with HSPiP
|
|
87
|
+
[HSPiP](https://www.hansen-solubility.com/) is commercially available software for working with Hansen Solubility Parameters; aside from fitting there are a host of other useful features. pyHSP is not associated with HSPiP in any way.
|
|
88
|
+
|
|
89
|
+
pyHSP has been validated against HSPiP using the Polymer88 dataset shipped with HSPiP, achieving broadly the same fitted sphere coefficients and classification scores; HSPiP achieved an average F1 classification score of _ and pyHSP achieved an average score of _:
|
|
90
|
+

|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## Contributing
|
|
95
|
+
Contributions are welcome and do not just have to be code.
|
|
96
|
+
|
|
97
|
+
### Feedback
|
|
98
|
+
If you encounter any problems or have suggestions for improvement please raise an issue on github. Positive feedback is also gladly appreciated.
|
|
99
|
+
|
|
100
|
+
### Data
|
|
101
|
+
If you have data that you would be willing to provide to the project please raise an issue on github. Data may include solubility parameters for chemicals that could be provided in a database, or experimental solubility data that could be used for testing pyHSP or providing an enhanced set of examples. Please ensure you have the appropriate permissions to share such data with us.
|
|
102
|
+
|
|
103
|
+
### Code
|
|
104
|
+
Pull requests that address an outstanding issue will be reviewed on a case-by-case basis.
|
|
105
|
+
|
pyhsp-0.1.0rc1/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# pyHSP
|
|
2
|
+
pyHSP is a python package for performing fitting of Hansen Solubility Parameters.
|
|
3
|
+
|
|
4
|
+
## About Hansen Solubility Parameters (HSP)
|
|
5
|
+
[Hansen Solubility Parameters](https://en.wikipedia.org/wiki/Hansen_solubility_parameter) provide a methodology for predicting the solubility of a solute in one or more solvents based upon 3 terms, or dimensions, covering dispersion, polar and hydrogen bonding forces; for simplicity we term these dD, dP, and dH respectively. Every chemical has characteristic set of solubility parameters, defining a point in the parameter space. A solute is likely to dissolve in a solvent when the (modified) euclidean distance in the parameter space is small (like dissolves like). A cut-off distance determines if a solute is soluble or not. This is termed the 'solubility radius', as together with the dD, dP, dH terms it defines a solubility sphere.
|
|
6
|
+
|
|
7
|
+
Determining the solubility parameters of a solute is done experimentally. Dissolution trials are conducted in solvents with known solubility parameters, then each sample scored 1 for dissolved, or 0 for not dissolved. We recommend testing at least 12 different solvents. The acquired data is used to fit a sphere that attempts to accurately classify the trialled solvents. With a fitted sphere predictions can be made about the solute solubility in other solvents.
|
|
8
|
+
|
|
9
|
+
HSP has traditionally been applied to polymers, but has been successfully applied to pigments, dispersions and small molecules.
|
|
10
|
+
|
|
11
|
+
## About pyHSP
|
|
12
|
+
The fit and predict method of HSP aligns with machine learning, specifically classification. pyHSP implements a scikit-learn compatible API for fitting solubility spheres. pyHSP has been developed to introduce an alternative fitting strategy and (in the future) provide support for improvements proposed by [Louwerse et al.](https://chemistry-europe.onlinelibrary.wiley.com/doi/full/10.1002/cphc.201700408)
|
|
13
|
+
|
|
14
|
+
The focus of pyHSP is to implement fitting routines. No data is provided, save for minimal examples, and users are expected to source their own solubility parameter data. This may be revised in future versions if and when data is contributed to the repository.
|
|
15
|
+
|
|
16
|
+
### Roadmap
|
|
17
|
+
- [x] Sphere fitting using classic Hansen distance
|
|
18
|
+
- [ ] Support for donor/acceptor split hydrogen bonding term
|
|
19
|
+
- [ ] Support for Louwerse et al. improvements
|
|
20
|
+
- [ ] Visualisation
|
|
21
|
+
|
|
22
|
+
### License
|
|
23
|
+
This software is licensed under the MIT license.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
Eager beavers can check out the repository.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
The main entry point is the `ClassicSphere` class, which is a scikit-learn classifier:
|
|
30
|
+
```
|
|
31
|
+
from pyHSP import ClassicSphere
|
|
32
|
+
|
|
33
|
+
X = ... # a 2D array-like of trial solvent HSPs, ordered dD, dP, dH
|
|
34
|
+
y = ... # solubility scores for each trial solvent; 1 = soluble, 0 = insoluble
|
|
35
|
+
|
|
36
|
+
sphere = ClassicSphere().fit(X, y)
|
|
37
|
+
|
|
38
|
+
# Fitted solubility parameters are accessed on the coefs_ attribute
|
|
39
|
+
sphere.coefs_
|
|
40
|
+
|
|
41
|
+
predictions = sphere.predict( X_other ) # predicted binary solubility
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
It is often convenient to tabulate solvent HSPs and scores in a single dataframe.
|
|
45
|
+
The pyHSP convention is to label the respective columns 'dD', 'dP', 'dH' and 'Score'.
|
|
46
|
+
HSPEstimators have a `pd` attribute for conveniently handling such dataframes:
|
|
47
|
+
```
|
|
48
|
+
import pandas as pd
|
|
49
|
+
|
|
50
|
+
data_with_scores = pd.DataFrame(..., columns=['dD, 'dP', 'dH', 'Score'])
|
|
51
|
+
|
|
52
|
+
# use the pd accessor
|
|
53
|
+
sphere.pd.fit(data_with_scores) # returns sphere
|
|
54
|
+
|
|
55
|
+
predictions = sphere.pd.predict(data_with_scores) # returns pd.Series
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
See [Introduction.ipynb](examples/Introduction.ipynb) for a more detailed introduction with real data.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Comparison with HSPiP
|
|
62
|
+
[HSPiP](https://www.hansen-solubility.com/) is commercially available software for working with Hansen Solubility Parameters; aside from fitting there are a host of other useful features. pyHSP is not associated with HSPiP in any way.
|
|
63
|
+
|
|
64
|
+
pyHSP has been validated against HSPiP using the Polymer88 dataset shipped with HSPiP, achieving broadly the same fitted sphere coefficients and classification scores; HSPiP achieved an average F1 classification score of _ and pyHSP achieved an average score of _:
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
## Contributing
|
|
70
|
+
Contributions are welcome and do not just have to be code.
|
|
71
|
+
|
|
72
|
+
### Feedback
|
|
73
|
+
If you encounter any problems or have suggestions for improvement please raise an issue on github. Positive feedback is also gladly appreciated.
|
|
74
|
+
|
|
75
|
+
### Data
|
|
76
|
+
If you have data that you would be willing to provide to the project please raise an issue on github. Data may include solubility parameters for chemicals that could be provided in a database, or experimental solubility data that could be used for testing pyHSP or providing an enhanced set of examples. Please ensure you have the appropriate permissions to share such data with us.
|
|
77
|
+
|
|
78
|
+
### Code
|
|
79
|
+
Pull requests that address an outstanding issue will be reviewed on a case-by-case basis.
|
|
80
|
+
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
# import matplotlib.pyplot as plt
|
|
7
|
+
# import os
|
|
8
|
+
# import argparse
|
|
9
|
+
|
|
10
|
+
from typing import Callable, Concatenate, overload
|
|
11
|
+
from numpy.typing import ArrayLike, NDArray
|
|
12
|
+
from sklearn.utils import check_array as _skl_check_array, check_consistent_length
|
|
13
|
+
from functools import wraps
|
|
14
|
+
|
|
15
|
+
from ._conf import BETA_MAX
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def check_X(
|
|
19
|
+
X: ArrayLike, *, n_features: int = 3, min_samples: int = 1, estimator=None
|
|
20
|
+
) -> NDArray[np.floating]:
|
|
21
|
+
"""Check that X is a valid array with the specified minimum features and samples."""
|
|
22
|
+
X_ = _skl_check_array(
|
|
23
|
+
X,
|
|
24
|
+
ensure_2d=True,
|
|
25
|
+
allow_nd=False,
|
|
26
|
+
ensure_all_finite=True,
|
|
27
|
+
accept_sparse=False,
|
|
28
|
+
ensure_min_samples=min_samples,
|
|
29
|
+
ensure_non_negative=True,
|
|
30
|
+
estimator=estimator,
|
|
31
|
+
input_name="X",
|
|
32
|
+
)
|
|
33
|
+
if X_.shape[1] != n_features:
|
|
34
|
+
raise ValueError(f"X must have exactly {n_features} features.")
|
|
35
|
+
return X_
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def check_y(
|
|
39
|
+
y: ArrayLike, *, graded: bool = False, min_samples: int = 1, estimator=None
|
|
40
|
+
) -> NDArray[np.floating]:
|
|
41
|
+
"""Check scores are either 0 or 1, or between 0 and 1 (inclusive) for graded scoring."""
|
|
42
|
+
y_ = _skl_check_array(
|
|
43
|
+
y,
|
|
44
|
+
ensure_2d=False,
|
|
45
|
+
allow_nd=False,
|
|
46
|
+
ensure_all_finite=True,
|
|
47
|
+
accept_sparse=False,
|
|
48
|
+
ensure_min_samples=min_samples,
|
|
49
|
+
estimator=estimator,
|
|
50
|
+
input_name="y",
|
|
51
|
+
)
|
|
52
|
+
if y_.ndim != 1:
|
|
53
|
+
raise ValueError("y must be a 1-dimensional array.")
|
|
54
|
+
if not graded and not np.all((y_ == 1) + (y_ == 0)):
|
|
55
|
+
raise ValueError(
|
|
56
|
+
"Invalid score values for non-graded fit. All score "
|
|
57
|
+
"values must be 0 or 1."
|
|
58
|
+
)
|
|
59
|
+
if np.any((y_ > 1) + (y_ < 0)):
|
|
60
|
+
raise ValueError(
|
|
61
|
+
"Invalid score values. All scores must be between 0 and 1 inclusive."
|
|
62
|
+
)
|
|
63
|
+
return y_
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def check_X_y(
|
|
67
|
+
X: ArrayLike,
|
|
68
|
+
y: ArrayLike,
|
|
69
|
+
*,
|
|
70
|
+
n_features: int = 3,
|
|
71
|
+
min_samples: int = 1,
|
|
72
|
+
graded: bool = False,
|
|
73
|
+
estimator=None,
|
|
74
|
+
) -> tuple[NDArray[np.floating], NDArray[np.floating]]:
|
|
75
|
+
|
|
76
|
+
X_ = check_X(X, n_features=n_features, min_samples=min_samples, estimator=estimator)
|
|
77
|
+
y_ = check_y(y, graded=graded, min_samples=min_samples, estimator=estimator)
|
|
78
|
+
check_consistent_length(X_, y_)
|
|
79
|
+
|
|
80
|
+
return X_, y_
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def check_beta(beta: int | float) -> float:
|
|
84
|
+
"""Check that beta is a valid float."""
|
|
85
|
+
if not isinstance(beta, (int, float)):
|
|
86
|
+
raise TypeError("beta must be a float.")
|
|
87
|
+
if beta <= 0 or beta > BETA_MAX:
|
|
88
|
+
raise ValueError(
|
|
89
|
+
f"beta must be a float greater than 0 and less than or equal to {BETA_MAX}."
|
|
90
|
+
)
|
|
91
|
+
return float(beta)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# def validates_dataframe(func) -> Callable:
|
|
95
|
+
# """Decorator to validate that the input is a pandas dataframe."""
|
|
96
|
+
|
|
97
|
+
# @wraps(func)
|
|
98
|
+
# def wrapper(self, X, *args, **kwargs) -> pd.DataFrame | np.ndarray:
|
|
99
|
+
# if isinstance(X, pd.DataFrame):
|
|
100
|
+
# X = validate_dataframe(X)
|
|
101
|
+
# return func(self, X, *args, **kwargs)
|
|
102
|
+
|
|
103
|
+
# return wrapper
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def keep_index[_Self, **P](
|
|
107
|
+
func: Callable[Concatenate[_Self, ArrayLike, P], NDArray],
|
|
108
|
+
) -> Callable[Concatenate[_Self, ArrayLike, P], pd.Series | NDArray]:
|
|
109
|
+
"""Decorator to output a series if input is a dataframe."""
|
|
110
|
+
|
|
111
|
+
@wraps(func)
|
|
112
|
+
def wrapper(
|
|
113
|
+
self: _Self, X: ArrayLike, *args: P.args, **kwargs: P.kwargs
|
|
114
|
+
) -> pd.Series | NDArray:
|
|
115
|
+
result = func(self, np.asarray(X), *args, **kwargs)
|
|
116
|
+
if isinstance(X, pd.DataFrame):
|
|
117
|
+
return pd.Series(result, index=X.index)
|
|
118
|
+
return result
|
|
119
|
+
|
|
120
|
+
return wrapper
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Pyridine":{
|
|
3
|
+
"dD":19.0,
|
|
4
|
+
"dP":8.8,
|
|
5
|
+
"dH":5.9,
|
|
6
|
+
"MVol":80.9,
|
|
7
|
+
"Score":1.0
|
|
8
|
+
},
|
|
9
|
+
"N-Methyl-2-Pyrrolidone (NMP)":{
|
|
10
|
+
"dD":18.0,
|
|
11
|
+
"dP":12.3,
|
|
12
|
+
"dH":7.2,
|
|
13
|
+
"MVol":96.6,
|
|
14
|
+
"Score":1.0
|
|
15
|
+
},
|
|
16
|
+
"Methylene Dichloride (Dichloromethane)":{
|
|
17
|
+
"dD":17.0,
|
|
18
|
+
"dP":7.3,
|
|
19
|
+
"dH":7.1,
|
|
20
|
+
"MVol":64.4,
|
|
21
|
+
"Score":1.0
|
|
22
|
+
},
|
|
23
|
+
"1,3-Dioxolane":{
|
|
24
|
+
"dD":18.1,
|
|
25
|
+
"dP":6.6,
|
|
26
|
+
"dH":9.3,
|
|
27
|
+
"MVol":69.9,
|
|
28
|
+
"Score":1.0
|
|
29
|
+
},
|
|
30
|
+
"Methyl Ethyl Ketone (MEK)":{
|
|
31
|
+
"dD":16.0,
|
|
32
|
+
"dP":9.0,
|
|
33
|
+
"dH":5.1,
|
|
34
|
+
"MVol":90.2,
|
|
35
|
+
"Score":1.0
|
|
36
|
+
},
|
|
37
|
+
"Tetrahydrofuran (THF)":{
|
|
38
|
+
"dD":16.8,
|
|
39
|
+
"dP":5.7,
|
|
40
|
+
"dH":8.0,
|
|
41
|
+
"MVol":81.9,
|
|
42
|
+
"Score":1.0
|
|
43
|
+
},
|
|
44
|
+
"Chloroform":{
|
|
45
|
+
"dD":17.8,
|
|
46
|
+
"dP":3.1,
|
|
47
|
+
"dH":5.7,
|
|
48
|
+
"MVol":80.5,
|
|
49
|
+
"Score":1.0
|
|
50
|
+
},
|
|
51
|
+
"Acetone":{
|
|
52
|
+
"dD":15.5,
|
|
53
|
+
"dP":10.4,
|
|
54
|
+
"dH":7.0,
|
|
55
|
+
"MVol":73.8,
|
|
56
|
+
"Score":1.0
|
|
57
|
+
},
|
|
58
|
+
"Dimethyl Formamide (DMF)":{
|
|
59
|
+
"dD":17.4,
|
|
60
|
+
"dP":13.7,
|
|
61
|
+
"dH":11.3,
|
|
62
|
+
"MVol":77.4,
|
|
63
|
+
"Score":1.0
|
|
64
|
+
},
|
|
65
|
+
"Dimethyl Sulfoxide (DMSO)":{
|
|
66
|
+
"dD":18.4,
|
|
67
|
+
"dP":16.4,
|
|
68
|
+
"dH":10.2,
|
|
69
|
+
"MVol":71.3,
|
|
70
|
+
"Score":1.0
|
|
71
|
+
},
|
|
72
|
+
"1,4-Dioxane":{
|
|
73
|
+
"dD":17.5,
|
|
74
|
+
"dP":1.8,
|
|
75
|
+
"dH":9.0,
|
|
76
|
+
"MVol":85.7,
|
|
77
|
+
"Score":1.0
|
|
78
|
+
},
|
|
79
|
+
"Ethyl Acetate":{
|
|
80
|
+
"dD":15.8,
|
|
81
|
+
"dP":5.3,
|
|
82
|
+
"dH":7.2,
|
|
83
|
+
"MVol":98.6,
|
|
84
|
+
"Score":1.0
|
|
85
|
+
},
|
|
86
|
+
"Furan":{
|
|
87
|
+
"dD":17.0,
|
|
88
|
+
"dP":1.8,
|
|
89
|
+
"dH":5.3,
|
|
90
|
+
"MVol":73.1,
|
|
91
|
+
"Score":1.0
|
|
92
|
+
},
|
|
93
|
+
"m-Cresol":{
|
|
94
|
+
"dD":18.5,
|
|
95
|
+
"dP":6.5,
|
|
96
|
+
"dH":13.7,
|
|
97
|
+
"MVol":105.0,
|
|
98
|
+
"Score":1.0
|
|
99
|
+
},
|
|
100
|
+
"Toluene":{
|
|
101
|
+
"dD":18.0,
|
|
102
|
+
"dP":1.4,
|
|
103
|
+
"dH":2.0,
|
|
104
|
+
"MVol":106.6,
|
|
105
|
+
"Score":1.0
|
|
106
|
+
},
|
|
107
|
+
"p-Xylene":{
|
|
108
|
+
"dD":17.8,
|
|
109
|
+
"dP":1.0,
|
|
110
|
+
"dH":3.1,
|
|
111
|
+
"MVol":121.1,
|
|
112
|
+
"Score":1.0
|
|
113
|
+
},
|
|
114
|
+
"Benzene":{
|
|
115
|
+
"dD":18.4,
|
|
116
|
+
"dP":0.0,
|
|
117
|
+
"dH":2.0,
|
|
118
|
+
"MVol":89.5,
|
|
119
|
+
"Score":1.0
|
|
120
|
+
},
|
|
121
|
+
"Hexafluoro Isopropanol":{
|
|
122
|
+
"dD":17.2,
|
|
123
|
+
"dP":4.5,
|
|
124
|
+
"dH":14.7,
|
|
125
|
+
"MVol":105.3,
|
|
126
|
+
"Score":1.0
|
|
127
|
+
},
|
|
128
|
+
"Isoamyl Alcohol (3-Methyl-1-Butanol)":{
|
|
129
|
+
"dD":15.8,
|
|
130
|
+
"dP":5.2,
|
|
131
|
+
"dH":13.3,
|
|
132
|
+
"MVol":109.3,
|
|
133
|
+
"Score":1.0
|
|
134
|
+
},
|
|
135
|
+
"Acetonitrile":{
|
|
136
|
+
"dD":15.3,
|
|
137
|
+
"dP":18.0,
|
|
138
|
+
"dH":6.1,
|
|
139
|
+
"MVol":52.9,
|
|
140
|
+
"Score":0.0
|
|
141
|
+
},
|
|
142
|
+
"Diethyl Ether":{
|
|
143
|
+
"dD":14.5,
|
|
144
|
+
"dP":2.9,
|
|
145
|
+
"dH":4.6,
|
|
146
|
+
"MVol":104.7,
|
|
147
|
+
"Score":0.0
|
|
148
|
+
},
|
|
149
|
+
"Cyclohexane":{
|
|
150
|
+
"dD":16.8,
|
|
151
|
+
"dP":0.0,
|
|
152
|
+
"dH":0.2,
|
|
153
|
+
"MVol":108.9,
|
|
154
|
+
"Score":0.0
|
|
155
|
+
},
|
|
156
|
+
"Isopropyl Ether":{
|
|
157
|
+
"dD":15.1,
|
|
158
|
+
"dP":3.2,
|
|
159
|
+
"dH":3.2,
|
|
160
|
+
"MVol":141.8,
|
|
161
|
+
"Score":0.0
|
|
162
|
+
},
|
|
163
|
+
"Hexane":{
|
|
164
|
+
"dD":14.9,
|
|
165
|
+
"dP":0.0,
|
|
166
|
+
"dH":0.0,
|
|
167
|
+
"MVol":131.4,
|
|
168
|
+
"Score":0.0
|
|
169
|
+
},
|
|
170
|
+
"Ethanol":{
|
|
171
|
+
"dD":15.8,
|
|
172
|
+
"dP":8.8,
|
|
173
|
+
"dH":19.4,
|
|
174
|
+
"MVol":58.6,
|
|
175
|
+
"Score":0.0
|
|
176
|
+
},
|
|
177
|
+
"Methanol":{
|
|
178
|
+
"dD":14.7,
|
|
179
|
+
"dP":12.3,
|
|
180
|
+
"dH":22.3,
|
|
181
|
+
"MVol":40.6,
|
|
182
|
+
"Score":0.0
|
|
183
|
+
},
|
|
184
|
+
"Water":{
|
|
185
|
+
"dD":15.5,
|
|
186
|
+
"dP":16.0,
|
|
187
|
+
"dH":42.3,
|
|
188
|
+
"MVol":18.0,
|
|
189
|
+
"Score":0.0
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
# prgma: no cover
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from .io import read_json
|
|
7
|
+
|
|
8
|
+
DATA_DIR = Path(__file__).parent / "data"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def load_pla():
|
|
12
|
+
"""
|
|
13
|
+
Load polylatic acid (PLA) example.
|
|
14
|
+
|
|
15
|
+
Returns a dataframe with 'dD', 'dP' and 'dH' columns and a series of binary scores
|
|
16
|
+
(1 for soluble, 0 for insoluble).
|
|
17
|
+
|
|
18
|
+
This data was published on the `HSPiP website
|
|
19
|
+
<https://hansen-solubility.com/HSP-science/sphere.php>`__ (accessed Nov 2026).
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
return read_json(DATA_DIR / "pla.json")
|