Skip to content

Commit b4816eb

Browse files
committed
Merge remote-tracking branch 'origin/docs' into dev
2 parents f70d78b + eb2cafc commit b4816eb

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

exdir/core/group.py

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def __init__(self, root_directory, parent_path, object_name, io_mode=None,
6262
def create_dataset(self, name, shape=None, dtype=None,
6363
data=None, fillvalue=None):
6464
"""
65-
Create a dataset.
65+
Create a dataset. This will create a folder on the filesystem with the given
66+
name, an exdir.yaml file that identifies the folder as an Exdir Dataset,
67+
and a data.npy file that contains the data.
6668
6769
Parameters
6870
----------
@@ -86,13 +88,16 @@ def create_dataset(self, name, shape=None, dtype=None,
8688
8789
Returns
8890
-------
89-
A reference to the newly created dataset.
91+
The newly created Dataset.
9092
9193
Raises
9294
------
9395
FileExistsError
9496
If an object with the same `name` already exists.
9597
98+
See also
99+
--------
100+
require_dataset
96101
"""
97102
exob._assert_valid_name(name, self)
98103

@@ -134,8 +139,9 @@ def create_dataset(self, name, shape=None, dtype=None,
134139

135140
def create_group(self, name):
136141
"""
137-
Create a subgroup with the given name.
138-
This will create a subfolder on the file system.
142+
Create a group. This will create a folder on the filesystem with the
143+
given name and an exdir.yaml file that identifies the folder as a
144+
group. A group can contain multiple groups and datasets.
139145
140146
Parameters
141147
----------
@@ -149,7 +155,11 @@ def create_group(self, name):
149155
150156
Returns
151157
-------
152-
A reference to the newly created group.
158+
The newly created Group.
159+
160+
See also
161+
--------
162+
require_group
153163
"""
154164
if self.io_mode == self.OpenMode.READ_ONLY:
155165
raise IOError("Cannot write data to file in read only ("r") mode")
@@ -193,7 +203,11 @@ def require_group(self, name):
193203
194204
Returns
195205
-------
196-
A reference to the newly created group.
206+
The existing or created group.
207+
208+
See also
209+
--------
210+
create_group
197211
"""
198212
path = utils.path.name_to_asserted_group_path(name)
199213
if len(path.parts) > 1:
@@ -305,6 +319,14 @@ def require_dataset(self, name, shape=None, dtype=None, exact=False,
305319
return current_object
306320

307321
def __contains__(self, name):
322+
"""
323+
Checks the existence of an object with the given name in the group.
324+
325+
Parameters
326+
----------
327+
name: str
328+
the case-sensitive name of the object
329+
"""
308330
if name == ".":
309331
return True
310332
if name == "":
@@ -314,6 +336,19 @@ def __contains__(self, name):
314336
return exob.is_exdir_object(directory)
315337

316338
def __getitem__(self, name):
339+
"""
340+
Retrieves the object with the given name if it exists in the group.
341+
342+
Parameters
343+
----------
344+
name: str
345+
the case-sensitive name of the object to retrieve
346+
347+
Raises
348+
------
349+
KeyError:
350+
if the name does not correspond to an exdir object in the group
351+
"""
317352
path = utils.path.name_to_asserted_group_path(name)
318353
if len(path.parts) > 1:
319354
top_directory = path.parts[0]
@@ -365,6 +400,17 @@ def _dataset(self, name):
365400
)
366401

367402
def __setitem__(self, name, value):
403+
"""
404+
Set or create a dataset with the given name from the given value.
405+
406+
Parameters
407+
----------
408+
name: str
409+
name of the existing or new dataset
410+
value: object
411+
value that will be used to create a new or set
412+
the contents of an existing dataset
413+
"""
368414
path = utils.path.name_to_asserted_group_path(name)
369415
if len(path.parts) > 1:
370416
self[path.parent][path.name] = value
@@ -409,6 +455,9 @@ def values(self):
409455
return abc.ValuesView(self)
410456

411457
def __iter__(self):
458+
"""
459+
Iterate over all the objects in the group.
460+
"""
412461
# NOTE os.walk is way faster than os.listdir + os.path.isdir
413462
directories = next(os.walk(str(self.directory)))[1]
414463
for name in sorted(directories):

0 commit comments

Comments
 (0)