Skip to content

Commit 2f2a55b

Browse files
author
Uli Köhler
committed
Fix docstring linting errors in UliEngineering/Utils/ files
1 parent 65c121d commit 2f2a55b

4 files changed

Lines changed: 22 additions & 21 deletions

File tree

UliEngineering/Utils/NumPy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def numpy_resize_insert(arr, val, index, growth_factor=1.5, min_growth=1000, max
1212
"""
1313
Append a value to a 1D numpy array. Resize dynamically if required.
1414
Returns the new array (which may be the same as the old array).
15-
No resize is performed if the array is already large enough
15+
No resize is performed if the array is already large enough.
1616
1717
Supports non-continous insertion of values (i.e. index must not grow monotonically).
1818
@@ -64,7 +64,7 @@ def invert_bijection(arr):
6464
returned by np.argsort().
6565
6666
For each value x in the given array at index i,
67-
the new array will
67+
the new array will have the value i at index x.
6868
6969
Preconditions (not checked):
7070
- All elements must be >= 0 and < arr.size
@@ -97,7 +97,7 @@ def apply_pairwise_1d(valuesA, valuesB, fn, dtype=float):
9797
"""
9898
Given two 1d arrays, generates a 2d matrix
9999
containing at any coordinate [x,y] the value of fn(valuesA[x], valuesB[y]).
100-
If valu
100+
If valuesB is None, valuesA is used for both arrays.
101101
102102
The input values do not neccessarily have to be numbers and can be
103103
non-uniform throughout the input list data type,
@@ -130,7 +130,7 @@ def ngrams(arr, n, closed=False):
130130
"""
131131
Yield ngrams of subsequent entries from an arbitrarily-shaped array.
132132
For example, with arr=[1,2,3,4,5,6]
133-
and n=2, yields [[1,2][2,3],[3,4],[4,5],[5,6]]
133+
and n=2, yields [[1,2][2,3],[3,4],[4,5],[5,6]].
134134
if closed=False or [[1,2][2,3],[3,4],[4,5],[5,6],[6,1]] if closed=True.
135135
136136
For n=2, this function behaves similarly to

UliEngineering/Utils/String.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def suffix_list(s: str) -> List[str]:
3636
Return all suffixes for a string, including the string itself,
3737
in order of ascending length.
3838
39-
Example: "foobar" => ['r', 'ar', 'bar', 'obar', 'oobar', 'foobar']
39+
Example: "foobar" => ['r', 'ar', 'bar', 'obar', 'oobar', 'foobar'].
4040
"""
4141
return [s[-i:] for i in range(1, len(s) + 1)]
4242

UliEngineering/Utils/Temporary.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class AutoDeleteTempfileGenerator:
1111
"""
12-
A wrapper for temporary files and directories that are automatically automatically
12+
A wrapper for temporary files and directories that are automatically
1313
deleted once this class is deleted or deleteAll() is called.
1414
1515
This is not comparable to tempfile.TemporaryFile as the TemporaryFile instance
@@ -29,30 +29,30 @@ def __del__(self):
2929
self.delete_all()
3030

3131
def mkstemp(self, suffix='', prefix='tmp', directory=None):
32-
"""Same as tempfile.mktemp(), but creates a file managed by this class instance"""
32+
"""Same as tempfile.mktemp(), but creates a file managed by this class instance."""
3333
handle, fname = tempfile.mkstemp(suffix, prefix, directory)
3434
self.tempfiles.append(fname)
3535
return (handle, fname)
3636

3737
def mkftemp(self, suffix='', prefix='tmp', directory=None, mode='w'):
3838
"""
3939
Wrapper for self.mkstemp() that opens the OS-level file handle
40-
as a normal Python handle with the given mode
40+
as a normal Python handle with the given mode.
4141
"""
4242
handle, fname = self.mkstemp(suffix, prefix, directory)
4343
handle = os.fdopen(handle, mode)
4444
return (handle, fname)
4545

4646
def mkdtemp(self, suffix='', prefix='tmp', directory=None):
47-
"""Same as tempfile.mkdtemp(), but creates a file managed by this class instance"""
47+
"""Same as tempfile.mkdtemp(), but creates a file managed by this class instance."""
4848
fname = tempfile.mkdtemp(suffix, prefix, directory)
4949
self.tempdirs.append(fname)
5050
return fname
5151

5252
def delete_all(self):
5353
"""
5454
Force-delete all files and directories created by this instance.
55-
The class instance may be used without restriction after this call
55+
The class instance may be used without restriction after this call.
5656
"""
5757
#
5858
for filename in self.tempfiles:

UliEngineering/Utils/ZIP.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99

1010
def create_zip_from_directory(zippath, directory, include_rootdir=True):
1111
"""
12-
Create a ZIP file from a directory that exist
12+
Create a ZIP file from a directory that exists
1313
on the filesystem. Adds all files recursively,
1414
naming them correctly.
1515
1616
Parameters
1717
----------
1818
zippath : path-like
19-
The path of the ZIP file to write
19+
The path of the ZIP file to write.
2020
directory : path-like
21-
The directory to compress
21+
The directory to compress.
2222
include_rootdir : bool
23-
if True, the basename of the directory is prepended
23+
If True, the basename of the directory is prepended
2424
to each filename in the ZIP (i.e. when running unzip
25-
on the ZIP, one directory is extracted)
25+
on the ZIP, one directory is extracted).
2626
"""
2727
basename = os.path.basename(directory)
2828
with zipfile.ZipFile(zippath, mode="w") as zipout:
@@ -50,18 +50,19 @@ def read_from_zip(zippath, filepaths, binary=True):
5050
Parameters
5151
----------
5252
zippath : path-like
53-
The path of the ZIP file
53+
The path of the ZIP file.
5454
filepath : str or iterable of strings
55-
The path of the file inside the ZIP
56-
Multiple paths allowed (=> list is returned)
55+
The path of the file inside the ZIP.
56+
Multiple paths allowed (=> list is returned).
5757
binary : bool
5858
If True, returns a io.BytesIO().
59-
If False, returns a io.StringIO()
59+
If False, returns a io.StringIO().
6060
6161
Returns
6262
-------
63-
If filepath is a string, a single file-like object (in-memory).
64-
If filepath is any other iterable, a list of file-like in-memory objs.
63+
io.BytesIO or io.StringIO or list
64+
If filepath is a string, a single file-like object (in-memory).
65+
If filepath is any other iterable, a list of file-like in-memory objs.
6566
"""
6667
iof = io.BytesIO if binary else io.StringIO
6768
# Handle single file using the same code as multiple files

0 commit comments

Comments
 (0)