def test_finding_nested_path_on_set_condition_with_list(): d = {'1': {'2': {'3': {'4': ['hey']}, '5': '6'}, '7': '8'}, '9': '10'} value = {'hey'} assert dict_support.find_nested_paths_to_value(d, value) == [{ '1': { '2': { '3': '4' } } }]
def test_finding_nested_path_on_condition(): d = {'1': {'2': {'3': {'4': 'hey'}, '5': '6'}, '7': '8'}, '9': '10'} value = 'hey' assert dict_support.find_nested_paths_to_value(d, value) == [{ '1': { '2': { '3': '4' } } }]
def attach(self, indices: set): if isinstance(self.data, dict): self.attachments += dict_support.find_nested_paths_to_value(self.data, indices) if isinstance(self.data, pd.DataFrame): for col in self.data.columns: if all([isinstance(x, (list, set)) for x in self.data[col]]): if set(self.data[col].sum()) & indices: self.attachments.append(col) elif set(self.data[col]) & indices: self.attachments.append(col) self.build_identity_map()
def test_finding_multiple_nested_paths_on_condition(): d = { '1': { '2': { '3': { '4': ['hey'] }, '5': '6' }, '7': 'hey' }, '9': '10', '11': 'heyo' } value = {'hey', 'heyo'} assert dict_support.find_nested_paths_to_value(d, value) == [{ '1': { '2': { '3': '4' } } }, { '1': '7' }, '11']