Skip to content

Commit

Permalink
Including more documentattion
Browse files Browse the repository at this point in the history
Signed-off-by: Julio Faracco <[email protected]>
  • Loading branch information
jcfaracco committed May 1, 2024
1 parent 71798f6 commit 04b6940
Show file tree
Hide file tree
Showing 15 changed files with 1,292 additions and 33 deletions.
4 changes: 4 additions & 0 deletions dasf/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env python3

""" Init module for Datasets objects. """

from dasf.datasets.base import * # noqa
from dasf.datasets.datasets import * # noqa

Expand Down
52 changes: 46 additions & 6 deletions dasf/datasets/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python3

""" Base module for most of the DASF Datasets. """

import json
import os
from numbers import Number
Expand Down Expand Up @@ -69,6 +71,7 @@ def __init__(self,
root: str = None,
*args,
**kwargs):
""" Constructor of the object Dataset. """
super().__init__(*args, **kwargs)

# Dataset internals
Expand Down Expand Up @@ -145,7 +148,7 @@ def __init__(self,
download: bool = False,
root: str = None,
chunks="auto"):

""" Constructor of the object DatasetArray. """
Dataset.__init__(self, name, download, root)

self._chunks = chunks
Expand All @@ -159,6 +162,22 @@ def __init__(self,
self._root = os.path.dirname(root)

def __operator_check__(self, other):
"""Check what type of the data we are handling
Examples:
DatasetArray with array-like; or
DatasetArray with DatasetArray
Parameters
----------
other : Any
array-like of DatasetArray for the operation.
Returns
-------
data : Any
A data representing the internal array or the class itself.
"""
assert self._data is not None, "Data is not loaded yet."
if isinstance(other, DatasetArray):
return other._data
Expand All @@ -171,10 +190,23 @@ def __repr__(self):
return repr(self._data)

def __array__(self, dtype=None):
"""Array interface is required to support most of the array functions.
Parameters
----------
dtype : Any
Type of the internal array, default=None (not used)
Returns
-------
data : Any
A data representing the internal array or the class itself.
"""
assert self._data is not None, "Data is not loaded yet."
return self._data

def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):

assert self._data is not None, "Data is not loaded yet."
if method == '__call__':
scalars = []
Expand Down Expand Up @@ -398,6 +430,13 @@ def _load_cpu(self):
return self

def from_array(self, array):
"""Load data from an existing array.
Parameters
----------
array : array-like
Input data to be initialized.
"""
self._data = array
self.__copy_attrs_from_data()

Expand Down Expand Up @@ -469,7 +508,7 @@ def __init__(self,
root: str = None,
backend: str = None,
chunks=None):

""" Constructor of the object DatasetZarr. """
Dataset.__init__(self, name, download, root)

self._backend = backend
Expand Down Expand Up @@ -802,7 +841,7 @@ def __init__(self,
root: str = None,
chunks="auto",
dataset_path: str = None):

""" Constructor of the object DatasetHDF5. """
Dataset.__init__(self, name, download, root)

self._chunks = chunks
Expand Down Expand Up @@ -955,6 +994,7 @@ def __init__(self,
root: str = None,
chunks=None,
data_var=None):
""" Constructor of the object DatasetXarray. """
Dataset.__init__(self, name, download, root)

self._chunks = chunks
Expand Down Expand Up @@ -1121,7 +1161,7 @@ def __init__(self,
download: bool = False,
root: str = None,
chunks="auto"):

""" Constructor of the object DatasetLabeled. """
Dataset.__init__(self, name, download, root)

self._chunks = chunks
Expand Down Expand Up @@ -1295,7 +1335,7 @@ def __init__(self,
download: bool = True,
root: str = None,
chunks="auto"):

""" Constructor of the object DatasetDataFrame. """
Dataset.__init__(self, name, download, root)

self._chunks = chunks
Expand Down Expand Up @@ -1442,7 +1482,7 @@ def __init__(self,
download: bool = True,
root: str = None,
chunks="auto"):

""" Constructor of the object DatasetParquet. """
DatasetDataFrame.__init__(self, name, download, root, chunks)

def _lazy_load_gpu(self):
Expand Down
Loading

0 comments on commit 04b6940

Please sign in to comment.