🔧 Fix all ruff typo errors & test CI/CD workflow (#109)
* [chore] Fix ruff typo * [robot] Fix welcome robot
This commit is contained in:
@@ -41,7 +41,7 @@ def readimgs(image_paths: list[str]) -> list[np.ndarray]:
|
||||
if image is None:
|
||||
raise ValueError(f"Image at {path} could not be read.")
|
||||
if image.dtype == np.uint16:
|
||||
_logger.warning(f'Converting {path} to 8-bit, image may be lossy.')
|
||||
_logger.warning(f"Converting {path} to 8-bit, image may be lossy.")
|
||||
image = cv2.convertScaleAbs(image, alpha=(255.0 / 65535.0))
|
||||
|
||||
channels = 1 if len(image.shape) == 2 else image.shape[2]
|
||||
@@ -112,7 +112,7 @@ def transform(images: List[Union[np.ndarray, Image.Image]]) -> List[torch.Tensor
|
||||
|
||||
assert IMG_CHANNELS == 1, "Only support grayscale images for now"
|
||||
images = [
|
||||
np.array(img.convert('RGB')) if isinstance(img, Image.Image) else img for img in images
|
||||
np.array(img.convert("RGB")) if isinstance(img, Image.Image) else img for img in images
|
||||
]
|
||||
images = [trim_white_border(image) for image in images]
|
||||
images = [general_transform_pipeline(image) for image in images]
|
||||
|
||||
@@ -21,7 +21,7 @@ def _change(input_str, old_inst, new_inst, old_surr_l, old_surr_r, new_surr_l, n
|
||||
j = start + 1
|
||||
escaped = False
|
||||
while j < n and count > 0:
|
||||
if input_str[j] == '\\' and not escaped:
|
||||
if input_str[j] == "\\" and not escaped:
|
||||
escaped = True
|
||||
j += 1
|
||||
continue
|
||||
@@ -71,10 +71,10 @@ def change_all(input_str, old_inst, new_inst, old_surr_l, old_surr_r, new_surr_l
|
||||
for p in pos[::-1]:
|
||||
res[p:] = list(
|
||||
_change(
|
||||
''.join(res[p:]), old_inst, new_inst, old_surr_l, old_surr_r, new_surr_l, new_surr_r
|
||||
"".join(res[p:]), old_inst, new_inst, old_surr_l, old_surr_r, new_surr_l, new_surr_r
|
||||
)
|
||||
)
|
||||
res = ''.join(res)
|
||||
res = "".join(res)
|
||||
return res
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ def add_newlines(latex_str: str) -> str:
|
||||
|
||||
# 4. Cleanup: Collapse multiple consecutive newlines into a single newline.
|
||||
# This handles cases where the replacements above might have created \n\n.
|
||||
processed_str = re.sub(r'\n{2,}', '\n', processed_str)
|
||||
processed_str = re.sub(r"\n{2,}", "\n", processed_str)
|
||||
|
||||
# Remove leading/trailing whitespace (including potential single newlines
|
||||
# at the very start/end resulting from the replacements) from the entire result.
|
||||
|
||||
Reference in New Issue
Block a user