Topsis-Anahat-102313058 1.0.0__tar.gz → 1.0.2__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.
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/PKG-INFO +1 -1
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/Topsis_Anahat_102313058.egg-info/PKG-INFO +1 -1
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/Topsis_Anahat_102313058.egg-info/SOURCES.txt +2 -2
- topsis_anahat_102313058-1.0.2/Topsis_Anahat_102313058.egg-info/top_level.txt +1 -0
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/setup.py +1 -1
- {topsis_anahat_102313058-1.0.0/topsis-anahat-102313058 → topsis_anahat_102313058-1.0.2/topsis_anahat_102313058}/topsis.py +9 -22
- topsis_anahat_102313058-1.0.0/Topsis_Anahat_102313058.egg-info/top_level.txt +0 -1
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/README.md +0 -0
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/Topsis_Anahat_102313058.egg-info/dependency_links.txt +0 -0
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/Topsis_Anahat_102313058.egg-info/entry_points.txt +0 -0
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/Topsis_Anahat_102313058.egg-info/requires.txt +0 -0
- {topsis_anahat_102313058-1.0.0 → topsis_anahat_102313058-1.0.2}/setup.cfg +0 -0
- {topsis_anahat_102313058-1.0.0/topsis-anahat-102313058 → topsis_anahat_102313058-1.0.2/topsis_anahat_102313058}/__init__.py +0 -0
|
@@ -6,5 +6,5 @@ Topsis_Anahat_102313058.egg-info/dependency_links.txt
|
|
|
6
6
|
Topsis_Anahat_102313058.egg-info/entry_points.txt
|
|
7
7
|
Topsis_Anahat_102313058.egg-info/requires.txt
|
|
8
8
|
Topsis_Anahat_102313058.egg-info/top_level.txt
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
topsis_anahat_102313058/__init__.py
|
|
10
|
+
topsis_anahat_102313058/topsis.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
topsis_anahat_102313058
|
|
@@ -6,18 +6,9 @@ def error(msg):
|
|
|
6
6
|
print(f"Error: {msg}")
|
|
7
7
|
sys.exit(1)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if len(sys.argv) != 5:
|
|
12
|
-
error("Incorrect number of parameters.\nUsage: python topsis.py <InputFile> <Weights> <Impacts> <OutputFile>")
|
|
9
|
+
# ✅ THIS FUNCTION IS REQUIRED FOR PyPI CLI
|
|
10
|
+
def topsis(input_file, weights, impacts, output_file):
|
|
13
11
|
|
|
14
|
-
input_file = sys.argv[1]
|
|
15
|
-
weights = sys.argv[2]
|
|
16
|
-
impacts = sys.argv[3]
|
|
17
|
-
output_file = sys.argv[4]
|
|
18
|
-
|
|
19
|
-
#Message for wrong inputs
|
|
20
|
-
#File Handling
|
|
21
12
|
try:
|
|
22
13
|
data = pd.read_csv(input_file)
|
|
23
14
|
except FileNotFoundError:
|
|
@@ -26,13 +17,11 @@ def main():
|
|
|
26
17
|
if data.shape[1] < 3:
|
|
27
18
|
error("Input file must contain three or more columns.")
|
|
28
19
|
|
|
29
|
-
#Numeric Validation
|
|
30
20
|
try:
|
|
31
21
|
matrix = data.iloc[:, 1:].astype(float)
|
|
32
22
|
except ValueError:
|
|
33
23
|
error("From 2nd to last columns must contain numeric values only.")
|
|
34
24
|
|
|
35
|
-
#Weights & Impacts
|
|
36
25
|
try:
|
|
37
26
|
weights = list(map(float, weights.split(',')))
|
|
38
27
|
except:
|
|
@@ -47,14 +36,9 @@ def main():
|
|
|
47
36
|
if i not in ['+', '-']:
|
|
48
37
|
error("Impacts must be either '+' or '-'.")
|
|
49
38
|
|
|
50
|
-
# TOPSIS Steps
|
|
51
|
-
# Step 1: Normalize
|
|
52
39
|
norm = matrix / np.sqrt((matrix ** 2).sum())
|
|
53
|
-
|
|
54
|
-
# Step 2: Weighting
|
|
55
40
|
weighted = norm * weights
|
|
56
41
|
|
|
57
|
-
# Step 3: Ideal best & worst
|
|
58
42
|
ideal_best = []
|
|
59
43
|
ideal_worst = []
|
|
60
44
|
|
|
@@ -69,20 +53,23 @@ def main():
|
|
|
69
53
|
ideal_best = np.array(ideal_best)
|
|
70
54
|
ideal_worst = np.array(ideal_worst)
|
|
71
55
|
|
|
72
|
-
# Step 4: Distance
|
|
73
56
|
dist_best = np.sqrt(((weighted - ideal_best) ** 2).sum(axis=1))
|
|
74
57
|
dist_worst = np.sqrt(((weighted - ideal_worst) ** 2).sum(axis=1))
|
|
75
58
|
|
|
76
|
-
# Step 5: Score
|
|
77
59
|
score = dist_worst / (dist_best + dist_worst)
|
|
78
60
|
|
|
79
|
-
# Step 6: Rank
|
|
80
61
|
data['Topsis Score'] = score
|
|
81
62
|
data['Rank'] = data['Topsis Score'].rank(ascending=False, method='dense').astype(int)
|
|
82
63
|
|
|
83
|
-
# Output
|
|
84
64
|
data.to_csv(output_file, index=False)
|
|
85
65
|
print(f"TOPSIS result saved to {output_file}")
|
|
86
66
|
|
|
67
|
+
# ✅ THIS MAINTAINS CLI USAGE (python topsis.py ...)
|
|
68
|
+
def main():
|
|
69
|
+
if len(sys.argv) != 5:
|
|
70
|
+
error("Incorrect number of parameters.\nUsage: python topsis.py <InputFile> <Weights> <Impacts> <OutputFile>")
|
|
71
|
+
|
|
72
|
+
topsis(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
|
73
|
+
|
|
87
74
|
if __name__ == "__main__":
|
|
88
75
|
main()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
topsis-anahat-102313058
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|