chemotools 0.0.27__py3-none-any.whl → 0.1.6__py3-none-any.whl

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.
Files changed (53) hide show
  1. chemotools/augmentation/__init__.py +16 -0
  2. chemotools/augmentation/baseline_shift.py +119 -0
  3. chemotools/augmentation/exponential_noise.py +117 -0
  4. chemotools/augmentation/index_shift.py +120 -0
  5. chemotools/augmentation/normal_noise.py +118 -0
  6. chemotools/augmentation/spectrum_scale.py +120 -0
  7. chemotools/augmentation/uniform_noise.py +124 -0
  8. chemotools/baseline/__init__.py +20 -8
  9. chemotools/baseline/{air_pls.py → _air_pls.py} +20 -32
  10. chemotools/baseline/{ar_pls.py → _ar_pls.py} +18 -31
  11. chemotools/baseline/{constant_baseline_correction.py → _constant_baseline_correction.py} +22 -30
  12. chemotools/baseline/{cubic_spline_correction.py → _cubic_spline_correction.py} +26 -19
  13. chemotools/baseline/{linear_correction.py → _linear_correction.py} +19 -28
  14. chemotools/baseline/{non_negative.py → _non_negative.py} +15 -23
  15. chemotools/baseline/{polynomial_correction.py → _polynomial_correction.py} +29 -31
  16. chemotools/baseline/{subtract_reference.py → _subtract_reference.py} +23 -27
  17. chemotools/datasets/__init__.py +3 -0
  18. chemotools/datasets/_base.py +85 -15
  19. chemotools/datasets/data/coffee_labels.csv +61 -0
  20. chemotools/datasets/data/coffee_spectra.csv +61 -0
  21. chemotools/derivative/__init__.py +4 -2
  22. chemotools/derivative/{norris_william.py → _norris_william.py} +17 -24
  23. chemotools/derivative/{savitzky_golay.py → _savitzky_golay.py} +26 -36
  24. chemotools/feature_selection/__init__.py +4 -0
  25. chemotools/{variable_selection/select_features.py → feature_selection/_index_selector.py} +32 -56
  26. chemotools/{variable_selection/range_cut.py → feature_selection/_range_cut.py} +25 -50
  27. chemotools/scale/__init__.py +5 -3
  28. chemotools/scale/{min_max_scaler.py → _min_max_scaler.py} +20 -27
  29. chemotools/scale/{norm_scaler.py → _norm_scaler.py} +18 -25
  30. chemotools/scale/{point_scaler.py → _point_scaler.py} +27 -32
  31. chemotools/scatter/__init__.py +13 -4
  32. chemotools/scatter/{extended_multiplicative_scatter_correction.py → _extended_multiplicative_scatter_correction.py} +19 -28
  33. chemotools/scatter/{multiplicative_scatter_correction.py → _multiplicative_scatter_correction.py} +19 -17
  34. chemotools/scatter/{robust_normal_variate.py → _robust_normal_variate.py} +15 -23
  35. chemotools/scatter/{standard_normal_variate.py → _standard_normal_variate.py} +21 -26
  36. chemotools/smooth/__init__.py +6 -4
  37. chemotools/smooth/{mean_filter.py → _mean_filter.py} +18 -25
  38. chemotools/smooth/{median_filter.py → _median_filter.py} +32 -24
  39. chemotools/smooth/{savitzky_golay_filter.py → _savitzky_golay_filter.py} +22 -24
  40. chemotools/smooth/{whittaker_smooth.py → _whittaker_smooth.py} +24 -29
  41. {chemotools-0.0.27.dist-info → chemotools-0.1.6.dist-info}/METADATA +19 -16
  42. chemotools-0.1.6.dist-info/RECORD +51 -0
  43. {chemotools-0.0.27.dist-info → chemotools-0.1.6.dist-info}/WHEEL +1 -2
  44. chemotools/utils/check_inputs.py +0 -14
  45. chemotools/variable_selection/__init__.py +0 -2
  46. chemotools-0.0.27.dist-info/RECORD +0 -49
  47. chemotools-0.0.27.dist-info/top_level.txt +0 -2
  48. tests/__init__.py +0 -0
  49. tests/fixtures.py +0 -89
  50. tests/test_datasets.py +0 -30
  51. tests/test_functionality.py +0 -616
  52. tests/test_sklearn_compliance.py +0 -220
  53. {chemotools-0.0.27.dist-info → chemotools-0.1.6.dist-info}/LICENSE +0 -0
@@ -1,12 +1,12 @@
1
+ from typing import Literal
2
+
1
3
  import numpy as np
2
4
  from scipy.signal import savgol_filter
3
5
  from sklearn.base import BaseEstimator, TransformerMixin, OneToOneFeatureMixin
4
- from sklearn.utils.validation import check_is_fitted
5
-
6
- from chemotools.utils.check_inputs import check_input
6
+ from sklearn.utils.validation import check_is_fitted, validate_data
7
7
 
8
8
 
9
- class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
9
+ class SavitzkyGolayFilter(TransformerMixin, OneToOneFeatureMixin, BaseEstimator):
10
10
  """
11
11
  A transformer that calculates the Savitzky-Golay filter of the input data.
12
12
 
@@ -24,14 +24,6 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
24
24
  The mode to use for the Savitzky-Golay filter. Can be "nearest", "constant",
25
25
  "reflect", "wrap", "mirror" or "interp". Default is "nearest".
26
26
 
27
- Attributes
28
- ----------
29
- n_features_in_ : int
30
- The number of features in the input data.
31
-
32
- _is_fitted : bool
33
- Whether the transformer has been fitted to data.
34
-
35
27
  Methods
36
28
  -------
37
29
  fit(X, y=None)
@@ -40,8 +32,12 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
40
32
  transform(X, y=0, copy=True)
41
33
  Transform the input data by calculating the Savitzky-Golay filter.
42
34
  """
35
+
43
36
  def __init__(
44
- self, window_size: int = 3, polynomial_order: int = 1, mode: str = "nearest"
37
+ self,
38
+ window_size: int = 3,
39
+ polynomial_order: int = 1,
40
+ mode: Literal["mirror", "constant", "nearest", "wrap", "interp"] = "nearest",
45
41
  ) -> None:
46
42
  self.window_size = window_size
47
43
  self.polynomial_order = polynomial_order
@@ -65,14 +61,9 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
65
61
  The fitted transformer.
66
62
  """
67
63
  # Check that X is a 2D array and has only finite values
68
- X = check_input(X)
69
-
70
- # Set the number of features
71
- self.n_features_in_ = X.shape[1]
72
-
73
- # Set the fitted attribute to True
74
- self._is_fitted = True
75
-
64
+ X = validate_data(
65
+ self, X, y="no_validation", ensure_2d=True, reset=True, dtype=np.float64
66
+ )
76
67
  return self
77
68
 
78
69
  def transform(self, X: np.ndarray, y=None) -> np.ndarray:
@@ -93,11 +84,18 @@ class SavitzkyGolayFilter(OneToOneFeatureMixin, BaseEstimator, TransformerMixin)
93
84
  The transformed data.
94
85
  """
95
86
  # Check that the estimator is fitted
96
- check_is_fitted(self, "_is_fitted")
87
+ check_is_fitted(self, "n_features_in_")
97
88
 
98
89
  # Check that X is a 2D array and has only finite values
99
- X = check_input(X)
100
- X_ = X.copy()
90
+ X_ = validate_data(
91
+ self,
92
+ X,
93
+ y="no_validation",
94
+ ensure_2d=True,
95
+ copy=True,
96
+ reset=False,
97
+ dtype=np.float64,
98
+ )
101
99
 
102
100
  if X_.shape[1] != self.n_features_in_:
103
101
  raise ValueError(
@@ -2,17 +2,17 @@ import numpy as np
2
2
  from scipy.sparse import csc_matrix, eye, diags
3
3
  from scipy.sparse.linalg import spsolve
4
4
  from sklearn.base import BaseEstimator, TransformerMixin, OneToOneFeatureMixin
5
- from sklearn.utils.validation import check_is_fitted
5
+ from sklearn.utils.validation import (
6
+ check_is_fitted,
7
+ validate_data,
8
+ ) # This code is adapted from the following source:
6
9
 
7
- from chemotools.utils.check_inputs import check_input
8
-
9
- # This code is adapted from the following source:
10
- # Z.-M. Zhang, S. Chen, and Y.-Z. Liang,
11
- # Baseline correction using adaptive iteratively reweighted penalized least squares.
10
+ # Z.-M. Zhang, S. Chen, and Y.-Z. Liang,
11
+ # Baseline correction using adaptive iteratively reweighted penalized least squares.
12
12
  # Analyst 135 (5), 1138-1146 (2010).
13
13
 
14
14
 
15
- class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
15
+ class WhittakerSmooth(TransformerMixin, OneToOneFeatureMixin, BaseEstimator):
16
16
  """
17
17
  A transformer that calculates the Whittaker smooth of the input data.
18
18
 
@@ -24,14 +24,6 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
24
24
  differences : int, optional
25
25
  The number of differences to use for the Whittaker smooth. Default is 1.
26
26
 
27
- Attributes
28
- ----------
29
- n_features_in_ : int
30
- The number of features in the input data.
31
-
32
- _is_fitted : bool
33
- Whether the transformer has been fitted to data.
34
-
35
27
  Methods
36
28
  -------
37
29
  fit(X, y=None)
@@ -40,6 +32,7 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
40
32
  transform(X, y=0, copy=True)
41
33
  Transform the input data by calculating the Whittaker smooth.
42
34
  """
35
+
43
36
  def __init__(
44
37
  self,
45
38
  lam: float = 1e2,
@@ -66,14 +59,9 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
66
59
  The fitted transformer.
67
60
  """
68
61
  # Check that X is a 2D array and has only finite values
69
- X = check_input(X)
70
-
71
- # Set the number of features
72
- self.n_features_in_ = X.shape[1]
73
-
74
- # Set the fitted attribute to True
75
- self._is_fitted = True
76
-
62
+ X = validate_data(
63
+ self, X, y="no_validation", ensure_2d=True, reset=True, dtype=np.float64
64
+ )
77
65
  return self
78
66
 
79
67
  def transform(self, X: np.ndarray, y=None) -> np.ndarray:
@@ -94,11 +82,18 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
94
82
  The transformed data.
95
83
  """
96
84
  # Check that the estimator is fitted
97
- check_is_fitted(self, "_is_fitted")
85
+ check_is_fitted(self, "n_features_in_")
98
86
 
99
87
  # Check that X is a 2D array and has only finite values
100
- X = check_input(X)
101
- X_ = X.copy()
88
+ X_ = validate_data(
89
+ self,
90
+ X,
91
+ y="no_validation",
92
+ ensure_2d=True,
93
+ copy=True,
94
+ reset=False,
95
+ dtype=np.float64,
96
+ )
102
97
 
103
98
  # Check that the number of features is the same as the fitted data
104
99
  if X_.shape[1] != self.n_features_in_:
@@ -113,14 +108,14 @@ class WhittakerSmooth(OneToOneFeatureMixin, BaseEstimator, TransformerMixin):
113
108
  return X_.reshape(-1, 1) if X_.ndim == 1 else X_
114
109
 
115
110
  def _calculate_whittaker_smooth(self, x):
116
- X = np.matrix(x)
111
+ X = np.array(x)
117
112
  m = X.size
118
113
  E = eye(m, format="csc")
119
114
  w = np.ones(m)
120
115
  for i in range(self.differences):
121
116
  E = E[1:] - E[:-1]
122
117
  W = diags(w, 0, shape=(m, m))
123
- A = csc_matrix(W + (self.lam * E.T * E))
124
- B = csc_matrix(W * X.T)
118
+ A = csc_matrix(W + (self.lam * E.T @ E))
119
+ B = csc_matrix(W @ X.T).toarray().ravel()
125
120
  background = spsolve(A, B)
126
121
  return np.array(background)
@@ -1,23 +1,24 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: chemotools
3
- Version: 0.0.27
4
- Summary: Package to integrate chemometrics in scikit-learn pipelines
5
- Home-page: https://github.com/paucablop/chemotools
6
- Author: Pau Cabaneros Lopez
7
- Author-email: pau.cabaneros@gmail.com
8
- Project-URL: Bug Tracker, https://github.com/paucablop/chemotools/issues/
9
- Classifier: Programming Language :: Python :: 3
3
+ Version: 0.1.6
4
+ Summary: chemotools: A Python Package that Integrates Chemometrics and scikit-learn
5
+ License: MIT
6
+ Author: Pau Cabaneros
7
+ Requires-Python: >=3.10,<4.0
10
8
  Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.9
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: numpy (>=2.0.0,<3.0.0)
15
+ Requires-Dist: pandas (>=2.0.0,<3.0.0)
16
+ Requires-Dist: polars (>=1.17.0,<2.0.0)
17
+ Requires-Dist: pyarrow (>=18.0.0,<19.0.0)
18
+ Requires-Dist: scikit-learn (>=1.4.0,<2.0.0)
13
19
  Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Requires-Dist: numpy
16
- Requires-Dist: pandas
17
- Requires-Dist: scipy
18
- Requires-Dist: scikit-learn
19
20
 
20
- ![chemotools](assets/images/logo_5.png)
21
+ ![chemotools](assets/images/logo_pixel.png)
21
22
 
22
23
 
23
24
  [![pypi](https://img.shields.io/pypi/v/chemotools)](https://pypi.org/project/chemotools)
@@ -25,6 +26,8 @@ Requires-Dist: scikit-learn
25
26
  [![pypi](https://img.shields.io/pypi/l/chemotools)](https://github.com/paucablop/chemotools/blob/main/LICENSE)
26
27
  [![codecov](https://codecov.io/github/paucablop/chemotools/branch/main/graph/badge.svg?token=D7JUJM89LN)](https://codecov.io/github/paucablop/chemotools)
27
28
  [![Downloads](https://static.pepy.tech/badge/chemotools)](https://pepy.tech/project/chemotools)
29
+ [![DOI](https://joss.theoj.org/papers/10.21105/joss.06802/status.svg)](https://doi.org/10.21105/joss.06802)
30
+
28
31
 
29
32
  # __chemotools__
30
33
 
@@ -0,0 +1,51 @@
1
+ chemotools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ chemotools/augmentation/__init__.py,sha256=xIUoWov_aluoW5L3zpVAahyPdkWA5erApW-duzdE_9A,385
3
+ chemotools/augmentation/baseline_shift.py,sha256=kIlYvmKS9pu9vh_-eZ7PSHPuH_58V9mgYbSJt6Gq3BA,3476
4
+ chemotools/augmentation/exponential_noise.py,sha256=fhZ4zQGGqmW-OiSu388th6IhgXrFj1xOguqKYAgj8Y4,3348
5
+ chemotools/augmentation/index_shift.py,sha256=DWVfnxCUgm2NNQfASTpqNoMkfhlW1WZT8EoWVsSSF4c,3459
6
+ chemotools/augmentation/normal_noise.py,sha256=-se2Xv1pAWt9HY7H5yC4XlxRArPKZWGeTy2MdyN4lBE,3318
7
+ chemotools/augmentation/spectrum_scale.py,sha256=hMsmzXpssbI7tGm_YnQn9wjbByso3CgVxd3Hs8kfLS8,3442
8
+ chemotools/augmentation/uniform_noise.py,sha256=8a-AYzEDIkLckL6FK2i8mr_jXnQGcFaKXh_roGCICaQ,3456
9
+ chemotools/baseline/__init__.py,sha256=VzoblGg8Hx_FkTc_n7a-ZjGvtKP8JE_NwJKWenGFQkM,584
10
+ chemotools/baseline/_air_pls.py,sha256=eotXuIEsus7Z-c17oLx8UbiwOHM7DzQJ6rruHnwCGPQ,5067
11
+ chemotools/baseline/_ar_pls.py,sha256=Cl0tN0DGQA8JpnbIge4cBqT7aGQ7yltppYEDI6tWqiM,4385
12
+ chemotools/baseline/_constant_baseline_correction.py,sha256=2ARXIma3m_He5KJs0t0Bz3m0Hd7CNHDR4Dd4XfjMWgs,3893
13
+ chemotools/baseline/_cubic_spline_correction.py,sha256=Qr8jLwAM4JIcD-8G6BBU2vLSLyi44iHiIpJrHyZ6qJE,3432
14
+ chemotools/baseline/_linear_correction.py,sha256=jYUy1q5hlBIhoQr5yPWbqr65pTK8NCVPdJdjVg1SFtg,3258
15
+ chemotools/baseline/_non_negative.py,sha256=0Huq4fKAzAoX9nr6Fk-Awx5xBqmah4jTcn0TY31FJQc,2741
16
+ chemotools/baseline/_polynomial_correction.py,sha256=jzoTyj5a9dHBtefTKVer8CVpCwWqV25Ruj7mq7Ra_PI,4005
17
+ chemotools/baseline/_subtract_reference.py,sha256=B92DAYJmJR5VtWTM7Q6_orvIl2xaadmvbGr1r_ZJALA,3379
18
+ chemotools/datasets/__init__.py,sha256=WcchczWPH-A22DmYEnz2-u8A6vfVviJ6tOCBB0zaIAU,196
19
+ chemotools/datasets/_base.py,sha256=g_-R6c9WI5lt_j40FgA_mvEFzFHM9eGW6hj9d1e29P4,4883
20
+ chemotools/datasets/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ chemotools/datasets/data/coffee_labels.csv,sha256=ZXQWQIf8faLHjdnHfRoXfxMR56kq9Q1BGPZBkQyhGlY,487
22
+ chemotools/datasets/data/coffee_spectra.csv,sha256=VA-sN4u0hC5iALlRxxkj-K87Lz3b3mmUHBJPoDXychI,2206147
23
+ chemotools/datasets/data/fermentation_hplc.csv,sha256=AMmiFQxwaXrH8aN310-3h1YQDiDrT8JNRv1RDvhEvg4,2140
24
+ chemotools/datasets/data/fermentation_spectra.csv,sha256=MaaNMQP0lygJgFbEoUX0OUqdA-id8mF5Llvf_vj9tJk,15237508
25
+ chemotools/datasets/data/train_hplc.csv,sha256=DjtmqiePOWB-F6TsOGFngE1pKyXkb7Xmsi-1CLxsTnE,249
26
+ chemotools/datasets/data/train_spectra.csv,sha256=iVF19W52NHlbqq8BbLomn8n47kSPT0QxJv7wtQX4yjQ,203244
27
+ chemotools/derivative/__init__.py,sha256=FkckdzO30jrRWPGpIU3cfnaTtxPtNT5Tb2G9F9PmVTw,134
28
+ chemotools/derivative/_norris_william.py,sha256=rMY_yntpiB5fbSM1tPph4AaGmF1k-HqJp7o48ijePBs,4958
29
+ chemotools/derivative/_savitzky_golay.py,sha256=CuCrKoLmrB1YmJ4ihIykgkL3tO3frqkStMogtsVhO3A,3632
30
+ chemotools/feature_selection/__init__.py,sha256=1_i28hIxijjwhMypTy1w2fLbzXXVkKD5IYzzY8ZSuHw,117
31
+ chemotools/feature_selection/_index_selector.py,sha256=lNTP2b7P3doWl30KiAr3Xd2HOMxeUmj24MuqoXl4Voc,3556
32
+ chemotools/feature_selection/_range_cut.py,sha256=lVVVC30ZsK2z9jsDGb_z6l8Ty2I89yM05_dIDbMP73Q,3564
33
+ chemotools/scale/__init__.py,sha256=eztqcHg-TKE1Rr0N9ArfytHk8teuqVfi4SZi2DS96vc,175
34
+ chemotools/scale/_min_max_scaler.py,sha256=YvqRkV2pXu-viQrpjzWcp9KmSSCYSoubSnrZHRLqgKQ,3011
35
+ chemotools/scale/_norm_scaler.py,sha256=CHWSir2q-pL1hxzw_ZB45yi4mw-SkJ4YOa1CUL4nm2I,2568
36
+ chemotools/scale/_point_scaler.py,sha256=je-vomAk7g3Q7yxmisQK4-3ndKEKI2wDwLrUiNuwzzA,3505
37
+ chemotools/scatter/__init__.py,sha256=ftyC_MGurzxpWMie8WlFDGh5ylalK2K3aCSN4qUzQAw,459
38
+ chemotools/scatter/_extended_multiplicative_scatter_correction.py,sha256=7OpOcvWX1hlMUR18tC29pkSiADLZViDrTh-wro738E4,6560
39
+ chemotools/scatter/_multiplicative_scatter_correction.py,sha256=nPMPYKHl6-U--GAuQdZL8KVNPlr3V52teUAoJ0iRs3g,5801
40
+ chemotools/scatter/_robust_normal_variate.py,sha256=nPfcvjHEpwkcSCjdvD86WN9q2wVMCeZ2Z8wMzcBpM3Y,3110
41
+ chemotools/scatter/_standard_normal_variate.py,sha256=22mJzbbZoXQY-_hHAhGO0vzfYwr3oMqaR6xPjJryHtk,2582
42
+ chemotools/smooth/__init__.py,sha256=G8JvAoBK9d18-k6XgukqN6dbJP-dsEgeDdbKbZdCIkA,265
43
+ chemotools/smooth/_mean_filter.py,sha256=KVAqOzYWv-SnDX2HD3zLWSSDNePi2Zy3EV9NwIX2H38,2827
44
+ chemotools/smooth/_median_filter.py,sha256=9ndTJCwrZirWlvDNldiigMddy79KIGq9OwwYNSXaw14,3111
45
+ chemotools/smooth/_savitzky_golay_filter.py,sha256=27iFUWxdL9_7oZabR0R5L0ZTpBmYfVUjx2XCTukihBE,3509
46
+ chemotools/smooth/_whittaker_smooth.py,sha256=lpLAyf4GdyDW4ulT1nyEoK6xQEl2cVUKquawQdGWbHU,3571
47
+ chemotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
+ chemotools-0.1.6.dist-info/LICENSE,sha256=qtyOy2wDQVX9hxp58h3T-6Lmfv-mSCHoSRkcLUdM9bg,1070
49
+ chemotools-0.1.6.dist-info/METADATA,sha256=79TZ--QC_SOHj3ou6bDaRYsJsQoFS0sx2Rfe2BUOrG4,5239
50
+ chemotools-0.1.6.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
51
+ chemotools-0.1.6.dist-info/RECORD,,
@@ -1,5 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
-
@@ -1,14 +0,0 @@
1
- from sklearn.utils.validation import check_array
2
-
3
-
4
- def check_input(X, y=None):
5
- # Check that X is a 2D array and has only finite values
6
- X = check_array(X, ensure_2d=True, force_all_finite=True)
7
-
8
- # Check that y is None or a 1D array of the same length as X
9
- if y is not None:
10
- y = y.reshape(-1, 1) if y.ndim == 1 else y
11
- y = check_array(y, force_all_finite=True)
12
- if len(y) != X.shape[0]:
13
- raise ValueError("y must have the same number of samples as X")
14
- return X
@@ -1,2 +0,0 @@
1
- from .range_cut import RangeCut
2
- from .select_features import SelectFeatures
@@ -1,49 +0,0 @@
1
- chemotools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- chemotools/baseline/__init__.py,sha256=W61mEZU_9-sVGRkP2MJOIhd6e9KsOS1BYjxm1NOMIyM,373
3
- chemotools/baseline/air_pls.py,sha256=qn03l66IrxW7woFbRmRqCmfZHzQ7KKW8A7ogTxTHKo0,5443
4
- chemotools/baseline/ar_pls.py,sha256=OY2cpU2X6KIBR9ag3PAJXo_uQbniIV58zbUJxCxvZWs,4736
5
- chemotools/baseline/constant_baseline_correction.py,sha256=m6GKTAaCSjIjOK4Q3OHqdle5IyB4KFu04FzQofYt-oU,4221
6
- chemotools/baseline/cubic_spline_correction.py,sha256=PCHqR7TAhbdlTZrxgedlk0PU0kRUwQd_jymh0g-ieo8,3311
7
- chemotools/baseline/linear_correction.py,sha256=6Sw2n4QTvIDKWRdJpFD48hMvOEwqbctUAQLF1WwcoXs,3381
8
- chemotools/baseline/non_negative.py,sha256=17_82l95U9kgoQ3Pdz3-jGv8B51JzqPdHODt6PegWRw,2864
9
- chemotools/baseline/polynomial_correction.py,sha256=caP866fwZb7PASyz6oezgg8hdZtFMT0EimK89TGSTSc,4059
10
- chemotools/baseline/subtract_reference.py,sha256=Pht87XadXK0URq2fun66OHaUk_cx56AkF84ta3VJy_8,3441
11
- chemotools/datasets/__init__.py,sha256=yarhf-7bKB-mbStdWfi9LA_apOusoxY5A9bcwyzj10M,85
12
- chemotools/datasets/_base.py,sha256=ArZrVRW5m5yO13iK_EycvV8gheiWKR9hoSZCD_OfS1g,2249
13
- chemotools/datasets/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
- chemotools/datasets/data/fermentation_hplc.csv,sha256=AMmiFQxwaXrH8aN310-3h1YQDiDrT8JNRv1RDvhEvg4,2140
15
- chemotools/datasets/data/fermentation_spectra.csv,sha256=MaaNMQP0lygJgFbEoUX0OUqdA-id8mF5Llvf_vj9tJk,15237508
16
- chemotools/datasets/data/train_hplc.csv,sha256=DjtmqiePOWB-F6TsOGFngE1pKyXkb7Xmsi-1CLxsTnE,249
17
- chemotools/datasets/data/train_spectra.csv,sha256=iVF19W52NHlbqq8BbLomn8n47kSPT0QxJv7wtQX4yjQ,203244
18
- chemotools/derivative/__init__.py,sha256=x2F0IJ-uCbEYFoXFbZl_RTPCbSq82vqGOwlM9R_2Klo,84
19
- chemotools/derivative/norris_william.py,sha256=JaJ7zlSiC_0tiITu7VWXtgKrmkQP7gLvuFb0_n1j9Dw,5081
20
- chemotools/derivative/savitzky_golay.py,sha256=fFzQRVGVXQIUkHp1x9dqfLVPlyStubIhSj9aGfZKuXY,3745
21
- chemotools/scale/__init__.py,sha256=HuXy_TktvXLTMWoW0pKhVCzMOkRkMRnvWCGiIKvjvZ8,115
22
- chemotools/scale/min_max_scaler.py,sha256=f1bGkODTWGwfnfMfWPimVxIZC3WIikgthQh-zUiaQUU,3123
23
- chemotools/scale/norm_scaler.py,sha256=qNs-npf5Jqcp8RYqt88_5-zwd-yIo-J1jItgUTFeozs,2699
24
- chemotools/scale/point_scaler.py,sha256=4q7nweuCKjOTV2VcvteAmfvTh1AV2Emf32XqWfiC7oc,3603
25
- chemotools/scatter/__init__.py,sha256=M0_B4hXVoDc2Qx00QreUfhFqPUTs6LbU4CWaFU17hg4,288
26
- chemotools/scatter/extended_multiplicative_scatter_correction.py,sha256=J65hyEFBzKNo_35Ta9MKWO35CjTw-8hDbSr8xd8RIfc,6912
27
- chemotools/scatter/multiplicative_scatter_correction.py,sha256=MFemiwS-KWFOtlcXVhLnY4mn6QQ8pttuj6UP0rodXEM,5689
28
- chemotools/scatter/robust_normal_variate.py,sha256=joIL-nGUja0nG8YcCuT32ehxmy2xOy3OD0t0yP5vWfM,3233
29
- chemotools/scatter/standard_normal_variate.py,sha256=wmK_8ea2CvoLaGebBFKr8zAU7QjGbaKAg04y6iZ4sDc,2681
30
- chemotools/smooth/__init__.py,sha256=Kwg3jVnl-W-efTHMR6-6hQsTp-An1lYQ1lZFj6sNMtg,176
31
- chemotools/smooth/mean_filter.py,sha256=fcC4EjO57Br3I9SJqWDJRxPxAv2WjjmXTECdBmBYXLI,2953
32
- chemotools/smooth/median_filter.py,sha256=5tR931HIej-yrw1SoV9t09gi55QKbZ3eCTeO-EjNSU8,2966
33
- chemotools/smooth/savitzky_golay_filter.py,sha256=OlkW4-gHsgk7HFf7yeweKkL6aOZpNqMSbUpvKjC66KY,3523
34
- chemotools/smooth/whittaker_smooth.py,sha256=OVEYEstsURgkLbjwRiBWeN_XNs_JOFeD60uyZsVtrHQ,3664
35
- chemotools/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- chemotools/utils/check_inputs.py,sha256=fRAV4HIaGamdj_PNXSNnl7LurXytACNTGO51rhPpMUY,512
37
- chemotools/variable_selection/__init__.py,sha256=6gKxCAoGKAOhhTerUyBg_62YKCIr0K4mbDcoDfbMJeA,75
38
- chemotools/variable_selection/range_cut.py,sha256=xNEnUJTdQeMnfeiOvX7BDo2ySZEoftRaI7BIsms_Mlo,4204
39
- chemotools/variable_selection/select_features.py,sha256=pcoFmGZLUPjtRytGpnqK8YdVj3Z5hwKGSJ10VxCpg58,4164
40
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
- tests/fixtures.py,sha256=Xa-Vd62Kd1fyWg3PLUSP6iIkOK8etrbyOkMJTn3dvX8,1933
42
- tests/test_datasets.py,sha256=QwqZPLTcXG8f5ZeUJs5bq39v3kVnwSVxPRZ28spobUI,736
43
- tests/test_functionality.py,sha256=t4Uq0Czy_M_RhHz3_ze1bJ1HLKO0z8Tl3W9oIaOEoJY,16991
44
- tests/test_sklearn_compliance.py,sha256=-DxSrJEK-sayGTYimTQFa4rJu93PtyBz91a5r5lCNXw,4773
45
- chemotools-0.0.27.dist-info/LICENSE,sha256=qtyOy2wDQVX9hxp58h3T-6Lmfv-mSCHoSRkcLUdM9bg,1070
46
- chemotools-0.0.27.dist-info/METADATA,sha256=JmOb5CSzBk_cJR5g9otvF7yW9Biig9q2wZo75SeRsWQ,5015
47
- chemotools-0.0.27.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
48
- chemotools-0.0.27.dist-info/top_level.txt,sha256=eNcNcKSdo-1H_2gwSDrS__dr7BM3R73Cnn-pBiW5FEw,17
49
- chemotools-0.0.27.dist-info/RECORD,,
@@ -1,2 +0,0 @@
1
- chemotools
2
- tests
tests/__init__.py DELETED
File without changes
tests/fixtures.py DELETED
@@ -1,89 +0,0 @@
1
- import numpy as np
2
- import os
3
- import pytest
4
-
5
-
6
- test_directory = os.path.dirname(os.path.abspath(__file__))
7
-
8
- path_to_resources = os.path.join(test_directory, "resources")
9
-
10
-
11
- @pytest.fixture
12
- def spectrum() -> np.ndarray:
13
- return [
14
- np.loadtxt(
15
- os.path.join(path_to_resources, "spectrum.csv"), delimiter=","
16
- ).tolist()
17
- ]
18
-
19
-
20
- @pytest.fixture
21
- def spectrum_arpls() -> np.ndarray:
22
- return [
23
- np.loadtxt(
24
- os.path.join(path_to_resources, "spectrum_arpls.csv"), delimiter=","
25
- ).tolist()
26
- ]
27
-
28
-
29
- @pytest.fixture
30
- def reference_airpls() -> np.ndarray:
31
- return [
32
- np.loadtxt(
33
- os.path.join(path_to_resources, "reference_airpls.csv"), delimiter=","
34
- ).tolist()
35
- ]
36
-
37
-
38
- @pytest.fixture
39
- def reference_arpls() -> np.ndarray:
40
- return [
41
- np.loadtxt(
42
- os.path.join(path_to_resources, "reference_arpls.csv"), delimiter=","
43
- ).tolist()
44
- ]
45
-
46
-
47
- @pytest.fixture
48
- def reference_msc_mean() -> np.ndarray:
49
- return [
50
- np.loadtxt(
51
- os.path.join(path_to_resources, "reference_msc_mean.csv"), delimiter=","
52
- ).tolist()
53
- ]
54
-
55
-
56
- @pytest.fixture
57
- def reference_msc_median() -> np.ndarray:
58
- return [
59
- np.loadtxt(
60
- os.path.join(path_to_resources, "reference_msc_median.csv"), delimiter=","
61
- ).tolist()
62
- ]
63
-
64
-
65
- @pytest.fixture
66
- def reference_sg_15_2() -> np.ndarray:
67
- return [
68
- np.loadtxt(
69
- os.path.join(path_to_resources, "reference_sg_15_2.csv"), delimiter=","
70
- ).tolist()
71
- ]
72
-
73
-
74
- @pytest.fixture
75
- def reference_snv() -> np.ndarray:
76
- return [
77
- np.loadtxt(
78
- os.path.join(path_to_resources, "reference_snv.csv"), delimiter=","
79
- ).tolist()
80
- ]
81
-
82
-
83
- @pytest.fixture
84
- def reference_whitakker() -> np.ndarray:
85
- return [
86
- np.loadtxt(
87
- os.path.join(path_to_resources, "reference_whitakker.csv"), delimiter=","
88
- ).tolist()
89
- ]
tests/test_datasets.py DELETED
@@ -1,30 +0,0 @@
1
- import pandas as pd
2
-
3
- from chemotools.datasets import load_fermentation_test, load_fermentation_train
4
-
5
-
6
- def test_load_fermentation_test():
7
- # Arrange
8
-
9
- # Act
10
- test_spectra, test_hplc = load_fermentation_test()
11
-
12
- # Assert
13
- assert test_spectra.shape == (1629, 1047)
14
- assert test_hplc.shape == (34, 6)
15
- assert isinstance(test_spectra, pd.DataFrame)
16
- assert isinstance(test_hplc, pd.DataFrame)
17
-
18
- def test_load_fermentation_train():
19
- # Arrange
20
-
21
- # Act
22
- train_spectra, train_hplc = load_fermentation_train()
23
-
24
- # Assert
25
- assert train_spectra.shape == (21, 1047)
26
- assert train_hplc.shape == (21, 1)
27
- assert isinstance(train_spectra, pd.DataFrame)
28
- assert isinstance(train_hplc, pd.DataFrame)
29
-
30
-