Skip to content

Commit 2e3b1b1

Browse files
prasad-sawantdesaiolivhoenen
authored andcommitted
added workflow for sphinx doc generation and fixed docstrings
1 parent 062266a commit 2e3b1b1

File tree

5 files changed

+119
-2
lines changed

5 files changed

+119
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: verify-sphinx-doc-generation
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: ubuntu-22.04
11+
12+
steps:
13+
- name: Checkout IMAS-Python sources
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
with:
20+
# until saxonche is available in 3.13
21+
# https://saxonica.plan.io/issues/6561
22+
python-version: "<3.13"
23+
24+
- name: Display Python version
25+
run: python -c "import sys; print(sys.version)"
26+
27+
28+
- name: Set up Python virtual environment
29+
run: |
30+
python -m venv venv
31+
source venv/bin/activate
32+
33+
- name: Install build dependencies
34+
run: |
35+
pip install --upgrade pip setuptools wheel build
36+
37+
- name: Build package
38+
run: |
39+
rm -rf dist
40+
python -m build .
41+
42+
- name: Install package and dependencies
43+
run: |
44+
pip install "$(readlink -f dist/*.whl)[docs,netcdf]"
45+
46+
- name: Debug dependencies
47+
run: |
48+
pip freeze
49+
50+
- name: Build Sphinx documentation
51+
run: |
52+
export SPHINXOPTS='-W -n --keep-going'
53+
make -C docs clean html
54+
55+
- name: Deactivate virtual environment
56+
run: deactivate

docs/source/changelog.rst

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

66
What's new in IMAS-Python 1.2.0
7-
--------------------------
7+
-------------------------------
88

99
New features and improvements
1010
'''''''''''''''''''''''''''''
1111

12-
- Add :py:func:`imaspy.DBEntry.get_sample` (requires imas_core >= 5.4.0)
12+
- Add :py:func:`imas.DBEntry.get_sample` previously imaspy.DBEntry.get_sample (requires imas_core >= 5.4.0)
1313
- Improved validation of netCDF files
1414
- Improve compatibility with the UDA backend in imas_core
1515
- Extend the support of netCDF to >= 1.4.1 (without complex numbers)

imas/backends/imas_core/al_context.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ def __init__(
282282
"""Potential weak reference to opened context."""
283283

284284
def get_child(self, child):
285+
"""
286+
Retrieve a child entry from the field.
287+
288+
Args:
289+
child (str): The name or identifier of the child entry to retrieve.
290+
291+
Returns:
292+
The child entry retrieved from the database.
293+
294+
Raises:
295+
Exception: If the child entry cannot be found or an error occurs during retrieval.
296+
"""
285297
imas.backends.imas_core.db_entry_helpers._get_child(child, self)
286298

287299
def get_context(self) -> ALContext:

imas/backends/netcdf/ids_tensorizer.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ def filter_coordinates(self, path: str) -> str:
169169
)
170170

171171
def tensorize(self, path, fillvalue):
172+
"""
173+
Tensorizes the data at the given path with the specified fill value.
174+
175+
Args:
176+
path (str): The path to the data in the NetCDF file.
177+
fillvalue (any): The value to fill the tensor with. Can be of any type,
178+
including strings.
179+
180+
Returns:
181+
numpy.ndarray: A tensor filled with the data from the specified path.
182+
"""
172183
dimensions = self.ncmeta.get_dimensions(path, self.homogeneous_time)
173184
shape = tuple(self.dimension_size[dim] for dim in dimensions)
174185

imas/backends/netcdf/nc2ids.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ def __init__(self, nc2ids, index=()):
317317
self.index = index
318318

319319
def get_child(self, child):
320+
"""
321+
Retrieves and sets the appropriate context or value for a given child node based on its metadata.
322+
323+
Args:
324+
child: The child node for which the context or value is to be set. The child node should have metadata attributes.
325+
326+
"""
320327
metadata = child.metadata
321328
path = metadata.path_string
322329
data_type = metadata.data_type
@@ -366,12 +373,43 @@ def get_child(self, child):
366373

367374

368375
class LazyArrayStructContext(LazyContext):
376+
"""
377+
LazyArrayStructContext is a subclass of LazyContext that provides a context for
378+
handling structured arrays in a lazy manner. It is initialized with a NetCDF to
379+
IDS mapping object, an index, and a size.
380+
"""
369381
def __init__(self, nc2ids, index, size):
382+
"""
383+
Initialize the instance with nc2ids, index, and size.
384+
385+
Args:
386+
nc2ids: The NetCDF to IDS mapping object.
387+
index: The index within the NetCDF file.
388+
size: The size of the data to be processed.
389+
"""
370390
super().__init__(nc2ids, index)
371391
self.size = size
372392

373393
def get_context(self):
394+
"""
395+
Returns the current context.
396+
397+
This method returns the current instance of the class, which is expected
398+
to have a 'size' attribute as required by IDSStructArray.
399+
400+
Returns:
401+
self: The current instance of the class.
402+
"""
374403
return self # IDSStructArray expects to get something with a size attribute
375404

376405
def iterate_to_index(self, index: int) -> LazyContext:
406+
"""
407+
Iterates to a specified index and returns a LazyContext object.
408+
409+
Args:
410+
index (int): The index to iterate to.
411+
412+
Returns:
413+
LazyContext: A LazyContext object initialized with the updated index.
414+
"""
377415
return LazyContext(self.nc2ids, self.index + (index,))

0 commit comments

Comments
 (0)