chtoolbox 1.1.0__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: chtoolbox
3
+ Version: 1.2.0
4
+ Home-page: https://github.com/chagenvik/chtoolbox
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE
7
+
8
+ # chtoolbox
9
+ chtoolbox is a library containing various python tools used in my daily work
10
+
11
+ ## Installation
12
+ To install chtoolbox, use pip:
13
+
14
+ ```sh
15
+ pip install chtoolbox
16
+ ```
17
+
18
+ ## Usage
19
+ Examples are provided in the `examples` folder in the repository.
20
+
21
+ ## License
22
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -109,7 +109,7 @@ def compare_lists_from_clipboard():
109
109
  The table is converted into lists (one list per column in the Excel range).
110
110
  Then it compares all the lists and finds the unique elements that are not present in all the lists.
111
111
  Useful for comparing large amounts of elements from Excel.
112
- Dictionary containing one list per column in the clipboard (Excel range).
112
+ Dictionary containing one list per column in clipboard (Excel range).
113
113
  """
114
114
  '''
115
115
  En funksjon som brukes ved å merke og kopiere en tabell fra excel.
@@ -205,4 +205,46 @@ def generate_combination_matrix(input_dict):
205
205
  # Create a DataFrame from the combinations
206
206
  df = pd.DataFrame(combinations, columns=input_dict.keys())
207
207
 
208
- return df
208
+ return df
209
+
210
+
211
+ def filter_dictionary(input_dict: dict, filter: str | list[str]) -> dict:
212
+ """
213
+ Filters a dictionary to only include keys containing the filter string(s).
214
+
215
+ Parameters
216
+ ----------
217
+ input_dict : dict
218
+ The dictionary to filter.
219
+ filter : str or list of str
220
+ String or list of strings to match in the dictionary keys (case-insensitive).
221
+
222
+ Returns
223
+ -------
224
+ dict
225
+ A new dictionary containing only the keys that match the filter string(s).
226
+
227
+ Examples
228
+ --------
229
+ >>> input_dict = {
230
+ ... 'pressure': [10, 20],
231
+ ... 'GVF': [10, 20, 30],
232
+ ... 'WLR': [40, 60, 80],
233
+ ... 'temp': [100, 200],
234
+ ... }
235
+ >>> filter_dictionary(input_dict, 'pres')
236
+ {'pressure': [10, 20]}
237
+ >>> filter_dictionary(input_dict, ['pres', 'WLR'])
238
+ {'pressure': [10, 20], 'WLR': [40, 60, 80]}
239
+
240
+ Notes
241
+ -----
242
+ - Filtering is case-insensitive.
243
+ - If no keys match, an empty dictionary is returned.
244
+ """
245
+ if isinstance(filter, str):
246
+ filter = [filter]
247
+
248
+ filtered_dict = {key: value for key, value in input_dict.items() if any(f.lower() in key.lower() for f in filter)}
249
+
250
+ return filtered_dict
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: chtoolbox
3
+ Version: 1.2.0
4
+ Home-page: https://github.com/chagenvik/chtoolbox
5
+ Description-Content-Type: text/markdown
6
+ License-File: LICENSE
7
+
8
+ # chtoolbox
9
+ chtoolbox is a library containing various python tools used in my daily work
10
+
11
+ ## Installation
12
+ To install chtoolbox, use pip:
13
+
14
+ ```sh
15
+ pip install chtoolbox
16
+ ```
17
+
18
+ ## Usage
19
+ Examples are provided in the `examples` folder in the repository.
20
+
21
+ ## License
22
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -36,7 +36,7 @@ with readme_path.open() as readme_file:
36
36
 
37
37
  setup(
38
38
  name='chtoolbox',
39
- version='1.1.0',
39
+ version='1.2.0',
40
40
  packages=find_packages(),
41
41
  install_requires=requirements,
42
42
  long_description=long_description,
chtoolbox-1.1.0/PKG-INFO DELETED
@@ -1,23 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: chtoolbox
3
- Version: 1.1.0
4
- Summary: UNKNOWN
5
- Home-page: https://github.com/chagenvik/chtoolbox
6
- License: UNKNOWN
7
- Description: # chtoolbox
8
- chtoolbox is a library containing various python tools used in my daily work
9
-
10
- ## Installation
11
- To install chtoolbox, use pip:
12
-
13
- ```sh
14
- pip install chtoolbox
15
- ```
16
-
17
- ## Usage
18
- Examples are provided in the `examples` folder in the repository.
19
-
20
- ## License
21
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
22
- Platform: UNKNOWN
23
- Description-Content-Type: text/markdown
@@ -1,23 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: chtoolbox
3
- Version: 1.1.0
4
- Summary: UNKNOWN
5
- Home-page: https://github.com/chagenvik/chtoolbox
6
- License: UNKNOWN
7
- Description: # chtoolbox
8
- chtoolbox is a library containing various python tools used in my daily work
9
-
10
- ## Installation
11
- To install chtoolbox, use pip:
12
-
13
- ```sh
14
- pip install chtoolbox
15
- ```
16
-
17
- ## Usage
18
- Examples are provided in the `examples` folder in the repository.
19
-
20
- ## License
21
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
22
- Platform: UNKNOWN
23
- Description-Content-Type: text/markdown
File without changes
File without changes
File without changes
File without changes