-
Notifications
You must be signed in to change notification settings - Fork 0
Fix package structure, update badges, and resolve gitignore blocking source code #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
52c192e
5866646
6d6b48f
8ebc0d7
5d9a01a
347f521
b7a9008
ae28c3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,21 +5,24 @@ Un toolkit Python complet pour l'analyse statistique et le traitement des donné | |
| ## 🏆 Qualité du Code | ||
|
||
|
|
||
| [](https://www.python.org/downloads/) | ||
| [](https://pypi.org/project/py-stats-toolkit/) | ||
| [](https://pypi.org/project/py-stats-toolkit/) | ||
| [](https://pypi.org/project/py-stats-toolkit/) | ||
| [](https://opensource.org/licenses/MIT) | ||
| [](https://github.com/ThePhoenixAgency/py-stats-toolkit/actions/workflows/tests.yml) | ||
| [](https://github.com/ThePhoenixAgency/py-stats-toolkit/actions/workflows/publish.yml) | ||
| [](https://github.com/psf/black) | ||
| [](https://pycqa.github.io/isort/) | ||
| [](https://flake8.pycqa.org/) | ||
| [](https://mypy-lang.org/) | ||
| [](https://bandit.readthedocs.io/) | ||
| [](https://docs.pytest.org/) | ||
| [](https://codecov.io/) | ||
|
|
||
| ## 🚀 Installation | ||
|
|
||
| ### Installation depuis PyPI (recommandé) | ||
|
|
||
| ```bash | ||
| pip install py-stats-toolkit==1.0.3 | ||
|
||
| pip install py-stats-toolkit | ||
| ``` | ||
|
|
||
| ### Installation depuis les sources | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| """ | ||
|
|
||
| # Version du toolkit | ||
| __version__ = "1.0.1" | ||
| __version__ = "1.0.4" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
|
|
||
| # Imports des modules principaux | ||
| try: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| """ | ||
| ===================================================================== | ||
| File : BaseCapsule.py | ||
| ===================================================================== | ||
| version : 1.0.0 | ||
| release : 15/06/2025 | ||
| author : Phoenix Project | ||
| contact : [email protected] | ||
EthanThePhoenix38 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| license : MIT | ||
| ===================================================================== | ||
| Copyright (c) 2025, Phoenix Project | ||
| All rights reserved. | ||
| Description du module BaseCapsule.py | ||
| Base class for all statistical analysis capsules/modules. | ||
| Provides common interface and functionality for data processing. | ||
| tags : module, base, capsule | ||
| ===================================================================== | ||
| """ | ||
|
|
||
| from typing import Any, Dict, Union | ||
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
|
|
||
|
|
||
| class BaseCapsule: | ||
| """ | ||
| Base class for all statistical analysis modules. | ||
| Provides common interface for data validation, configuration, | ||
| and processing workflow. | ||
| Attributes: | ||
| data: Input data being processed | ||
| parameters: Configuration parameters | ||
| result: Analysis results | ||
| """ | ||
|
|
||
| def __init__(self): | ||
| """Initialize BaseCapsule with default attributes.""" | ||
| self.data = None | ||
| self.parameters = {} | ||
| self.result = None | ||
|
|
||
| def configure(self, **kwargs) -> None: | ||
| """ | ||
| Configure the module parameters. | ||
| Args: | ||
| **kwargs: Configuration parameters | ||
| """ | ||
| self.parameters.update(kwargs) | ||
|
|
||
| def validate_data( | ||
| self, data: Union[pd.DataFrame, pd.Series, np.ndarray, list] | ||
| ) -> None: | ||
| """ | ||
| Validate input data. | ||
| Args: | ||
| data: Data to validate | ||
| Raises: | ||
| ValueError: If data is invalid | ||
| """ | ||
| if data is None: | ||
| raise ValueError("Data cannot be None") | ||
|
|
||
| if isinstance(data, (pd.DataFrame, pd.Series)): | ||
| if data.empty: | ||
| raise ValueError("Data cannot be empty") | ||
|
Check failure on line 74 in py_stats_toolkit/capsules/BaseCapsule.py
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merci de corriger comme préconisé
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Corrected as recommended - changed to catch specific exceptions (TypeError, ValueError). Fixed in commit b7a9008. |
||
| elif isinstance(data, (np.ndarray, list)): | ||
| if len(data) == 0: | ||
| raise ValueError("Data cannot be empty") | ||
| else: | ||
| # Try to convert to array-like | ||
| try: | ||
| data_array = np.array(data) | ||
| if data_array.size == 0: | ||
| raise ValueError("Data cannot be empty") | ||
| except Exception as e: | ||
EthanThePhoenix38 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| raise ValueError(f"Invalid data type: {type(data)}. Error: {e}") | ||
|
|
||
| def process( | ||
| self, data: Union[pd.DataFrame, pd.Series, np.ndarray], **kwargs | ||
| ) -> Dict[str, Any]: | ||
| """ | ||
| Process data and perform analysis. | ||
| This method should be overridden by subclasses. | ||
| Args: | ||
| data: Input data to process | ||
| **kwargs: Additional processing parameters | ||
| Returns: | ||
| Dict[str, Any]: Analysis results | ||
| """ | ||
| raise NotImplementedError("Subclasses must implement the process method") | ||
|
|
||
| def get_result(self) -> Any: | ||
| """ | ||
| Get the analysis result. | ||
| Returns: | ||
| Analysis result | ||
| """ | ||
| return self.result | ||
|
|
||
| def reset(self) -> None: | ||
| """Reset the module to initial state.""" | ||
| self.data = None | ||
| self.parameters = {} | ||
| self.result = None | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,96 @@ | ||||||||||||
| """ | ||||||||||||
| Correlation analysis module. | ||||||||||||
| Provides the CorrelationAnalysis class for computing correlations between variables. | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| from typing import Any, Dict, Union | ||||||||||||
|
|
||||||||||||
| import numpy as np | ||||||||||||
| import pandas as pd | ||||||||||||
| from scipy import stats | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class CorrelationAnalysis: | ||||||||||||
| """ | ||||||||||||
| Correlation analysis class. | ||||||||||||
| Computes correlation coefficients between variables with support for | ||||||||||||
| different correlation methods (Pearson, Spearman, Kendall). | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| def __init__(self, method: str = "pearson"): | ||||||||||||
| """ | ||||||||||||
| Initialize CorrelationAnalysis. | ||||||||||||
| Args: | ||||||||||||
| method: Correlation method ('pearson', 'spearman', or 'kendall') | ||||||||||||
| """ | ||||||||||||
|
||||||||||||
| """ | |
| """ | |
| valid_methods = {"pearson", "spearman", "kendall"} | |
| if method not in valid_methods: | |
| raise ValueError(f"Method must be one of {valid_methods}, got '{method}'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added method validation in init as suggested. Invalid methods now fail immediately with a clear error message. Fixed in commit b7a9008.
Check failure on line 31 in py_stats_toolkit/stats/correlation.py
SonarQubeCloud / SonarCloud Code Analysis
Refactor this function to reduce its Cognitive Complexity from 25 to the 15 allowed.
See more on https://sonarcloud.io/project/issues?id=PhoenixGuardianTools_py-stats-toolkit&issues=AZsFuAlDp_ZvhC2qzhZf&open=AZsFuAlDp_ZvhC2qzhZf&pullRequest=5
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||
| """ | ||||||||
| Statistics descriptives module. | ||||||||
| Provides the DescriptiveStatistics class for computing descriptive | ||||||||
| statistics on various data types (lists, arrays, Series, DataFrames). | ||||||||
| """ | ||||||||
|
|
||||||||
| from typing import Any, Dict, Union | ||||||||
|
|
||||||||
| import numpy as np | ||||||||
| import pandas as pd | ||||||||
|
|
||||||||
|
|
||||||||
| class DescriptiveStatistics: | ||||||||
| """ | ||||||||
| Class for computing descriptive statistics. | ||||||||
| Handles various data types and provides comprehensive statistical measures | ||||||||
| including central tendency, dispersion, and percentiles. | ||||||||
| """ | ||||||||
|
|
||||||||
| def __init__(self): | ||||||||
| """Initialize DescriptiveStatistics.""" | ||||||||
| pass | ||||||||
|
||||||||
| def __init__(self): | |
| """Initialize DescriptiveStatistics.""" | |
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the empty init method. Python will use the default object.init. Fixed in commit b7a9008.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sonarqube a suggéré un changement par
def init(self):
"""Initialize DescriptiveStatistics."""
pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je n'ai pas mis ces tirets!