DiaModality 0.1.4__tar.gz → 0.1.7__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.
@@ -1,155 +1,161 @@
1
- Metadata-Version: 2.1
2
- Name: DiaModality
3
- Version: 0.1.4
4
- Summary: Tool to plot modality vector diagrams
5
- Author-email: konung-yaropolk <yaropolk1995@gmail.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2024 konung-yaropolk
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- Project-URL: Homepage, https://github.com/konung-yaropolk/DiaModality
28
- Project-URL: Issues, https://github.com/konung-yaropolk/DiaModality/issues
29
- Keywords: Visualization,Plotting,Matplotlib
30
- Classifier: Programming Language :: Python :: 3
31
- Classifier: License :: OSI Approved :: MIT License
32
- Classifier: Operating System :: OS Independent
33
- Classifier: Development Status :: 4 - Beta
34
- Classifier: Intended Audience :: Science/Research
35
- Classifier: Natural Language :: English
36
- Classifier: Topic :: Scientific/Engineering :: Visualization
37
- Requires-Python: >=3.10
38
- Description-Content-Type: text/markdown
39
- License-File: LICENSE
40
- Requires-Dist: numpy
41
- Requires-Dist: matplotlib
42
-
43
- # DiaModality - The Modality Diagram
44
-
45
- Simple tool to plot vector modality diagram
46
-
47
- ### To install package run the command:
48
- ```bash
49
- pip install diamodality
50
- ```
51
-
52
-
53
- ### How to use:
54
- See the /demo directory on Git repo or
55
- create and run the following two files:
56
-
57
- ---
58
- ``generate_sample_data.py``:
59
- ```python
60
- import csv
61
- import random
62
- import os
63
-
64
- num_rows = 1500
65
- output_file = 'modality_data.csv'
66
-
67
- # locate working directory
68
- script_dir = os.path.dirname(os.path.realpath(__file__))
69
- file_path = os.path.join(script_dir, output_file)
70
-
71
- # Open a new CSV file to write the data
72
- with open(file_path, mode='w', newline='') as file:
73
- writer = csv.writer(file)
74
-
75
- # Generate the data
76
- signal_treshold = 1.5
77
- for _ in range(num_rows):
78
-
79
- # generate data columns:
80
- col1 = random.uniform(0, 2.7)
81
- col2 = random.uniform(0, 3.3)
82
- col3 = random.uniform(0, 7.3)
83
-
84
- # generate binarization columns:
85
- col4 = 1 if col1 > signal_treshold else ''
86
- col5 = 1 if col2 > signal_treshold else ''
87
- col6 = 1 if col3 > signal_treshold else ''
88
-
89
- writer.writerow([col1, col2, col3, col4, col5, col6])
90
-
91
- ```
92
-
93
-
94
- ---
95
- ``plot_sample_data.py``:
96
- ```python
97
- import DiaModality.CsvParser as csv
98
- import DiaModality.ModalityPlot as plt
99
- import os
100
-
101
- # input files:
102
- files = ['modality_data.csv']
103
-
104
- # Get full path
105
- script_dir = os.path.dirname(os.path.realpath(__file__))
106
-
107
- for file in files:
108
-
109
- # Get full path of input files
110
- file_path = os.path.join(script_dir, file)
111
-
112
- # Parse data from csv file
113
- new_csv = csv.LoadCsv(file_path)
114
- data, binarization = new_csv.ParseCsv(3, 3)
115
-
116
- # Make figure:
117
- plot = plt.ModalityPlot(
118
- data,
119
- binarization,
120
- modalities=[
121
- 'Set 1', 'Set 2', 'Set 3'],
122
- angles=[210, 90, 330],
123
- labels=False,
124
- scalecircle=0.5, # Scale circle radius
125
- scalecircle_linestyle=':',
126
- scalecircle_linewidth=0.75,
127
- marker='', # vector endpoints marker
128
- linestyle='-',
129
- linewidth=0.5,
130
- alpha=0.5,
131
- same_scale=False, # Draw all the subplots in the same scale
132
- full_center=True, # Draw all vectors in the central subplot, else draw trimodal vectors only
133
- whole_sum=True, # Calculate all three modality vectors despite binarization
134
- figsize=(10, 10),
135
- title='Modality Diagram Example',
136
- colors=(
137
- 'tab:green', # Set 1 color
138
- 'navy', # Set 2 color
139
- 'tab:red', # Set 3 color
140
- '#1E88E5', # Sets 1 & 2 intersection color
141
- '#FF9933', # Sets 1 & 3 intersection color
142
- '#9900FF', # Sets 2 & 3 intersection color
143
- 'black', # All sets intersection color
144
- ),
145
- )
146
-
147
- plot.save(file_path, type='png', transparent=False)
148
- plot.show()
149
- ```
150
-
151
- Source page:
152
- https://github.com/konung-yaropolk/DiaModality
153
-
154
-
155
- ![modality_data csv](https://github.com/user-attachments/assets/eb77b4d7-281f-45b0-a5ce-4c2442fc9a75)
1
+ Metadata-Version: 2.1
2
+ Name: DiaModality
3
+ Version: 0.1.7
4
+ Summary: Tool to plot modality vector diagrams
5
+ Author-email: konung-yaropolk <yaropolk1995@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 konung-yaropolk
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/konung-yaropolk/DiaModality
28
+ Project-URL: Issues, https://github.com/konung-yaropolk/DiaModality/issues
29
+ Keywords: Visualization,Plotting,Matplotlib
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Classifier: Development Status :: 4 - Beta
34
+ Classifier: Intended Audience :: Science/Research
35
+ Classifier: Natural Language :: English
36
+ Classifier: Topic :: Scientific/Engineering :: Visualization
37
+ Requires-Python: >=3.10
38
+ Description-Content-Type: text/markdown
39
+ License-File: LICENSE
40
+ Requires-Dist: numpy
41
+ Requires-Dist: matplotlib
42
+
43
+ # DiaModality - The Modality Diagram
44
+
45
+ Simple tool to plot vector modality diagram
46
+
47
+ [![pypi_version](https://img.shields.io/pypi/v/diamodality?label=PyPI&color=green)](https://pypi.org/project/diamodality)
48
+ [![PyPI - License](https://img.shields.io/pypi/l/diamodality)](https://pypi.org/project/diamodality)
49
+ [![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/diamodality)
50
+
51
+
52
+ ### To install package run the command:
53
+ ```bash
54
+ pip install diamodality
55
+ ```
56
+
57
+
58
+ ### Example of use:
59
+ See the /demo directory on Git repo or
60
+ create and run the following two files:
61
+ *(file names don't matter)*
62
+
63
+ ---
64
+ ``generate_sample_data.py``:
65
+ ```python
66
+ import csv
67
+ import random
68
+ import os
69
+
70
+ num_rows = 1500
71
+ output_file = 'modality_data.csv'
72
+
73
+ # locate working directory
74
+ script_dir = os.path.dirname(os.path.realpath(__file__))
75
+ file_path = os.path.join(script_dir, output_file)
76
+
77
+ # Open a new CSV file to write the data
78
+ with open(file_path, mode='w', newline='') as file:
79
+ writer = csv.writer(file)
80
+
81
+ # Generate the data
82
+ signal_treshold = 1.5
83
+ for _ in range(num_rows):
84
+
85
+ # generate data columns:
86
+ col1 = random.uniform(0, 2.7)
87
+ col2 = random.uniform(0, 3.3)
88
+ col3 = random.uniform(0, 7.3)
89
+
90
+ # generate binarization columns:
91
+ col4 = 1 if col1 > signal_treshold else ''
92
+ col5 = 1 if col2 > signal_treshold else ''
93
+ col6 = 1 if col3 > signal_treshold else ''
94
+
95
+ writer.writerow([col1, col2, col3, col4, col5, col6])
96
+
97
+ ```
98
+
99
+
100
+ ---
101
+ ``plot_sample_data.py``:
102
+ ```python
103
+ import DiaModality.CsvParser as csv
104
+ import DiaModality.ModalityPlot as plt
105
+ import os
106
+
107
+ # input files:
108
+ files = ['modality_data.csv']
109
+
110
+ # Get full path
111
+ script_dir = os.path.dirname(os.path.realpath(__file__))
112
+
113
+ for file in files:
114
+
115
+ # Get full path of input files
116
+ file_path = os.path.join(script_dir, file)
117
+
118
+ # Parse data from csv file
119
+ new_csv = csv.LoadCsv(file_path)
120
+ data, binarization = new_csv.ParseCsv(3, 3)
121
+
122
+ # Make figure:
123
+ plot = plt.ModalityPlot(
124
+ data,
125
+ binarization,
126
+ modalities=['Set 1', 'Set 2', 'Set 3'],
127
+ angles=[210, 90, 330],
128
+ labels=False,
129
+ scalecircle=0.5, # Scale circle radius
130
+ scalecircle_linestyle=':',
131
+ scalecircle_linewidth=0.75,
132
+ marker='', # vector endpoints marker
133
+ linestyle='-',
134
+ linewidth=0.5,
135
+ alpha=0.5,
136
+ same_scale=False, # Draw all the subplots in the same scale
137
+ full_center=True, # Draw all vectors in the central subplot,
138
+ # else draw trimodal vectors only
139
+ whole_sum=True, # Calculate all three modality vectors despite binarization
140
+ figsize=(10, 10),
141
+ title='Modality Diagram Example',
142
+ colors=(
143
+ 'tab:green', # Set 1 color
144
+ 'navy', # Set 2 color
145
+ 'tab:red', # Set 3 color
146
+ '#1E88E5', # Sets 1 & 2 intersection color
147
+ '#FF9933', # Sets 1 & 3 intersection color
148
+ '#9900FF', # Sets 2 & 3 intersection color
149
+ 'black', # All sets intersection color
150
+ ),
151
+ )
152
+
153
+ plot.save(file_path, type='png', transparent=False)
154
+ plot.show()
155
+ ```
156
+
157
+ Source page:
158
+ https://github.com/konung-yaropolk/DiaModality
159
+
160
+
161
+ ![modality_data csv](https://github.com/user-attachments/assets/eb77b4d7-281f-45b0-a5ce-4c2442fc9a75)
@@ -1,6 +1,11 @@
1
1
  # DiaModality - The Modality Diagram
2
2
 
3
- Simple tool to plot vector modality diagram
3
+ Simple tool to plot vector modality diagram
4
+
5
+ [![pypi_version](https://img.shields.io/pypi/v/diamodality?label=PyPI&color=green)](https://pypi.org/project/diamodality)
6
+ [![PyPI - License](https://img.shields.io/pypi/l/diamodality)](https://pypi.org/project/diamodality)
7
+ [![Python](https://img.shields.io/badge/Python-v3.10%5E-green?logo=python)](https://pypi.org/project/diamodality)
8
+
4
9
 
5
10
  ### To install package run the command:
6
11
  ```bash
@@ -8,9 +13,10 @@ pip install diamodality
8
13
  ```
9
14
 
10
15
 
11
- ### How to use:
16
+ ### Example of use:
12
17
  See the /demo directory on Git repo or
13
- create and run the following two files:
18
+ create and run the following two files:
19
+ *(file names don't matter)*
14
20
 
15
21
  ---
16
22
  ``generate_sample_data.py``:
@@ -75,8 +81,7 @@ for file in files:
75
81
  plot = plt.ModalityPlot(
76
82
  data,
77
83
  binarization,
78
- modalities=[
79
- 'Set 1', 'Set 2', 'Set 3'],
84
+ modalities=['Set 1', 'Set 2', 'Set 3'],
80
85
  angles=[210, 90, 330],
81
86
  labels=False,
82
87
  scalecircle=0.5, # Scale circle radius
@@ -87,7 +92,8 @@ for file in files:
87
92
  linewidth=0.5,
88
93
  alpha=0.5,
89
94
  same_scale=False, # Draw all the subplots in the same scale
90
- full_center=True, # Draw all vectors in the central subplot, else draw trimodal vectors only
95
+ full_center=True, # Draw all vectors in the central subplot,
96
+ # else draw trimodal vectors only
91
97
  whole_sum=True, # Calculate all three modality vectors despite binarization
92
98
  figsize=(10, 10),
93
99
  title='Modality Diagram Example',
@@ -1,35 +1,35 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "DiaModality"
7
- dynamic = ["version"]
8
- license = {file = "LICENSE"}
9
- authors = [
10
- { name="konung-yaropolk", email="yaropolk1995@gmail.com" },
11
- ]
12
- description = "Tool to plot modality vector diagrams"
13
- keywords = ["Visualization", "Plotting", "Matplotlib"]
14
- readme = "README.md"
15
- requires-python = ">=3.10"
16
- classifiers = [
17
- "Programming Language :: Python :: 3",
18
- "License :: OSI Approved :: MIT License",
19
- "Operating System :: OS Independent",
20
- "Development Status :: 4 - Beta",
21
- "Intended Audience :: Science/Research",
22
- "Natural Language :: English",
23
- "Topic :: Scientific/Engineering :: Visualization",
24
- ]
25
- dependencies = [
26
- "numpy",
27
- "matplotlib",
28
- ]
29
-
30
- [project.urls]
31
- Homepage = "https://github.com/konung-yaropolk/DiaModality"
32
- Issues = "https://github.com/konung-yaropolk/DiaModality/issues"
33
-
34
- [tool.setuptools.dynamic]
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "DiaModality"
7
+ dynamic = ["version"]
8
+ license = {file = "LICENSE"}
9
+ authors = [
10
+ { name="konung-yaropolk", email="yaropolk1995@gmail.com" },
11
+ ]
12
+ description = "Tool to plot modality vector diagrams"
13
+ keywords = ["Visualization", "Plotting", "Matplotlib"]
14
+ readme = "README.md"
15
+ requires-python = ">=3.10"
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Development Status :: 4 - Beta",
21
+ "Intended Audience :: Science/Research",
22
+ "Natural Language :: English",
23
+ "Topic :: Scientific/Engineering :: Visualization",
24
+ ]
25
+ dependencies = [
26
+ "numpy",
27
+ "matplotlib",
28
+ ]
29
+
30
+ [project.urls]
31
+ Homepage = "https://github.com/konung-yaropolk/DiaModality"
32
+ Issues = "https://github.com/konung-yaropolk/DiaModality/issues"
33
+
34
+ [tool.setuptools.dynamic]
35
35
  version = {attr = "DiaModality.__version__"}
@@ -1,4 +1,4 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -1,77 +1,77 @@
1
- #!/usr/bin/env python
2
- import csv
3
-
4
-
5
- class LoadCsv:
6
- '''
7
- The input CSV file must be comma delimited and contains only numeric
8
- data or empty cells. Each empty cell concideres as None.
9
- '''
10
-
11
- def __init__(self, file_path: str) -> None:
12
- self.file_path = file_path
13
-
14
- def ParseCsv(self, *args) -> list:
15
- '''
16
- The input is a list of integers.
17
- Output is list of matrices.
18
- Each int represent each output matrix and defines
19
- how many columns to include into matrix.
20
- Eg: input: (3, 2)
21
- output: list of two matrices, first one with 1-3 cols
22
- and second one with 4-5 cols from the original csv.
23
- '''
24
-
25
- with open(self.file_path, 'r') as file:
26
- reader = csv.reader(file)
27
- table = tuple(reader)
28
- output = []
29
-
30
- for i, arg in enumerate(args):
31
-
32
- output.append([])
33
- start = sum(args) - sum(args[i:])
34
- stop = start + arg
35
-
36
- for row in table:
37
- output[i].append(
38
- tuple(
39
- float(cell) if cell
40
- else None
41
- for cell in row[start:stop]
42
- )
43
- )
44
-
45
- return output
46
-
47
- def ParseCsv_old(self) -> list:
48
- '''
49
- Ugly legacy method specific for modality plot only
50
- to be removed if new one works well
51
- '''
52
- with open(self.file_path, 'r') as file:
53
- reader = csv.reader(file)
54
- data, binarization = [], []
55
- for row in reader:
56
- data.append(
57
- tuple(
58
- float(cell)
59
- if cell
60
- else 0
61
- for cell in row[:3]
62
- )
63
- )
64
- binarization.append(
65
- tuple(
66
- True
67
- if cell
68
- else False
69
- for cell in row[3:6]
70
- )
71
- )
72
-
73
- return data, binarization
74
-
75
-
76
- if __name__ == '__main__':
77
- print('\nThis script can be used as an imported module only\n')
1
+ #!/usr/bin/env python
2
+ import csv
3
+
4
+
5
+ class LoadCsv:
6
+ '''
7
+ The input CSV file must be comma delimited and contains only numeric
8
+ data or empty cells. Each empty cell concideres as None.
9
+ '''
10
+
11
+ def __init__(self, file_path: str) -> None:
12
+ self.file_path = file_path
13
+
14
+ def ParseCsv(self, *args) -> list:
15
+ '''
16
+ The input is a list of integers.
17
+ Output is list of matrices.
18
+ Each int represent each output matrix and defines
19
+ how many columns to include into matrix.
20
+ Eg: input: (3, 2)
21
+ output: list of two matrices, first one with 1-3 cols
22
+ and second one with 4-5 cols from the original csv.
23
+ '''
24
+
25
+ with open(self.file_path, 'r') as file:
26
+ reader = csv.reader(file)
27
+ table = tuple(reader)
28
+ output = []
29
+
30
+ for i, arg in enumerate(args):
31
+
32
+ output.append([])
33
+ start = sum(args) - sum(args[i:])
34
+ stop = start + arg
35
+
36
+ for row in table:
37
+ output[i].append(
38
+ tuple(
39
+ float(cell) if cell
40
+ else None
41
+ for cell in row[start:stop]
42
+ )
43
+ )
44
+
45
+ return output
46
+
47
+ def ParseCsv_old(self) -> list:
48
+ '''
49
+ Ugly legacy method specific for modality plot only
50
+ to be removed if new one works well
51
+ '''
52
+ with open(self.file_path, 'r') as file:
53
+ reader = csv.reader(file)
54
+ data, binarization = [], []
55
+ for row in reader:
56
+ data.append(
57
+ tuple(
58
+ float(cell)
59
+ if cell
60
+ else 0
61
+ for cell in row[:3]
62
+ )
63
+ )
64
+ binarization.append(
65
+ tuple(
66
+ True
67
+ if cell
68
+ else False
69
+ for cell in row[3:6]
70
+ )
71
+ )
72
+
73
+ return data, binarization
74
+
75
+
76
+ if __name__ == '__main__':
77
+ print('\nThis script can be used as an imported module only\n')