Skip to content

Commit 81ebcbe

Browse files
committed
Inject SimpleProxy docs in reference section
1 parent 38b6640 commit 81ebcbe

File tree

4 files changed

+52
-6
lines changed

4 files changed

+52
-6
lines changed

doc/reference/classes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Main Classes
1212
proxy
1313
proxysource
1414
proxyndsource
15+
simpleproxy

doc/reference/proxysource.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ ProxySource
44
===========
55

66
Base interface for all supported sources in :ref:`Proxy` and are not NDim objects.
7-
For example, a file, a memory buffer, a network resource, etc. For NDims, see
8-
:ref:`ProxyNDSource`.
7+
For example, a file, a memory buffer, a network resource, etc. For n-dimemsional
8+
ones, see :ref:`ProxyNDSource`.
99

1010
.. currentmodule:: blosc2.ProxySource
1111

doc/reference/simpleproxy.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. _SimpleProxy:
2+
3+
SimpleProxy
4+
===========
5+
6+
Simple proxy for a NumPy array (or similar) that can be used with the Blosc2 compute engine.
7+
8+
This only supports the __getitem__ method. No caching is performed.
9+
10+
.. currentmodule:: blosc2.SimpleProxy
11+
12+
Methods
13+
-------
14+
15+
.. autosummary::
16+
:toctree: autofiles/simpleproxy
17+
:nosignatures:
18+
19+
__init__
20+
__getitem__
21+
22+
Attributes
23+
----------
24+
25+
.. autosummary::
26+
:toctree: autofiles/simpleproxy
27+
28+
shape
29+
dtype
30+
src

src/blosc2/proxy.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,15 +555,30 @@ def __init__(self, src, chunks: tuple | None = None, blocks: tuple | None = None
555555
if not hasattr(src, "shape") or not hasattr(src, "dtype"):
556556
# If the source is not a NumPy array, convert it to one
557557
src = np.asarray(src)
558-
self.src = src
559-
self.dtype = src.dtype
560-
self.shape = src.shape
558+
self._src = src
559+
self._dtype = src.dtype
560+
self._shape = src.shape
561561
# Compute reasonable values for chunks and blocks
562562
cparams = blosc2.CParams(clevel=0)
563563
self.chunks, self.blocks = blosc2.compute_chunks_blocks(
564564
self.shape, chunks, blocks, self.dtype, **{"cparams": cparams}
565565
)
566566

567+
@property
568+
def src(self):
569+
"""The source object that this proxy wraps."""
570+
return self._src
571+
572+
@property
573+
def shape(self):
574+
"""The shape of the source array."""
575+
return self._shape
576+
577+
@property
578+
def dtype(self):
579+
"""The data type of the source array."""
580+
return self._dtype
581+
567582
def __getitem__(self, item: slice | list[slice]) -> np.ndarray:
568583
"""
569584
Get a slice as a numpy.ndarray (via this proxy).
@@ -577,7 +592,7 @@ def __getitem__(self, item: slice | list[slice]) -> np.ndarray:
577592
out: numpy.ndarray
578593
An array with the data slice.
579594
"""
580-
return self.src[item]
595+
return self._src[item]
581596

582597

583598
def jit(func=None, *, out=None, **kwargs): # noqa: C901

0 commit comments

Comments
 (0)