Skip to content

Commit 5f08a36

Browse files
committed
enh: add docstring and doctests for nitransforms.io.get_linear_factory
1 parent a94e577 commit 5f08a36

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

nitransforms/io/__init__.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
"""Read and write transforms."""
4+
45
from nitransforms.io import afni, fsl, itk, lta, x5
56
from nitransforms.io.base import TransformIOError, TransformFileError
67

@@ -27,7 +28,37 @@
2728

2829

2930
def get_linear_factory(fmt, is_array=True):
30-
"""Return the type required by a given format."""
31+
"""
32+
Return the type required by a given format.
33+
34+
Parameters
35+
----------
36+
fmt : :obj:`str`
37+
A format identifying string.
38+
is_array : :obj:`bool`
39+
Whether the array version of the class should be returned.
40+
41+
Returns
42+
-------
43+
type
44+
The class object (not an instance) of the linear transfrom to be created
45+
(for example, :obj:`~nitransforms.io.itk.ITKLinearTransform`).
46+
47+
Examples
48+
--------
49+
>>> get_linear_factory("itk")
50+
<class 'nitransforms.io.itk.ITKLinearTransformArray'>
51+
>>> get_linear_factory("itk", is_array=False)
52+
<class 'nitransforms.io.itk.ITKLinearTransform'>
53+
>>> get_linear_factory("fsl")
54+
<class 'nitransforms.io.fsl.FSLLinearTransformArray'>
55+
>>> get_linear_factory("fsl", is_array=False)
56+
<class 'nitransforms.io.fsl.FSLLinearTransform'>
57+
>>> get_linear_factory("fakepackage") # doctest: +IGNORE_EXCEPTION_DETAIL
58+
Traceback (most recent call last):
59+
TypeError: Unsupported transform format <fakepackage>.
60+
61+
"""
3162
if fmt.lower() not in _IO_TYPES:
3263
raise TypeError(f"Unsupported transform format <{fmt}>.")
3364

0 commit comments

Comments
 (0)