2302 | def _combine_check(self, other): |
2303 | """ |
2304 | Check if self and other refer to the same table and if all columns in |
2305 | self and other are numeric. This sanity check is used before performing |
2306 | aggregation operations between IdaDataFrame/IdaSeries. |
2307 | """ |
2308 | def check_numeric_columns(idaobject): |
2309 | not_valid = [] |
2310 | numeric_columns = idaobject._get_numerical_columns() |
2311 | for column in idaobject.columns: |
2312 | if column not in numeric_columns: |
2313 | not_valid.append(column) |
2314 | if not_valid: |
2315 | raise TypeError("Arithmetic operation are not defined for %s"%not_valid) |
2316 | |
2317 | if isinstance(other, IdaDataFrame) | isinstance(other, ibmdbpy.IdaSeries): |
2318 | if self._name != other._name: |
2319 | raise IdaDataFrameError("It is not possible to aggregate columns using columns of a different table.") |
2320 | |
2321 | if not(isinstance(other, IdaDataFrame) | isinstance(other, ibmdbpy.IdaSeries) | isinstance(other, Number)): |
2322 | if other is not None: |
2323 | raise TypeError("Aggregation makes only sense with numbers, "+ |
2324 | "or IdaDataFrames refering to the same table.") |
2325 | |
2326 | check_numeric_columns(self) |
2327 | if isinstance(other, ibmdbpy.IdaSeries)|isinstance(other, IdaDataFrame): |
2328 | check_numeric_columns(other) |