Visitar URL original
Black coding style · github2016-yuan/DeepLabCut@e2c8047 · GitHub
Skip to content

Commit e2c8047

Browse files
committed
Black coding style
1 parent 44a9ac1 commit e2c8047

58 files changed

Lines changed: 2069 additions & 1792 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎deeplabcut/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
try:
3030
import wx
31+
3132
mpl.use("WxAgg")
3233
from deeplabcut import generate_training_dataset
3334
from deeplabcut import refine_training_dataset

‎deeplabcut/__main__.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"""
1010
try:
1111
import wx
12+
1213
lite = False
1314
except ModuleNotFoundError:
1415
lite = True
@@ -20,4 +21,6 @@
2021

2122
deeplabcut.launch_dlc()
2223
else:
23-
print("You installed DLC lite, thus GUI's cannot be used. If you need GUI support please: pip install deeplabcut[gui]")
24+
print(
25+
"You installed DLC lite, thus GUI's cannot be used. If you need GUI support please: pip install deeplabcut[gui]"
26+
)

‎deeplabcut/generate_training_dataset/trainingsetmanipulation.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,9 @@ def cropimagesandlabels(
397397
# moving old entry to _original, dropping it from video_set and update crop parameters
398398
video_orig = sep.join((vidpath, vidname + videotype))
399399
if video_orig not in cfg["video_sets_original"]:
400-
cfg["video_sets_original"][video_orig] = cfg["video_sets"][video_orig]
400+
cfg["video_sets_original"][video_orig] = cfg["video_sets"][
401+
video_orig
402+
]
401403
cfg["video_sets"].pop(video_orig)
402404
cfg["video_sets"][sep.join((vidpath, new_vidname + videotype))] = {
403405
"crop": ", ".join(map(str, [0, temp_size[1], 0, temp_size[0]]))
@@ -461,7 +463,7 @@ def check_labels(
461463
for folder in folders:
462464
try:
463465
DataCombined = pd.read_hdf(
464-
os.path.join(str(folder), "CollectedData_" + cfg["scorer"] + ".h5"),
466+
os.path.join(str(folder), "CollectedData_" + cfg["scorer"] + ".h5")
465467
)
466468
if cfg.get("multianimalproject", False):
467469
color_by = "individual" if visualizeindividuals else "bodypart"
@@ -887,7 +889,11 @@ def create_training_dataset(
887889
if net_type is None: # loading & linking pretrained models
888890
net_type = cfg.get("default_net_type", "resnet_50")
889891
else:
890-
if "resnet" in net_type or "mobilenet" in net_type or "efficientnet" in net_type:
892+
if (
893+
"resnet" in net_type
894+
or "mobilenet" in net_type
895+
or "efficientnet" in net_type
896+
):
891897
pass
892898
else:
893899
raise ValueError("Invalid network type:", net_type)

‎deeplabcut/gui/auxfun_drag.py‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ def on_press(self, event):
8989
message = f"Do you want to remove the label {self.bodyParts}?"
9090
if self.likelihood is not None:
9191
message += " You cannot undo this step!"
92-
msg = wx.MessageBox(
93-
message,
94-
"Remove!",
95-
wx.YES_NO | wx.ICON_WARNING,
96-
)
92+
msg = wx.MessageBox(message, "Remove!", wx.YES_NO | wx.ICON_WARNING)
9793
if msg == 2:
9894
self.delete_data()
9995

‎deeplabcut/gui/create_training_dataset.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ def __init__(self, parent, gui_size, cfg):
146146
)
147147
self.cropandlabel.Bind(wx.EVT_RADIOBOX, self.input_crop_size)
148148
self.cropandlabel.SetSelection(0)
149-
self.crop_text = wx.StaticBox(self, label="Crop settings (set to smaller than your input images)")
149+
self.crop_text = wx.StaticBox(
150+
self, label="Crop settings (set to smaller than your input images)"
151+
)
150152
self.crop_sizer = wx.StaticBoxSizer(self.crop_text, wx.VERTICAL)
151153
self.crop_widgets = []
152154
for name, val in [
@@ -171,7 +173,9 @@ def __init__(self, parent, gui_size, cfg):
171173
self.hbox3.Add(self.userfeedback, 10, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
172174

173175
if config_file.get("multianimalproject", False):
174-
print("more networks are available soon for maDLC, but currenlty this uses DLC-ResNet50 only")
176+
print(
177+
"more networks are available soon for maDLC, but currenlty this uses DLC-ResNet50 only"
178+
)
175179
self.model_comparison_choice = "No"
176180
else:
177181
self.model_comparison_choice = wx.RadioBox(

‎deeplabcut/gui/frame_extraction_toolbox.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def getColorIndices(self, img, bodyparts):
4545
class MainFrame(BaseFrame):
4646
def __init__(self, parent, config, slider_width=25):
4747
super(MainFrame, self).__init__(
48-
"DeepLabCut2.0 - Manual Frame Extraction", parent,
48+
"DeepLabCut2.0 - Manual Frame Extraction", parent
4949
)
5050

5151
###################################################################################################################################################
@@ -158,8 +158,9 @@ def __init__(self, parent, config, slider_width=25):
158158
self.date = self.cfg["date"]
159159
self.trainFraction = self.cfg["TrainingFraction"]
160160
self.trainFraction = self.trainFraction[0]
161-
self.videos = list(self.cfg.get("video_sets_original")
162-
or self.cfg["video_sets"])
161+
self.videos = list(
162+
self.cfg.get("video_sets_original") or self.cfg["video_sets"]
163+
)
163164
self.bodyparts = self.cfg["bodyparts"]
164165
self.colormap = plt.get_cmap(self.cfg["colormap"])
165166
self.colormap = self.colormap.reversed()

‎deeplabcut/gui/label_frames.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@ def label_frames(
7171
os.chdir(str(wd))
7272
cfg = auxiliaryfunctions.read_config(config)
7373
if cfg.get("multianimalproject", False) or multiple_individualsGUI:
74-
from deeplabcut.gui import (
75-
multiple_individuals_labeling_toolbox,
76-
)
74+
from deeplabcut.gui import multiple_individuals_labeling_toolbox
7775

7876
multiple_individuals_labeling_toolbox.show(config, config3d, sourceCam)
7977
else:

‎deeplabcut/gui/labeling_toolbox.py‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ def retrieveData_and_computeEpLines(self, img, imNum):
5858
if self.sourceCam is None:
5959
sourceCam = [
6060
otherCam for otherCam in cams if cam not in otherCam
61-
][0] #WHY?
61+
][
62+
0
63+
] # WHY?
6264
else:
6365
sourceCam = self.sourceCam
6466

@@ -80,11 +82,13 @@ def retrieveData_and_computeEpLines(self, img, imNum):
8082

8183
try:
8284
dataFrame = pd.read_hdf(
83-
os.path.join(sourceCam_path, "CollectedData_" + scorer + ".h5"),
85+
os.path.join(sourceCam_path, "CollectedData_" + scorer + ".h5")
8486
)
8587
dataFrame.sort_index(inplace=True)
8688
except IOError:
87-
print("source camera images have not yet been labeled, or you have opened this folder in the wrong mode!")
89+
print(
90+
"source camera images have not yet been labeled, or you have opened this folder in the wrong mode!"
91+
)
8892
return None, None, None
8993

9094
# Find offset terms for drawing epipolar Lines
@@ -241,7 +245,7 @@ def clearBoxer(self):
241245
class MainFrame(BaseFrame):
242246
def __init__(self, parent, config, imtypes, config3d, sourceCam):
243247
super(MainFrame, self).__init__(
244-
"DeepLabCut2.0 - Labeling ToolBox", parent, imtypes,
248+
"DeepLabCut2.0 - Labeling ToolBox", parent, imtypes
245249
)
246250

247251
self.statusbar.SetStatusText(
@@ -370,9 +374,7 @@ def OnKeyPressed(self, event=None):
370374
inv = self.axes.transData.inverted()
371375
pos_rel = list(inv.transform(pos_abs))
372376
y1, y2 = self.axes.get_ylim()
373-
pos_rel[1] = (
374-
y1 - pos_rel[1] + y2
375-
) # Recall y-axis is inverted
377+
pos_rel[1] = y1 - pos_rel[1] + y2 # Recall y-axis is inverted
376378
i = np.nanargmin(
377379
[self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
378380
)
@@ -619,7 +621,7 @@ def browseDir(self, event):
619621
# Reading the existing dataset,if already present
620622
try:
621623
self.dataFrame = pd.read_hdf(
622-
os.path.join(self.dir, "CollectedData_" + self.scorer + ".h5"),
624+
os.path.join(self.dir, "CollectedData_" + self.scorer + ".h5")
623625
)
624626
self.dataFrame.sort_index(inplace=True)
625627
self.prev.Enable(True)
@@ -892,9 +894,7 @@ def plot(self, img):
892894
)
893895
]
894896
self.axes.add_patch(circle[0])
895-
self.dr = auxfun_drag.DraggablePoint(
896-
circle[0], self.bodyparts[bpindex]
897-
)
897+
self.dr = auxfun_drag.DraggablePoint(circle[0], self.bodyparts[bpindex])
898898
self.dr.connect()
899899
self.dr.coords = MainFrame.getLabels(self, self.iter)[bpindex]
900900
self.drs.append(self.dr)
@@ -952,7 +952,6 @@ def onChecked(self, event):
952952
self.slider.Enable(False)
953953

954954

955-
956955
def show(config, config3d, sourceCam, imtypes=["*.png"]):
957956
app = wx.App()
958957
frame = MainFrame(None, config, imtypes, config3d, sourceCam).Show()

‎deeplabcut/gui/multiple_individuals_labeling_toolbox.py‎

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ def retrieveData_and_computeEpLines(self, img, imNum):
8686

8787
try:
8888
dataFrame = pd.read_hdf(
89-
os.path.join(sourceCam_path, "CollectedData_" + scorer + ".h5"),
89+
os.path.join(sourceCam_path, "CollectedData_" + scorer + ".h5")
9090
)
9191
dataFrame.sort_index(inplace=True)
9292
except IOError:
93-
print("source camera images have not yet been labeled, or you have opened this folder in the wrong mode!")
93+
print(
94+
"source camera images have not yet been labeled, or you have opened this folder in the wrong mode!"
95+
)
9496
return None, None, None
9597

9698
# Find offset terms for drawing epipolar Lines
@@ -283,7 +285,7 @@ def clearBoxer(self):
283285
class MainFrame(BaseFrame):
284286
def __init__(self, parent, config, config3d, sourceCam):
285287
super(MainFrame, self).__init__(
286-
"DeepLabCut2.0 - Multiple Individuals Labeling ToolBox", parent,
288+
"DeepLabCut2.0 - Multiple Individuals Labeling ToolBox", parent
287289
)
288290

289291
self.statusbar.SetStatusText(
@@ -415,9 +417,7 @@ def OnKeyPressed(self, event=None):
415417
inv = self.axes.transData.inverted()
416418
pos_rel = list(inv.transform(pos_abs))
417419
y1, y2 = self.axes.get_ylim()
418-
pos_rel[1] = (
419-
y1 - pos_rel[1] + y2
420-
) # Recall y-axis is inverted
420+
pos_rel[1] = y1 - pos_rel[1] + y2 # Recall y-axis is inverted
421421
i = np.nanargmin(
422422
[self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
423423
)
@@ -789,7 +789,7 @@ def browseDir(self, event):
789789
# Reading the existing dataset,if already present
790790
try:
791791
self.dataFrame = pd.read_hdf(
792-
os.path.join(self.dir, "CollectedData_" + self.scorer + ".h5"),
792+
os.path.join(self.dir, "CollectedData_" + self.scorer + ".h5")
793793
)
794794
# Handle data previously labeled on a different platform
795795
sep = "/" if "/" in self.dataFrame.index[0] else "\\"
@@ -1205,9 +1205,7 @@ def plot(self, img):
12051205
)
12061206
self.axes.add_patch(circle)
12071207
self.dr = auxfun_drag.DraggablePoint(
1208-
circle,
1209-
self.uniquebodyparts[c],
1210-
individual_names=ind,
1208+
circle, self.uniquebodyparts[c], individual_names=ind
12111209
)
12121210
self.dr.connect()
12131211
self.dr.coords = image_points
@@ -1243,9 +1241,7 @@ def plot(self, img):
12431241
)
12441242
self.axes.add_patch(circle)
12451243
self.dr = auxfun_drag.DraggablePoint(
1246-
circle,
1247-
self.multibodyparts[c],
1248-
individual_names=ind,
1244+
circle, self.multibodyparts[c], individual_names=ind
12491245
)
12501246
self.dr.connect()
12511247
self.dr.coords = image_points

‎deeplabcut/gui/multiple_individuals_refinement_toolbox.py‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def drawplot(
7575
self.axes.set_xlim(xlim)
7676
self.axes.set_ylim(ylim)
7777
self.figure.canvas.draw()
78-
if not hasattr(self, 'toolbar'):
78+
if not hasattr(self, "toolbar"):
7979
self.toolbar = NavigationToolbar(self.canvas)
8080
return (self.figure, self.axes, self.canvas, self.toolbar, self.ax)
8181

@@ -137,9 +137,7 @@ def clearBoxer(self):
137137

138138
class MainFrame(BaseFrame):
139139
def __init__(self, parent, config):
140-
super(MainFrame, self).__init__(
141-
"DeepLabCut - Refinement ToolBox", parent,
142-
)
140+
super(MainFrame, self).__init__("DeepLabCut - Refinement ToolBox", parent)
143141
self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPressed)
144142

145143
###################################################################################################################################################
@@ -281,9 +279,7 @@ def OnKeyPressed(self, event=None):
281279
inv = self.axes.transData.inverted()
282280
pos_rel = list(inv.transform(pos_abs))
283281
y1, y2 = self.axes.get_ylim()
284-
pos_rel[1] = (
285-
y1 - pos_rel[1] + y2
286-
) # Recall y-axis is inverted
282+
pos_rel[1] = y1 - pos_rel[1] + y2 # Recall y-axis is inverted
287283
i = np.nanargmin(
288284
[self.calc_distance(*dp.point.center, *pos_rel) for dp in self.drs]
289285
)
@@ -810,7 +806,7 @@ def saveDataSet(self, event):
810806
"A training dataset file is already found for this video. The refined machine labels are merged to this data!"
811807
)
812808
DataU1 = pd.read_hdf(
813-
os.path.join(self.dir, "CollectedData_" + self.humanscorer + ".h5"),
809+
os.path.join(self.dir, "CollectedData_" + self.humanscorer + ".h5")
814810
)
815811
# combine datasets Original Col. + corrected machinefiles:
816812
DataCombined = pd.concat([self.Dataframe, DataU1])

0 commit comments

Comments
 (0)