Topsis-Pulkit-102303800 1.0.0__tar.gz → 1.0.5__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Topsis-Pulkit-102303800
3
- Version: 1.0.0
3
+ Version: 1.0.5
4
4
  Summary: CLI-based TOPSIS implementation
5
5
  Author: Pulkit Goyal
6
6
  Requires-Python: >=3.6
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Topsis-Pulkit-102303800
3
- Version: 1.0.0
3
+ Version: 1.0.5
4
4
  Summary: CLI-based TOPSIS implementation
5
5
  Author: Pulkit Goyal
6
6
  Requires-Python: >=3.6
@@ -6,4 +6,6 @@ Topsis_Pulkit_102303800.egg-info/SOURCES.txt
6
6
  Topsis_Pulkit_102303800.egg-info/dependency_links.txt
7
7
  Topsis_Pulkit_102303800.egg-info/entry_points.txt
8
8
  Topsis_Pulkit_102303800.egg-info/requires.txt
9
- Topsis_Pulkit_102303800.egg-info/top_level.txt
9
+ Topsis_Pulkit_102303800.egg-info/top_level.txt
10
+ topsis_pulkit_102303800/__init__.py
11
+ topsis_pulkit_102303800/topsis.py
@@ -0,0 +1 @@
1
+ topsis_pulkit_102303800
@@ -2,10 +2,10 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="Topsis-Pulkit-102303800",
5
- version="1.0.0",
5
+ version="1.0.5",
6
6
  author="Pulkit Goyal",
7
7
  description="CLI-based TOPSIS implementation",
8
- packages=find_packages(),
8
+ packages=find_packages(), # 🔥 this auto-detects folder
9
9
  install_requires=["pandas", "numpy", "openpyxl"],
10
10
  entry_points={
11
11
  'console_scripts': [
@@ -0,0 +1 @@
1
+ from .topsis import main
@@ -0,0 +1,66 @@
1
+ import os
2
+ import sys
3
+ import pandas as pd
4
+ import numpy as np
5
+ import argparse
6
+
7
+
8
+ def topsis(input_file, weights, impacts, output_file):
9
+ if not os.path.exists(input_file):
10
+ sys.exit("Error: File not found")
11
+
12
+ if not (input_file.endswith('.csv') or input_file.endswith('.xlsx')):
13
+ sys.exit("Error: Only CSV and XLSX files allowed")
14
+
15
+ df = pd.read_csv(input_file) if input_file.endswith('.csv') else pd.read_excel(input_file)
16
+
17
+ if df.shape[1] < 3:
18
+ sys.exit("Error: File must have 3+ columns")
19
+
20
+ data = df.iloc[:, 1:].values
21
+
22
+ try:
23
+ data = data.astype(float)
24
+ except:
25
+ sys.exit("Error: Data columns must be numeric")
26
+
27
+ weights = list(map(float, weights.split(',')))
28
+ impacts = impacts.split(',')
29
+
30
+ if len(weights) != data.shape[1] or len(impacts) != data.shape[1]:
31
+ sys.exit("Error: Number of weights and impacts must equal number of columns")
32
+
33
+ if any(i not in ['+', '-'] for i in impacts):
34
+ sys.exit("Error: Impacts must be + or -")
35
+
36
+ norm = data / np.sqrt((data**2).sum(axis=0))
37
+ weighted = norm * weights
38
+
39
+ ideal_best = np.max(weighted, axis=0)
40
+ ideal_worst = np.min(weighted, axis=0)
41
+
42
+ for i, imp in enumerate(impacts):
43
+ if imp == '-':
44
+ ideal_best[i], ideal_worst[i] = ideal_worst[i], ideal_best[i]
45
+
46
+ dist_best = np.sqrt(((weighted - ideal_best)**2).sum(axis=1))
47
+ dist_worst = np.sqrt(((weighted - ideal_worst)**2).sum(axis=1))
48
+
49
+ score = dist_worst / (dist_best + dist_worst)
50
+
51
+ df["Topsis Score"] = score
52
+ df["Rank"] = score.argsort()[::-1] + 1
53
+
54
+ df.to_csv(output_file, index=False)
55
+ print("TOPSIS calculation complete. Output saved.")
56
+
57
+
58
+ def main():
59
+ parser = argparse.ArgumentParser(description="TOPSIS Decision Making Tool")
60
+ parser.add_argument("input_file")
61
+ parser.add_argument("weights")
62
+ parser.add_argument("impacts")
63
+ parser.add_argument("output_file")
64
+ args = parser.parse_args()
65
+
66
+ topsis(args.input_file, args.weights, args.impacts, args.output_file)