Then implement the Examples as unit tests.
Originally posted by @lguerard in #49 (comment)
|
def pad_number(index, pad_length=2): |
|
"""Pad a number with leading zeros to a specified length. |
|
|
|
Parameters |
|
---------- |
|
index : int or str |
|
The number to be padded |
|
pad_length : int, optional |
|
The total length of the resulting string after padding, by default 2 |
|
|
|
Returns |
|
------- |
|
str |
|
The padded number as a string |
|
|
|
Examples |
|
-------- |
|
>>> pad_number(7) |
|
'07' |
|
>>> pad_number(42, 4) |
|
'0042' |
|
""" |
|
return str(index).zfill(pad_length) |
Then implement the Examples as unit tests.
Originally posted by @lguerard in #49 (comment)
python-imcflibs/src/imcflibs/imagej/misc.py
Lines 601 to 623 in f0a1c9c