iwutil 0.1.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.
- iwutil-0.1.0/.gitignore +2 -0
- iwutil-0.1.0/LICENSE.md +27 -0
- iwutil-0.1.0/PKG-INFO +43 -0
- iwutil-0.1.0/README.md +3 -0
- iwutil-0.1.0/iwutil/__init__.py +133 -0
- iwutil-0.1.0/iwutil.egg-info/PKG-INFO +41 -0
- iwutil-0.1.0/iwutil.egg-info/SOURCES.txt +9 -0
- iwutil-0.1.0/iwutil.egg-info/dependency_links.txt +1 -0
- iwutil-0.1.0/iwutil.egg-info/requires.txt +3 -0
- iwutil-0.1.0/iwutil.egg-info/top_level.txt +1 -0
- iwutil-0.1.0/pyproject.toml +20 -0
iwutil-0.1.0/.gitignore
ADDED
iwutil-0.1.0/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) 2024, Ionworks Technologies Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
- Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
- Neither the name of the copyright holder nor the names of its
|
|
15
|
+
contributors may be used to endorse or promote products derived from
|
|
16
|
+
this software without specific prior written permission.
|
|
17
|
+
|
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
19
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
20
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
22
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
23
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
24
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
25
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
26
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
iwutil-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: iwutil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Public utility functions for Ionworks code.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ionworks/iwutil
|
|
6
|
+
Project-URL: Issues, https://github.com/ionworks/iwutil/issues
|
|
7
|
+
Author-email: Ionworks Technologies Inc <info@ionworks.com>
|
|
8
|
+
License: Copyright (c) 2024, Ionworks Technologies Inc.
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted provided that the following conditions are met:
|
|
13
|
+
|
|
14
|
+
- Redistributions of source code must retain the above copyright notice, this
|
|
15
|
+
list of conditions and the following disclaimer.
|
|
16
|
+
|
|
17
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
+
this list of conditions and the following disclaimer in the documentation
|
|
19
|
+
and/or other materials provided with the distribution.
|
|
20
|
+
|
|
21
|
+
- Neither the name of the copyright holder nor the names of its
|
|
22
|
+
contributors may be used to endorse or promote products derived from
|
|
23
|
+
this software without specific prior written permission.
|
|
24
|
+
|
|
25
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
26
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
27
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
28
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
29
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
30
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
31
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
32
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
33
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
34
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
+
License-File: LICENSE.md
|
|
36
|
+
Requires-Dist: matplotlib
|
|
37
|
+
Requires-Dist: numpy
|
|
38
|
+
Requires-Dist: pandas
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# Ionworks utility functions
|
|
42
|
+
|
|
43
|
+
Public utility functions for Ionworks code
|
iwutil-0.1.0/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import matplotlib.pyplot as plt
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def subplots_autolayout(
|
|
8
|
+
n, *args, n_rows=None, figsize=None, layout="constrained", **kwargs
|
|
9
|
+
):
|
|
10
|
+
"""
|
|
11
|
+
Create a subplot element with a
|
|
12
|
+
"""
|
|
13
|
+
n_rows = n_rows or int(n // np.sqrt(n))
|
|
14
|
+
n_cols = int(np.ceil(n / n_rows))
|
|
15
|
+
|
|
16
|
+
figwidth_default = min(15, 4 * n_cols)
|
|
17
|
+
figheight_default = min(8, 1 + 3 * n_rows)
|
|
18
|
+
figsize = figsize or (figwidth_default, figheight_default)
|
|
19
|
+
fig, axes = plt.subplots(
|
|
20
|
+
n_rows, n_cols, *args, figsize=figsize, layout=layout, **kwargs
|
|
21
|
+
)
|
|
22
|
+
# if we just have a single axis, make sure we are returning an array instead
|
|
23
|
+
if not isinstance(axes, np.ndarray):
|
|
24
|
+
axes = np.array([axes])
|
|
25
|
+
axes = axes.flatten()
|
|
26
|
+
|
|
27
|
+
return fig, axes
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def process_folder_file(folder, file):
|
|
31
|
+
"""
|
|
32
|
+
Process folder and file to create a full path. If folder does not exist, create it.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
folder : str
|
|
37
|
+
Folder to save file in
|
|
38
|
+
file : str
|
|
39
|
+
File name
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
str
|
|
44
|
+
Full path to file
|
|
45
|
+
"""
|
|
46
|
+
if not os.path.exists(folder):
|
|
47
|
+
os.makedirs(folder)
|
|
48
|
+
return os.path.join(folder, file)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def save_json(params, folder, file):
|
|
52
|
+
"""
|
|
53
|
+
Save params to a json file in folder/file
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
params : dict
|
|
58
|
+
Dictionary of parameters
|
|
59
|
+
folder : str
|
|
60
|
+
Folder to save file in
|
|
61
|
+
file : str
|
|
62
|
+
File name
|
|
63
|
+
"""
|
|
64
|
+
full_name = process_folder_file(folder, file)
|
|
65
|
+
with open(full_name, "w") as f:
|
|
66
|
+
json.dump(params, f, indent=2)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def save_csv(df, folder, file):
|
|
70
|
+
"""
|
|
71
|
+
Save df to a csv file in folder/file
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
df : pandas.DataFrame
|
|
76
|
+
DataFrame to save
|
|
77
|
+
folder : str
|
|
78
|
+
Folder to save file in
|
|
79
|
+
file : str
|
|
80
|
+
File name
|
|
81
|
+
"""
|
|
82
|
+
full_name = process_folder_file(folder, file)
|
|
83
|
+
df.to_csv(full_name, index=False)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def save_fig(fig, folder, file):
|
|
87
|
+
"""
|
|
88
|
+
Save fig to a file in folder
|
|
89
|
+
|
|
90
|
+
Parameters
|
|
91
|
+
----------
|
|
92
|
+
fig : matplotlib.figure.Figure
|
|
93
|
+
Figure to save
|
|
94
|
+
folder : str
|
|
95
|
+
Folder to save file in
|
|
96
|
+
file : str
|
|
97
|
+
File name
|
|
98
|
+
"""
|
|
99
|
+
full_name = process_folder_file(folder, file)
|
|
100
|
+
fig.savefig(full_name)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def check_and_combine_options(self, default_options, custom_options=None):
|
|
104
|
+
"""
|
|
105
|
+
Check that all required options are provided, and combine default and custom options
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
default_options : dict
|
|
110
|
+
Dictionary of default options
|
|
111
|
+
custom_options : dict, optional
|
|
112
|
+
Dictionary of custom options, by default None
|
|
113
|
+
|
|
114
|
+
Returns
|
|
115
|
+
-------
|
|
116
|
+
dict
|
|
117
|
+
Combined options
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
if custom_options is None:
|
|
121
|
+
custom_options = {}
|
|
122
|
+
|
|
123
|
+
# Check that all custom option keys have a default
|
|
124
|
+
for k in custom_options:
|
|
125
|
+
if k not in default_options:
|
|
126
|
+
raise ValueError(f"Option '{k}' not recognized")
|
|
127
|
+
|
|
128
|
+
# If any default options are marked as "[required]", check that they are provided
|
|
129
|
+
for k, v in default_options.items():
|
|
130
|
+
if v == "[required]" and k not in custom_options:
|
|
131
|
+
raise ValueError(f"Option '{k}' is required")
|
|
132
|
+
|
|
133
|
+
return {**default_options, **custom_options}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: iwutil
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Public utility functions for Ionworks code.
|
|
5
|
+
License: Copyright (c) 2024, Ionworks Technologies Inc.
|
|
6
|
+
All rights reserved.
|
|
7
|
+
|
|
8
|
+
Redistribution and use in source and binary forms, with or without
|
|
9
|
+
modification, are permitted provided that the following conditions are met:
|
|
10
|
+
|
|
11
|
+
- Redistributions of source code must retain the above copyright notice, this
|
|
12
|
+
list of conditions and the following disclaimer.
|
|
13
|
+
|
|
14
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
|
15
|
+
this list of conditions and the following disclaimer in the documentation
|
|
16
|
+
and/or other materials provided with the distribution.
|
|
17
|
+
|
|
18
|
+
- Neither the name of the copyright holder nor the names of its
|
|
19
|
+
contributors may be used to endorse or promote products derived from
|
|
20
|
+
this software without specific prior written permission.
|
|
21
|
+
|
|
22
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
23
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
25
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
26
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
27
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
28
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
30
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
31
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
License-File: LICENSE.md
|
|
35
|
+
Requires-Dist: matplotlib
|
|
36
|
+
Requires-Dist: pandas
|
|
37
|
+
Requires-Dist: numpy
|
|
38
|
+
|
|
39
|
+
# Ionworks utility functions
|
|
40
|
+
|
|
41
|
+
Public utility functions for Ionworks code
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
iwutil
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "iwutil"
|
|
3
|
+
description = "Public utility functions for Ionworks code."
|
|
4
|
+
authors = [{ name = "Ionworks Technologies Inc", email = "info@ionworks.com" }]
|
|
5
|
+
readme = { file = "README.md", content-type = "text/markdown" }
|
|
6
|
+
license = { file = "LICENSE.md" }
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"matplotlib",
|
|
10
|
+
"pandas",
|
|
11
|
+
"numpy"
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Homepage = "https://github.com/ionworks/iwutil"
|
|
16
|
+
Issues = "https://github.com/ionworks/iwutil/issues"
|
|
17
|
+
|
|
18
|
+
[build-system]
|
|
19
|
+
requires = ["hatchling"]
|
|
20
|
+
build-backend = "hatchling.build"
|