AnomalyLab 0.3.0__tar.gz → 0.3.1__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.
Files changed (49) hide show
  1. {anomalylab-0.3.0 → anomalylab-0.3.1/AnomalyLab.egg-info}/PKG-INFO +1 -1
  2. {anomalylab-0.3.0/AnomalyLab.egg-info → anomalylab-0.3.1}/PKG-INFO +1 -1
  3. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/visualization/format.py +40 -3
  4. {anomalylab-0.3.0 → anomalylab-0.3.1}/setup.py +1 -1
  5. {anomalylab-0.3.0 → anomalylab-0.3.1}/.gitattributes +0 -0
  6. {anomalylab-0.3.0 → anomalylab-0.3.1}/.github/workflows/python-publish.yml +0 -0
  7. {anomalylab-0.3.0 → anomalylab-0.3.1}/.gitignore +0 -0
  8. {anomalylab-0.3.0 → anomalylab-0.3.1}/AnomalyLab.egg-info/SOURCES.txt +0 -0
  9. {anomalylab-0.3.0 → anomalylab-0.3.1}/AnomalyLab.egg-info/dependency_links.txt +0 -0
  10. {anomalylab-0.3.0 → anomalylab-0.3.1}/AnomalyLab.egg-info/requires.txt +0 -0
  11. {anomalylab-0.3.0 → anomalylab-0.3.1}/AnomalyLab.egg-info/top_level.txt +0 -0
  12. {anomalylab-0.3.0 → anomalylab-0.3.1}/LICENSE +0 -0
  13. {anomalylab-0.3.0 → anomalylab-0.3.1}/MANIFEST.in +0 -0
  14. {anomalylab-0.3.0 → anomalylab-0.3.1}/README.md +0 -0
  15. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/__init__.py +0 -0
  16. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/config.py +0 -0
  17. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/core/__init__.py +0 -0
  18. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/core/core.py +0 -0
  19. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/datasets/__init__.py +0 -0
  20. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/datasets/dataset.py +0 -0
  21. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/datasets/panel_data.csv +0 -0
  22. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/datasets/time_series_data.csv +0 -0
  23. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/datasets/transition_matrix.png +0 -0
  24. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/__init__.py +0 -0
  25. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/correlation.py +0 -0
  26. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/empirical.py +0 -0
  27. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/factor_return.py +0 -0
  28. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/fm_regression.py +0 -0
  29. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/persistence.py +0 -0
  30. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/portfolio.py +0 -0
  31. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/empirical/summary.py +0 -0
  32. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/__init__.py +0 -0
  33. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/fillna.py +0 -0
  34. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/normalize.py +0 -0
  35. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/outliers.py +0 -0
  36. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/preprocessor.py +0 -0
  37. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/shift.py +0 -0
  38. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/preprocess/truncate.py +0 -0
  39. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/structure/__init__.py +0 -0
  40. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/structure/data.py +0 -0
  41. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/structure/panel_data.py +0 -0
  42. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/structure/time_series.py +0 -0
  43. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/utils/__init__.py +0 -0
  44. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/utils/imports.py +0 -0
  45. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/utils/utils.py +0 -0
  46. {anomalylab-0.3.0 → anomalylab-0.3.1}/anomalylab/visualization/__init__.py +0 -0
  47. {anomalylab-0.3.0 → anomalylab-0.3.1}/requirements.txt +0 -0
  48. {anomalylab-0.3.0 → anomalylab-0.3.1}/setup.cfg +0 -0
  49. {anomalylab-0.3.0 → anomalylab-0.3.1}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AnomalyLab
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A Python package for empirical asset pricing analysis.
5
5
  Author: FinPhd
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AnomalyLab
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A Python package for empirical asset pricing analysis.
5
5
  Author: FinPhd
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,9 +1,15 @@
1
1
  from anomalylab.utils.imports import *
2
2
 
3
+ # from dataclasses import dataclass
4
+ # from openpyxl import load_workbook
5
+ # from openpyxl.styles import Alignment, Border, Side
6
+ # from glob import glob
7
+ # import os
8
+
3
9
 
4
10
  @dataclass
5
11
  class FormatExcel:
6
- """Class to format Excel files by adjusting cell alignment and borders.
12
+ """Class to format Excel files by adjusting cell alignment, borders, and column widths.
7
13
 
8
14
  Attributes:
9
15
  path (str): The directory or file path of the Excel file(s) to format.
@@ -92,15 +98,44 @@ class FormatExcel:
92
98
  elif direction == "to_round":
93
99
  cell.value = cell.value.replace("[", "(").replace("]", ")")
94
100
 
101
+ def auto_adjust_column_widths(self):
102
+ """Automatically adjusts the column widths to fit the contents."""
103
+ for ws in self.wb.worksheets:
104
+ for column in ws.columns:
105
+ max_length = 0
106
+ col_letter = column[0].column_letter # Get the column letter
107
+ for cell in column:
108
+ try:
109
+ cell_length = sum(
110
+ 2 if ord(char) > 127 else 1 for char in str(cell.value)
111
+ )
112
+ max_length = max(max_length, cell_length)
113
+ except:
114
+ pass
115
+ # Adjust for header row
116
+ # header_cell = ws[f"{col_letter}1"]
117
+ # if header_cell.value:
118
+ # max_length = max(max_length, len(str(header_cell.value)))
119
+ adjusted_width = max_length + 2 # Add some padding to the width
120
+ ws.column_dimensions[col_letter].width = adjusted_width
121
+
95
122
  def save(self):
96
123
  """Saves the currently loaded workbook to its file path."""
97
124
  self.wb.save(self.file_path)
98
125
 
99
- def process(self, align=True, line=True, convert_brackets=False):
126
+ def process(
127
+ self, align=True, line=True, convert_brackets=False, adjust_col_widths=False
128
+ ):
100
129
  """Processes and formats Excel files.
101
130
 
102
131
  - If the provided path is a directory, it formats all Excel files in that directory.
103
132
  - If the provided path is a file, it formats that specific Excel file.
133
+
134
+ Args:
135
+ align (bool): Whether to apply text alignment. Default is True.
136
+ line (bool): Whether to apply borders. Default is True.
137
+ convert_brackets (bool): Whether to convert brackets. Default is False.
138
+ auto_adjust (bool): Whether to adjust column widths. Default is False.
104
139
  """
105
140
  files_to_process = (
106
141
  glob(os.path.join(self.path, "*.xlsx"))
@@ -116,10 +151,12 @@ class FormatExcel:
116
151
  self.line()
117
152
  if convert_brackets:
118
153
  self.convert_brackets()
154
+ if adjust_col_widths:
155
+ self.auto_adjust_column_widths()
119
156
  self.save()
120
157
 
121
158
 
122
159
  if __name__ == "__main__":
123
160
  path = "..."
124
161
  excel_formatter = FormatExcel(path)
125
- excel_formatter.process(convert_brackets=True)
162
+ excel_formatter.process()
@@ -2,7 +2,7 @@ from setuptools import find_packages, setup
2
2
 
3
3
  setup(
4
4
  name="AnomalyLab",
5
- version="0.3.0",
5
+ version="0.3.1",
6
6
  author="FinPhd",
7
7
  # author_email="your.email@example.com",
8
8
  description="A Python package for empirical asset pricing analysis.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes