Skip to content

Commit cb64e55

Browse files
committed
Merge branch 'develop' into release/2.0.0
2 parents 02c6387 + 84cb879 commit cb64e55

File tree

5 files changed

+114
-1
lines changed

5 files changed

+114
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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

docs/source/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ What's new in IMAS-Python 1.2.0
2929
New features and improvements
3030
'''''''''''''''''''''''''''''
3131

32-
- Add :py:func:`imaspy.DBEntry.get_sample` (requires imas_core >= 5.4.0)
32+
- Add :py:func:`imaspy.DBEntry.get_sample <imas.db_entry.DBEntry.get_sample>` (requires imas_core >= 5.4.0)
3333
- Improved validation of netCDF files
3434
- Improve compatibility with the UDA backend in imas_core
3535
- Extend the support of netCDF to >= 1.4.1 (without complex numbers)

imas/backends/imas_core/al_context.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ 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+
"""
285294
imas.backends.imas_core.db_entry_helpers._get_child(child, self)
286295

287296
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: The path to the data in the IDS.
177+
fillvalue: The value to fill the tensor with. Can be of any type,
178+
including strings.
179+
180+
Returns:
181+
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,14 @@ 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
322+
child node based on its metadata.
323+
324+
Args:
325+
child: The child IDS node which should be lazy loaded.
326+
327+
"""
320328
metadata = child.metadata
321329
path = metadata.path_string
322330
data_type = metadata.data_type
@@ -366,12 +374,44 @@ def get_child(self, child):
366374

367375

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

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

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

0 commit comments

Comments
 (0)