Returns all nodes from specified level. Parameters ---------- level : int Decomposition `level` from which the nodes will be collected. decompose : bool, optional If set then the method will try to decompose the data up
(self, level, decompose=True)
| 1022 | return self.data # return original data |
| 1023 | |
| 1024 | def get_level(self, level, decompose=True): |
| 1025 | """ |
| 1026 | Returns all nodes from specified level. |
| 1027 | |
| 1028 | Parameters |
| 1029 | ---------- |
| 1030 | level : int |
| 1031 | Decomposition `level` from which the nodes will be |
| 1032 | collected. |
| 1033 | decompose : bool, optional |
| 1034 | If set then the method will try to decompose the data up |
| 1035 | to the specified `level` (default: True). |
| 1036 | """ |
| 1037 | if level > self.maxlevel: |
| 1038 | raise ValueError("The level cannot be greater than the maximum" |
| 1039 | " decomposition level value (%d)" % self.maxlevel) |
| 1040 | |
| 1041 | result = [] |
| 1042 | |
| 1043 | def collect(node): |
| 1044 | if node.level == level: |
| 1045 | result.append(node) |
| 1046 | return False |
| 1047 | return True |
| 1048 | |
| 1049 | self.walk(collect, decompose=decompose) |
| 1050 | |
| 1051 | return result |