Skip to content

Commit

Permalink
Merge pull request #23 from WenjieDu/dev
Browse files Browse the repository at this point in the history
Updating the docs and adding pytorch into dependencies
  • Loading branch information
WenjieDu authored Nov 6, 2023
2 parents c748c8e + 8bb1894 commit 9f7929a
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 730 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/testing_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
python-version: [ 3.7, 3.9 ]
python-version: [ '3.7', '3.10' ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v3

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest
pip install coverage
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: pip
cache-dependency-path: |
requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest coverage
- name: Test with pytest
run: |
Expand Down
702 changes: 28 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<img alt="the latest release version" src="https://img.shields.io/github/v/release/wenjiedu/PyGrinder?color=EE781F&include_prereleases&label=Release&logo=github&logoColor=white">
</a>
<a href="https://github.com/WenjieDu/PyGrinder/blob/main/LICENSE">
<img alt="GPL-v3 license" src="https://img.shields.io/badge/License-GPL--v3-E9BB41?logo=opensourceinitiative&logoColor=white">
<img alt="BSD-3 license" src="https://img.shields.io/badge/License-BSD--3-E9BB41?logo=opensourceinitiative&logoColor=white">
</a>
<a href='https://github.com/WenjieDu/PyGrinder/actions/workflows/testing_ci.yml'>
<img alt='GitHub Testing' src='https://img.shields.io/github/actions/workflow/status/wenjiedu/PyGrinder/testing_ci.yml?logo=github&color=C8D8E1&label=CI'>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Welcome to PyGrinder's docs!
.. image:: https://img.shields.io/github/v/release/wenjiedu/pygrinder?color=EE781F&include_prereleases&label=Release&logo=github&logoColor=white
:alt: the latest release version
:target: https://img.shields.io/github/v/release/wenjiedu/pygrinder?color=EE781F&include_prereleases&label=Release&logo=github&logoColor=white
.. image:: https://img.shields.io/badge/License-GPL--v3-E9BB41?logo=opensourceinitiative&logoColor=white
.. image:: https://img.shields.io/badge/License-BSD--3-E9BB41?logo=opensourceinitiative&logoColor=white
:alt: License
:target: https://github.com/WenjieDu/PyGrinder/blob/main/LICENSE
.. image:: https://img.shields.io/github/actions/workflow/status/wenjiedu/pygrinder/testing_ci.yml?logo=github&color=C8D8E1&label=CI
Expand Down
4 changes: 2 additions & 2 deletions pygrinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

# PyGrinder version
#
Expand All @@ -21,7 +21,7 @@
#
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
__version__ = "0.1.1"
__version__ = "0.2"

try:
from pygrinder.missing_completely_at_random import mcar, mcar_little_test
Expand Down
2 changes: 1 addition & 1 deletion pygrinder/missing_at_random/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from .mar_logistic import mar_logistic

Expand Down
8 changes: 2 additions & 6 deletions pygrinder/missing_at_random/mar_logistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from typing import Union, Tuple

import numpy as np
import torch
from scipy import optimize

try:
import torch
except ImportError:
pass


def mar_logistic(
X: Union[torch.Tensor, np.ndarray],
Expand Down
2 changes: 1 addition & 1 deletion pygrinder/missing_completely_at_random/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from .little_test import mcar_little_test
from .mcar import mcar
Expand Down
19 changes: 17 additions & 2 deletions pygrinder/missing_completely_at_random/little_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GPL-v3
# License: BSD-3-Clause

from typing import Union

Expand All @@ -14,7 +14,22 @@ def mcar_little_test(X: Union[pd.DataFrame, np.ndarray]) -> float:
Notes
-----
This implementation is inspired by
https://github.com/RianneSchouten/pyampute/blob/master/pyampute/exploration/mcar_statistical_tests.py
https://github.com/RianneSchouten/pyampute/blob/master/pyampute/exploration/mcar_statistical_tests.py.
Note that this function should be used carefully. Rejecting the null hypothesis may not always mean that
the data is not MCAR, nor is accepting the null hypothesis a guarantee that the data is MCAR.
Parameters
----------
X:
Time series data containing missing values that should be in shape of [n_steps, n_features],
i.e. have 2 dimensions.
Returns
-------
p_value:
The p-value of a chi-square hypothesis test.
Null hypothesis: the time series is missing completely at random (MCAR).
"""

if isinstance(X, np.ndarray):
Expand Down
8 changes: 2 additions & 6 deletions pygrinder/missing_completely_at_random/mcar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GPL-v3
# License: BSD-3-Clause

from typing import Union, Tuple

import numpy as np

try:
import torch
except ImportError:
pass
import torch


def mcar(
Expand Down
2 changes: 1 addition & 1 deletion pygrinder/missing_not_at_random/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from .mnar_t import mnar_t
from .mnar_x import mnar_x
Expand Down
8 changes: 2 additions & 6 deletions pygrinder/missing_not_at_random/mnar_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
"""

# Created by Jun Wang <jwangfx@connect.ust.hk> and Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from typing import Optional, Union, Tuple

import numpy as np

try:
import torch
except ImportError:
pass
import torch


def mnar_t(
Expand Down
8 changes: 2 additions & 6 deletions pygrinder/missing_not_at_random/mnar_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
"""

# Created by Jun Wang <jwangfx@connect.ust.hk> and Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

from typing import Optional, Union, Tuple

import numpy as np

try:
import torch
except ImportError:
pass
import torch


def mnar_x(
Expand Down
8 changes: 2 additions & 6 deletions pygrinder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GPL-v3
# License: BSD-3-Clause

from typing import Union

import numpy as np

try:
import torch
except ImportError:
pass
import torch


def cal_missing_rate(X: Union[np.ndarray, torch.Tensor]) -> float:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy
scikit-learn
pandas
pandas
torch
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file stores some meta configurations for project PyGrinder.

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

[flake8]
# People may argue that coding style is personal. This may be true if the project is personal and one works like a
Expand Down
12 changes: 11 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
description="A Python toolkit for introducing missing values into datasets",
long_description=README,
long_description_content_type="text/markdown",
license="GPL-3.0",
license="BSD-3-Clause",
author="Wenjie Du",
author_email="wenjay.du@gmail.com",
url="https://github.com/WenjieDu/PyGrinder",
Expand All @@ -36,6 +36,16 @@
"numpy",
"scipy",
"pandas",
"torch",
],
setup_requires=["setuptools>=38.6.0"],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
],
)
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause
2 changes: 1 addition & 1 deletion tests/test_pygrinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

# Created by Wenjie Du <wenjay.du@gmail.com>
# License: GLP-v3
# License: BSD-3-Clause

import unittest

Expand Down

0 comments on commit 9f7929a

Please sign in to comment.