|
21 | 21 | from .trajectoriesAlgorithm import TrajectoryManipulationAlgorithm, help_str_base, help_str_traj
|
22 | 22 |
|
23 | 23 |
|
24 |
| -CPU_COUNT = os.cpu_count() |
25 |
| - |
26 |
| - |
27 | 24 | class SplitTrajectoriesAlgorithm(TrajectoryManipulationAlgorithm):
|
28 | 25 | def __init__(self):
|
29 | 26 | super().__init__()
|
@@ -90,12 +87,13 @@ def processTc(self, tc, parameters, context):
|
90 | 87 | if td_units == "Weeks":
|
91 | 88 | td_units = "W"
|
92 | 89 | time_gap = pd.Timedelta(f"{time_gap} {td_units}").to_pytimedelta()
|
| 90 | + |
93 | 91 | for traj in tc.trajectories:
|
94 | 92 | try:
|
95 | 93 | splits = ObservationGapSplitter(traj).split(
|
96 | 94 | gap=time_gap,
|
97 | 95 | min_length=tc.min_length,
|
98 |
| - n_processes=CPU_COUNT |
| 96 | + n_processes=self.cpu_count |
99 | 97 | )
|
100 | 98 | except TypeError:
|
101 | 99 | 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):
|
151 | 149 | splits = TemporalSplitter(tc).split(
|
152 | 150 | mode=split_mode,
|
153 | 151 | min_length=tc.min_length,
|
154 |
| - n_processes=CPU_COUNT |
| 152 | + n_processes=self.cpu_count |
155 | 153 | )
|
156 | 154 | except TypeError:
|
157 | 155 | 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):
|
212 | 210 | max_diameter=max_diameter,
|
213 | 211 | min_duration=min_duration,
|
214 | 212 | min_length=tc.min_length,
|
215 |
| - n_processes=CPU_COUNT |
| 213 | + n_processes=self.cpu_count |
216 | 214 | )
|
217 | 215 | except TypeError:
|
218 | 216 | 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):
|
263 | 261 | splits = ValueChangeSplitter(traj).split(
|
264 | 262 | col_name=self.field,
|
265 | 263 | min_length=tc.min_length,
|
266 |
| - n_processes=CPU_COUNT |
| 264 | + n_processes=self.cpu_count |
267 | 265 | )
|
268 | 266 | except TypeError:
|
269 | 267 | 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