[+] fix ruff issues

This commit is contained in:
Siarhei Siniak 2025-05-20 10:56:48 +03:00
parent 5491f92bbe
commit cf9ede1dde
3 changed files with 23 additions and 17 deletions

@ -5,12 +5,9 @@ import cv2
import re import re
import json import json
import io import io
import glob
import xarray import xarray
import numpy import numpy
import json
import glob import glob
import io
import os import os
import pandas import pandas
import pickle import pickle
@ -360,7 +357,7 @@ def kernel_7(
import torch.optim as optim import torch.optim as optim
import torchvision.transforms as transforms import torchvision.transforms as transforms
import torchvision.datasets as datasets import torchvision.datasets as datasets
import torchvision.models as models import torchvision.models
from torch.autograd import Variable from torch.autograd import Variable
@ -1731,7 +1728,10 @@ def kernel_28(
--outdir %s --outdir %s
''' % (t13, t2) ''' % (t13, t2)
if False: if False:
pprint.pprint([t4, t2, t6]) pprint.pprint([
# t4,
t2, t6,
])
with subprocess.Popen(t6, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: with subprocess.Popen(t6, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p:
if False: if False:
pprint.pprint(p.communicate()) pprint.pprint(p.communicate())
@ -1794,7 +1794,7 @@ def kernel_29(video_path=None, video_id=None,):
o['data'] o['data']
for o in t1 for o in t1
], []) ], [])
t10 = re.compile('frame-(\d+)\.jpg') t10 = re.compile(r'frame-(\d+)\.jpg')
for i, o in enumerate(t8): for i, o in enumerate(t8):
o['frame_id'] = int(t10.match(o['image_id'])[1]) o['frame_id'] = int(t10.match(o['image_id'])[1])
@ -2035,7 +2035,7 @@ def kernel_30(
def kernel_31(image_id, image_size, keypoints): def kernel_31(image_id, image_size, keypoints):
def get_angle(a,b): def get_angle(a,b):
from math import sqrt, acos, degrees, atan, degrees from math import sqrt, acos, degrees, atan
#print(a) #print(a)
#print(b) #print(b)
del_y = a[1]-b[1] del_y = a[1]-b[1]
@ -2054,7 +2054,7 @@ def kernel_31(image_id, image_size, keypoints):
def angle_gor(a,b,c,d): def angle_gor(a,b,c,d):
import numpy as np import numpy as np
from math import sqrt, acos, degrees, atan, degrees from math import sqrt, acos, degrees, atan
ab=[a[0]-b[0],a[1]-b[1]] ab=[a[0]-b[0],a[1]-b[1]]
ab1=[c[0]-d[0],c[1]-d[1]] ab1=[c[0]-d[0],c[1]-d[1]]
cos = \ cos = \
@ -2075,14 +2075,14 @@ def kernel_31(image_id, image_size, keypoints):
def sit_ang(a,b,c,d): def sit_ang(a,b,c,d):
ang=angle_gor(a,b,c,d) ang=angle_gor(a,b,c,d)
s1=0 s1=0
if ang != None: if not ang is None:
#print("Angle",ang) #print("Angle",ang)
if ang < 120 and ang>40: if ang < 120 and ang>40:
s1=1 s1=1
return s1 return s1
def sit_rec(a,b,c,d): def sit_rec(a,b,c,d):
from math import sqrt, acos, degrees, atan, degrees from math import sqrt, acos, degrees, atan
ab = [a[0] - b[0], a[1] - b[1]] ab = [a[0] - b[0], a[1] - b[1]]
ab1 = [c[0] - d[0], c[1] - d[1]] ab1 = [c[0] - d[0], c[1] - d[1]]
@ -2294,7 +2294,7 @@ def kernel_36():
""" """
import os # import os
from os.path import exists, join, basename, splitext from os.path import exists, join, basename, splitext
git_repo_url = 'https://github.com/CMU-Perceptual-Computing-Lab/openpose.git' git_repo_url = 'https://github.com/CMU-Perceptual-Computing-Lab/openpose.git'
@ -2318,8 +2318,8 @@ def kernel_36():
"""## From a Google Drive's folder""" """## From a Google Drive's folder"""
import os # import os
from os.path import exists, join, basename, splitext # from os.path import exists, join, basename, splitext
folder_path = '/content/drive/My Drive/openpose/' folder_path = '/content/drive/My Drive/openpose/'
files = os.listdir(folder_path) files = os.listdir(folder_path)
@ -2354,8 +2354,8 @@ def kernel_36():
# video_folder = os.path.dirname(colab_video_path) # video_folder = os.path.dirname(colab_video_path)
# video_base_name = os.path.basename(colab_video_path) # video_base_name = os.path.basename(colab_video_path)
# print(video_base_name) # print(video_base_name)
import os # import os
from os.path import exists, join, basename, splitext # from os.path import exists, join, basename, splitext
#colab_video_path = '/content/drive/My Drive/bachata.mp4' #colab_video_path = '/content/drive/My Drive/bachata.mp4'
colab_video_path = '/content/output.mp4' colab_video_path = '/content/output.mp4'
colab_openpose_video_path = colab_video_path.replace('.mp4', '') + '-openpose.mp4' colab_openpose_video_path = colab_video_path.replace('.mp4', '') + '-openpose.mp4'

@ -88,6 +88,8 @@ ignore = [
'F841', 'F841',
# fix * imports # fix * imports
'F403', 'F403',
# don't care about trailing new lines
'W292',
] ]
select = ['E', 'F', 'I', 'W', 'INT'] select = ['E', 'F', 'I', 'W', 'INT']
@ -100,7 +102,11 @@ detect-same-package = true
# known-third-party = ["odf", "qt", "templite", "tinycss", "css_selectors"] # known-third-party = ["odf", "qt", "templite", "tinycss", "css_selectors"]
relative-imports-order = "closest-to-furthest" relative-imports-order = "closest-to-furthest"
split-on-trailing-comma = true split-on-trailing-comma = true
section-order = ['__python__', "future", "standard-library", "third-party", "first-party", "local-folder"] section-order = [
# '__python__',
"future",
"standard-library", "third-party", "first-party", "local-folder"
]
force-wrap-aliases = true force-wrap-aliases = true
# [tool.ruff.lint.isort.sections] # [tool.ruff.lint.isort.sections]