Skip to content

Commit

Permalink
update doctring for path
Browse files Browse the repository at this point in the history
  • Loading branch information
kzqureshi committed Dec 12, 2024
1 parent 559a51f commit 32a59dc
Showing 1 changed file with 90 additions and 23 deletions.
113 changes: 90 additions & 23 deletions micromagneticdata/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,22 @@ class Data:
Examples
--------
1. Creating data object.
1. Creating data object using `dirname`
>>> import os
>>> import micromagneticdata as mdata
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = mdata.Data(name='rectangle', dirname=dirname)
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
2. Creating data object using `name` and `dirname`
>>> import os
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = mdata.Data(name='rectangle', dirname=dirname)
...
"""

def __init__(self, name=None, dirname="./", path=None):
Expand Down Expand Up @@ -92,13 +96,22 @@ def __repr__(self):
Examples
--------
1. Representation string.
1. Representation string using `path`
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data
Data(...)
2. Representation string using `name` and `dirname`
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data
Data(...)
Expand All @@ -121,13 +134,22 @@ def info(self):
Examples
--------
1. Getting information about data.
1. Getting information about data using `path`.
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data.info
drive_number...
2. Getting information about data using `name` and `dirname`.
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data.info
drive_number...
"""
Expand All @@ -145,13 +167,22 @@ def n(self):
Examples
--------
1. Getting the number of drives.
1. Getting the number of drives using 'path'.
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data.n
7
1. Getting the number of drives using `name` and 'dirname'.
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data.n
7
Expand All @@ -178,13 +209,28 @@ def __getitem__(self, item):
Examples
--------
1. Getting drive.
1. Getting drive using `path`
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data.n
7
>>> data[0] # first (0th) drive
OOMMFDrive(...)
>>> data[1] # second (1th) drive
Mumax3Drive(...)
>>> data[-1] # last (6th) drive
OOMMFDrive(...)
2. Getting drive using `name` and `dirname`
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data.n
7
>>> data[0] # first (0th) drive
Expand Down Expand Up @@ -214,13 +260,25 @@ def __iter__(self):
Examples
--------
1. Iterating data object.
1. Iterating data object using `path`
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data.n
7
>>> len(list(data))
7
2. Iterating data object using `name` and `dirname`
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data.n
7
>>> len(list(data))
Expand Down Expand Up @@ -250,13 +308,22 @@ def selector(self, description="drive", **kwargs):
Examples
--------
1. Selection widget.
1. Selection widget using `path`
>>> import micromagneticdata as mdata
...
>>> data = mdata.Data(
path="/home/zulfigak/ubermag_devtools/repos/micromagneticdata/micromagneticdata/tests/test_sample/rectangle"
)
>>> data.selector()
BoundedIntText(...)
2. Selection widget using `name` and `dirname`
>>> import os
>>> import micromagneticdata as md
...
>>> dirname = os.path.join(os.path.dirname(__file__), 'tests', 'test_sample')
>>> data = md.Data(name='rectangle', dirname=dirname)
>>> data = mdata.Data(name='rectangle', dirname=dirname)
>>> data.selector()
BoundedIntText(...)
Expand Down

0 comments on commit 32a59dc

Please sign in to comment.