Skip to content

Commit 4ad6272

Browse files
author
anitagraser
committed
Update qgis_processing/splitTrajectoriesAlgorithm.py
1 parent ab6bf35 commit 4ad6272

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

qgis_processing/splitTrajectoriesAlgorithm.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
from .trajectoriesAlgorithm import TrajectoryManipulationAlgorithm, help_str_base, help_str_traj
2222

2323

24-
CPU_COUNT = os.cpu_count()
25-
26-
2724
class SplitTrajectoriesAlgorithm(TrajectoryManipulationAlgorithm):
2825
def __init__(self):
2926
super().__init__()
@@ -90,12 +87,13 @@ def processTc(self, tc, parameters, context):
9087
if td_units == "Weeks":
9188
td_units = "W"
9289
time_gap = pd.Timedelta(f"{time_gap} {td_units}").to_pytimedelta()
90+
9391
for traj in tc.trajectories:
9492
try:
9593
splits = ObservationGapSplitter(traj).split(
9694
gap=time_gap,
9795
min_length=tc.min_length,
98-
n_processes=CPU_COUNT
96+
n_processes=self.cpu_count
9997
)
10098
except TypeError:
10199
raise TypeError("TypeError: cannot pickle 'QVariant' object. This error is usually caused by None values in input layer fields. Try to remove None values or run without Add movement metrics.")
@@ -151,7 +149,7 @@ def processTc(self, tc, parameters, context):
151149
splits = TemporalSplitter(tc).split(
152150
mode=split_mode,
153151
min_length=tc.min_length,
154-
n_processes=CPU_COUNT
152+
n_processes=self.cpu_count
155153
)
156154
except TypeError:
157155
raise TypeError("TypeError: cannot pickle 'QVariant' object. This error is usually caused by None values in input layer fields. Try to remove None values or run without Add movement metrics.")
@@ -212,7 +210,7 @@ def processTc(self, tc, parameters, context):
212210
max_diameter=max_diameter,
213211
min_duration=min_duration,
214212
min_length=tc.min_length,
215-
n_processes=CPU_COUNT
213+
n_processes=self.cpu_count
216214
)
217215
except TypeError:
218216
raise TypeError("TypeError: cannot pickle 'QVariant' object. This error is usually caused by None values in input layer fields. Try to remove None values or run without Add movement metrics.")
@@ -263,7 +261,7 @@ def processTc(self, tc, parameters, context):
263261
splits = ValueChangeSplitter(traj).split(
264262
col_name=self.field,
265263
min_length=tc.min_length,
266-
n_processes=CPU_COUNT
264+
n_processes=self.cpu_count
267265
)
268266
except TypeError:
269267
raise TypeError("TypeError: cannot pickle 'QVariant' object. This error is usually caused by None values in input layer fields. Try to remove None values or run without Add movement metrics.")

0 commit comments

Comments
 (0)