spectrochempy-tensor 0.1.0__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.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: spectrochempy-tensor
3
+ Version: 0.1.0
4
+ Summary: Tensor decompositions plugin for SpectroChemPy
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: spectrochempy<0.10,>=0.9
8
+ Requires-Dist: tensorly
9
+
10
+ # spectrochempy-tensor
11
+
12
+ Tensor decomposition plugin for SpectroChemPy.
13
+
14
+ This official plugin provides TensorLy-backed tensor decomposition classes,
15
+ starting with CP/PARAFAC decomposition exposed as `scp.tensor.CP`.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install spectrochempy-tensor
21
+ ```
22
+
23
+ For local development from the SpectroChemPy monorepo:
24
+
25
+ ```bash
26
+ pip install -e plugins/spectrochempy-tensor
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```python
32
+ import spectrochempy as scp
33
+
34
+ model = scp.tensor.CP(n_components=2)
35
+ model.fit(dataset)
36
+ ```
37
+
38
+ The historical `scp.CP` alias is retained as a deprecated compatibility path.
@@ -0,0 +1,29 @@
1
+ # spectrochempy-tensor
2
+
3
+ Tensor decomposition plugin for SpectroChemPy.
4
+
5
+ This official plugin provides TensorLy-backed tensor decomposition classes,
6
+ starting with CP/PARAFAC decomposition exposed as `scp.tensor.CP`.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install spectrochempy-tensor
12
+ ```
13
+
14
+ For local development from the SpectroChemPy monorepo:
15
+
16
+ ```bash
17
+ pip install -e plugins/spectrochempy-tensor
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```python
23
+ import spectrochempy as scp
24
+
25
+ model = scp.tensor.CP(n_components=2)
26
+ model.fit(dataset)
27
+ ```
28
+
29
+ The historical `scp.CP` alias is retained as a deprecated compatibility path.
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "spectrochempy-tensor"
7
+ version = "0.1.0"
8
+ description = "Tensor decompositions plugin for SpectroChemPy"
9
+ requires-python = ">=3.11"
10
+ readme = "README.md"
11
+ dependencies = [
12
+ "spectrochempy>=0.9,<0.10",
13
+ "tensorly",
14
+ ]
15
+
16
+ [project.entry-points."spectrochempy.plugins"]
17
+ tensor = "spectrochempy_tensor:TensorPlugin"
18
+
19
+ [tool.setuptools.packages.find]
20
+ where = ["src"]
21
+
22
+ [tool.pytest.ini_options]
23
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,62 @@
1
+ # ruff: noqa: PLC0415 - defer imports in plugin methods to avoid startup cost
2
+ """Tensor decomposition plugin for SpectroChemPy."""
3
+
4
+ from __future__ import annotations
5
+
6
+ from spectrochempy.api.plugins import CORE_PLUGIN_API_VERSION
7
+ from spectrochempy.api.plugins import PluginCapability
8
+ from spectrochempy.api.plugins import SpectroChemPyPlugin
9
+ from spectrochempy.plugins.proxies import lazy_proxy
10
+
11
+
12
+ def _resolve_CP():
13
+ """Lazily import and return the CP decomposition class."""
14
+ from spectrochempy_tensor.decompositions.cp import CP
15
+
16
+ return CP
17
+
18
+
19
+ class TensorPlugin(SpectroChemPyPlugin):
20
+ """TensorLy-backed tensor decomposition plugin."""
21
+
22
+ name = "tensor"
23
+ version = "0.1.0"
24
+ description = "TensorLy-backed tensor decompositions for SpectroChemPy"
25
+ spectrochempy_min_version = "0.9.0"
26
+ PLUGIN_API_VERSION = CORE_PLUGIN_API_VERSION
27
+ requires = ["tensorly"]
28
+ capabilities = [PluginCapability.ANALYSIS]
29
+ root_exports = {
30
+ "CP": {
31
+ "target": "CP",
32
+ "deprecated": True,
33
+ "replacement": "scp.tensor.CP",
34
+ },
35
+ }
36
+
37
+ def register_analyses(self) -> list[dict]:
38
+ """Declare tensor decomposition classes."""
39
+ return [
40
+ {
41
+ "name": "CP",
42
+ "func": lazy_proxy(
43
+ _resolve_CP,
44
+ name="spectrochempy.tensor.CP",
45
+ ),
46
+ "namespace": "tensor",
47
+ "description": "CP/PARAFAC tensor decomposition",
48
+ },
49
+ ]
50
+
51
+
52
+ def __getattr__(name: str):
53
+ if name == "CP":
54
+ from spectrochempy_tensor.decompositions.cp import CP
55
+
56
+ return CP
57
+ msg = f"module {__name__!r} has no attribute {name!r}"
58
+ raise AttributeError(msg)
59
+
60
+
61
+ def __dir__() -> list[str]:
62
+ return ["CP", "TensorPlugin"]
@@ -0,0 +1,3 @@
1
+ """Adapter layer for tensor-plugin integrations."""
2
+
3
+ __all__: list[str] = []
@@ -0,0 +1,5 @@
1
+ """TensorLy-backed tensor decomposition classes."""
2
+
3
+ from spectrochempy_tensor.decompositions.cp import CP
4
+
5
+ __all__ = ["CP"]