Skip to content

Commit 0d02caf

Browse files
committed
Move pad_number() to strtools
1 parent b76d60b commit 0d02caf

2 files changed

Lines changed: 25 additions & 25 deletions

File tree

src/imcflibs/imagej/misc.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -627,31 +627,6 @@ def save_image_in_format(imp, format, out_dir, series, pad_number, split_channel
627627
current_imp.close()
628628

629629

630-
def pad_number(index, pad_length=2):
631-
"""Pad a number with leading zeros to a specified length.
632-
633-
Parameters
634-
----------
635-
index : int or str
636-
The number to be padded
637-
pad_length : int, optional
638-
The total length of the resulting string after padding, by default 2
639-
640-
Returns
641-
-------
642-
str
643-
The padded number as a string
644-
645-
Examples
646-
--------
647-
>>> pad_number(7)
648-
'07'
649-
>>> pad_number(42, 4)
650-
'0042'
651-
"""
652-
return str(index).zfill(pad_length)
653-
654-
655630
def locate_latest_imaris(paths_to_check=None):
656631
"""Find paths to latest installed Imaris or ImarisFileConverter version.
657632

src/imcflibs/strtools.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,28 @@ def alphanum_key(key):
150150
return [convert(c) for c in re.split("([0-9]+)", key)]
151151

152152
return sorted(data, key=alphanum_key)
153+
154+
155+
def pad_number(index, pad_length=2):
156+
"""Pad a number with leading zeros to a specified length.
157+
158+
Parameters
159+
----------
160+
index : int or str
161+
The number to be padded
162+
pad_length : int, optional
163+
The total length of the resulting string after padding, by default 2
164+
165+
Returns
166+
-------
167+
str
168+
The padded number as a string
169+
170+
Examples
171+
--------
172+
>>> pad_number(7)
173+
'07'
174+
>>> pad_number(42, 4)
175+
'0042'
176+
"""
177+
return str(index).zfill(pad_length)

0 commit comments

Comments
 (0)