bindtools 0.3.1__tar.gz → 0.3.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.
Files changed (27) hide show
  1. {bindtools-0.3.1 → bindtools-0.3.3}/PKG-INFO +5 -5
  2. {bindtools-0.3.1 → bindtools-0.3.3}/pyproject.toml +5 -5
  3. {bindtools-0.3.1 → bindtools-0.3.3}/pyproject.toml.orig +5 -5
  4. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/models/binding_model.py +52 -11
  5. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/observables/transforms.py +4 -0
  6. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/observables/types.py +2 -0
  7. {bindtools-0.3.1 → bindtools-0.3.3}/README.md +0 -0
  8. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/__init__.py +0 -0
  9. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/binding.py +0 -0
  10. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/exceptions.py +0 -0
  11. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/io/__init__.py +0 -0
  12. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/io/export.py +0 -0
  13. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/mcmc/__init__.py +0 -0
  14. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/mcmc/helpers.py +0 -0
  15. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/mcmc/likelihood.py +0 -0
  16. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/mcmc/sampler.py +0 -0
  17. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/models/__init__.py +0 -0
  18. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/models/objective.py +0 -0
  19. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/models/simulation.py +0 -0
  20. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/observables/__init__.py +0 -0
  21. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/plotting/__init__.py +0 -0
  22. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/plotting/fit_plots.py +0 -0
  23. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/plotting/mcmc_plots.py +0 -0
  24. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/speciation/__init__.py +0 -0
  25. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/speciation/analytical.py +0 -0
  26. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/speciation/numerical.py +0 -0
  27. {bindtools-0.3.1 → bindtools-0.3.3}/src/bindtools/speciation/scipy_solver.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: bindtools
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Keywords: chemistry,analytical chemistry,binding constants,supramolecular
5
5
  Author: Martin Peeks
6
6
  Author-email: Martin Peeks <martinp23@googlemail.com>, m.peeks@unsw.edu.au
@@ -11,18 +11,18 @@ Classifier: Programming Language :: Python :: 3.13
11
11
  Classifier: Programming Language :: Python :: 3.14
12
12
  Classifier: Topic :: Scientific/Engineering :: Chemistry
13
13
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
14
- Requires-Dist: corner==2.2.3
14
+ Requires-Dist: corner==2.3.0
15
15
  Requires-Dist: emcee==3.1.6
16
16
  Requires-Dist: h5py>=3.14.0
17
17
  Requires-Dist: latex2mathml>=3.81.0
18
18
  Requires-Dist: lmfit==1.3.4
19
- Requires-Dist: matplotlib==3.11.0
19
+ Requires-Dist: matplotlib==3.11.2
20
20
  Requires-Dist: numba>=0.66
21
21
  Requires-Dist: numpy>=2.3.4
22
22
  Requires-Dist: openpyxl>=3.1.5
23
23
  Requires-Dist: pandas>=2.3.3
24
- Requires-Dist: scipy==1.18.0
25
- Requires-Dist: tqdm==4.68.3
24
+ Requires-Dist: scipy==1.18.1
25
+ Requires-Dist: tqdm==4.70.1
26
26
  Requires-Dist: uncertainties==3.2.3
27
27
  Requires-Python: >=3.12
28
28
  Project-URL: Homepage, https://github.com/martinp23/bindtools
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "bindtools"
7
- version = "0.3.1"
7
+ version = "0.3.3"
8
8
  readme = "README.md"
9
9
  classifiers = [
10
10
  "Development Status :: 3 - Alpha",
@@ -23,18 +23,18 @@ keywords = [
23
23
  "supramolecular",
24
24
  ]
25
25
  dependencies = [
26
- "corner==2.2.3",
26
+ "corner==2.3.0",
27
27
  "emcee==3.1.6",
28
28
  "h5py>=3.14.0",
29
29
  "latex2mathml>=3.81.0",
30
30
  "lmfit==1.3.4",
31
- "matplotlib==3.11.0",
31
+ "matplotlib==3.11.2",
32
32
  "numba>=0.66",
33
33
  "numpy>=2.3.4",
34
34
  "openpyxl>=3.1.5",
35
35
  "pandas>=2.3.3",
36
- "scipy==1.18.0",
37
- "tqdm==4.68.3",
36
+ "scipy==1.18.1",
37
+ "tqdm==4.70.1",
38
38
  "uncertainties==3.2.3",
39
39
  ]
40
40
 
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "bindtools"
7
- version = "0.3.1"
7
+ version = "0.3.3"
8
8
  readme = "README.md"
9
9
  classifiers = [
10
10
  # How mature is this project? Common values are
@@ -27,18 +27,18 @@ classifiers = [
27
27
  requires-python = ">=3.12"
28
28
  keywords = ["chemistry", "analytical chemistry", "binding constants", "supramolecular"]
29
29
  dependencies = [
30
- "corner==2.2.3",
30
+ "corner==2.3.0",
31
31
  "emcee==3.1.6",
32
32
  "h5py>=3.14.0",
33
33
  "latex2mathml>=3.81.0",
34
34
  "lmfit==1.3.4",
35
- "matplotlib==3.11.0",
35
+ "matplotlib==3.11.2",
36
36
  "numba>=0.66",
37
37
  "numpy>=2.3.4",
38
38
  "openpyxl>=3.1.5",
39
39
  "pandas>=2.3.3",
40
- "scipy==1.18.0",
41
- "tqdm==4.68.3",
40
+ "scipy==1.18.1",
41
+ "tqdm==4.70.1",
42
42
  "uncertainties==3.2.3",
43
43
  ]
44
44
  authors = [
@@ -10,11 +10,12 @@ from bindtools.models.objective import fitfun
10
10
  class bindingModel:
11
11
  def __init__(
12
12
  self,
13
- eqMat,
14
- compNames,
15
- speciesList,
16
- specToInteg=None,
17
- specToDd=None,
13
+ eqMat: np.ndarray,
14
+ compNames: List[str],
15
+ speciesList: List[str],
16
+ specToInteg: Optional[np.ndarray|List]=None,
17
+ specToDd: Optional[List|np.ndarray]=None,
18
+ specToLinear: Optional[List|np.ndarray]=None,
18
19
  colToComp=None,
19
20
  obsList=None,
20
21
  rawData=None,
@@ -47,8 +48,8 @@ class bindingModel:
47
48
  self.nConcs = np.shape(compConcs)[0]
48
49
 
49
50
  self.concUnits = None # mM #TODO
50
- self.specToDd = specToDd
51
- self.specToLinear: Optional[np.ndarray] = None # (n_species, n_obs) object array for UV-vis / fluorescence
51
+ self.specToDd = specToDd # (n_species, n_obs) object array for NMR chemical shifts
52
+ self.specToLinear: Optional[List] = specToLinear # (n_species, n_obs) object array for UV-vis / fluorescence
52
53
  self.analytical_fast_exchange: bool = False
53
54
  self.analytical_topology: Optional[str] = None
54
55
  self.analytical_complex_indices: list[int] = []
@@ -142,18 +143,58 @@ class bindingModel:
142
143
 
143
144
  # Register UV-vis / fluorescence parameters from specToLinear (object array).
144
145
  if self.specToLinear is not None:
145
- for _, x in np.ndenumerate(self.specToLinear):
146
- if isinstance(x, lmfit.Parameter):
146
+ # Coerce list or 1D array to 2D object array safely
147
+ if not isinstance(self.specToLinear, np.ndarray) or self.specToLinear.dtype != object:
148
+ raw_list = list(self.specToLinear)
149
+ if len(raw_list) > 0 and isinstance(raw_list[0], (list, tuple, np.ndarray)):
150
+ # Already 2D-like
151
+ rows, cols = len(raw_list), len(raw_list[0])
152
+ arr = np.empty((rows, cols), dtype=object)
153
+ for r in range(rows):
154
+ for c in range(cols):
155
+ arr[r, c] = raw_list[r][c]
156
+ else:
157
+ # 1D-like -> reshape to (n_species, 1)
158
+ arr = np.empty((len(raw_list), 1), dtype=object)
159
+ for r, val in enumerate(raw_list):
160
+ arr[r, 0] = val
161
+ self.specToLinear = arr
162
+ elif self.specToLinear.ndim == 1:
163
+ self.specToLinear = self.specToLinear[:, None]
164
+ # Register parameters (supporting both lmfit.Parameter and (min, init, max[, name]) tuples)
165
+ for ii, x in np.ndenumerate(self.specToLinear):
166
+ if isinstance(x, tuple):
167
+ param_name = x[3] if len(x) > 3 else f"lin_{ii[0]}_{ii[1]}"
168
+ self._addParam(param_name, x[1], min=x[0], max=x[2])
169
+ elif isinstance(x, lmfit.Parameter):
147
170
  self._addExistingParam(x)
148
171
 
149
- # add chemical shift fitting params
150
172
  if self.specToDd is not None:
173
+ if not isinstance(self.specToDd, np.ndarray) or self.specToDd.dtype != object:
174
+ raw_list = list(self.specToDd)
175
+ if len(raw_list) > 0 and isinstance(raw_list[0], (list, tuple, np.ndarray)):
176
+ # Already 2D-like
177
+ rows, cols = len(raw_list), len(raw_list[0])
178
+ arr = np.empty((rows, cols), dtype=object)
179
+ for r in range(rows):
180
+ for c in range(cols):
181
+ arr[r, c] = raw_list[r][c]
182
+ else:
183
+ # 1D-like -> reshape to (n_species, 1)
184
+ arr = np.empty((len(raw_list), 1), dtype=object)
185
+ for r, val in enumerate(raw_list):
186
+ arr[r, 0] = val
187
+ self.specToDd = arr
188
+ elif self.specToDd.ndim == 1:
189
+ self.specToDd = self.specToDd[:, None]
190
+
191
+
151
192
  for ii, x in np.ndenumerate(self.specToDd):
152
193
  if isinstance(x, tuple):
153
194
  self._addParam("shift_{}_{}".format(ii[0], ii[1]), x[1], min=x[0], max=x[2])
154
195
  elif isinstance(x, lmfit.Parameter):
155
196
  self._addExistingParam(x)
156
-
197
+
157
198
  def runModel(self, sigma=1, skip_col=1, method="least_squares", ret=False, kwargs={}) -> Optional["bindingModel"]:
158
199
  exptData = np.copy(self.rawData)
159
200
  spec_to_integ = None
@@ -46,6 +46,10 @@ def concToLinearObs(
46
46
 
47
47
  Returns an ndarray of shape (n_pts, n_obs).
48
48
  """
49
+
50
+ if hasattr(specToLinear, "ndim") and specToLinear.ndim == 1:
51
+ specToLinear = specToLinear[:, None]
52
+
49
53
  mlen, nlen = np.shape(specToLinear) # (n_species, n_obs)
50
54
  specToLinearTrial = np.copy(specToLinear)
51
55
 
@@ -43,6 +43,8 @@ class ObsType:
43
43
  self.param = lmfit.Parameter("lnsigmaFluorescence", value=-4, vary=True, min=-8, max=0)
44
44
 
45
45
  else:
46
+ print("Unknown observable type. Using default units and parameter name.")
47
+
46
48
  self.units = units
47
49
  self.param = lmfit.Parameter("lnsigma" + name)
48
50
 
File without changes