Skip to content

Commit

Permalink
Merge branch 'refactor' of https://github.com/jkanche/mopsy into refa…
Browse files Browse the repository at this point in the history
…ctor
  • Loading branch information
jkanche committed Jan 5, 2024
2 parents e19cb42 + de0434f commit 12dfcd8
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
password: ${{ secrets.PYPI_PASSWORD }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Changelog


## Version 0.2.0
## Version 0.2.0
- Support multi apply

## Version 0.1 (development)

- first release
- performs some basic operations over numpy or scipy matrices.
- performs some basic operations over numpy or scipy matrices.
- provides apply method so user can extend the underlying logic to any function
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
furo
# Requirements file for ReadTheDocs, check .readthedocs.yml.
# To build the module reference correctly, make sure every external package
# under `install_requires` in `setup.cfg` is also listed here!
# sphinx_rtd_theme
recommonmark
sphinx>=3.2.1
furo
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ apply(nz_func, mat, axis=1)

## Multiple functions

`mopsy` also supports applying multiple functions at the same time.
`mopsy` also supports applying multiple functions at the same time.

```python
from mopsy import multi_apply
Expand All @@ -73,4 +73,4 @@ tmat_wrow = append_row(mat, np.array([0, 0, 0, 0, 0]))
tmat_wcol = append_col(mat, np.array([[0], [0], [0], [0], [0]]))
```

That's all for today!
That's all for today!
10 changes: 4 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""
Setup file for mopsy.
Use setup.cfg to configure your project.
"""Setup file for mopsy. Use setup.cfg to configure your project.
This file was generated with PyScaffold 4.1.1.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
This file was generated with PyScaffold 4.1.1.
PyScaffold helps you to put up the scaffold of your new Python project.
Learn more under: https://pyscaffold.org/
"""
from setuptools import setup

Expand Down
2 changes: 1 addition & 1 deletion src/mopsy/checkutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


def check_axis(axis: Union[int, bool]):
"""Check if axis has a correct value
"""Check if axis has a correct value.
Args:
axis:
Expand Down
2 changes: 1 addition & 1 deletion src/mopsy/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from statistics import mean, median
from typing import Any, Callable, Sequence, Union
from typing import Callable, Sequence, Union

import numpy
import scipy
Expand Down
7 changes: 3 additions & 4 deletions src/mopsy/mops.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class Mops:
"""Base class for all matrix operations"""
"""Base class for all matrix operations."""

def __init__(self, mat, non_zero: bool = False) -> None:
"""Intialize the matrix.
Expand Down Expand Up @@ -108,9 +108,8 @@ def multi_apply(
group: list = None,
axis: int = 0,
) -> Tuple[np.ndarray, Optional[Sequence]]:
"""Apply multiple functions, the first axis
of the ndarray specifies the results of the inputs functions in
the same order.
"""Apply multiple functions, the first axis of the ndarray specifies the results of the inputs functions in the
same order.
Args:
func:
Expand Down
4 changes: 2 additions & 2 deletions src/mopsy/nops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class Nops(Mops):
"""Internal representation for numpy arrays"""
"""Internal representation for numpy arrays."""

def __init__(self, mat: np.ndarray, non_zero: bool = False) -> None:
super().__init__(mat, non_zero=non_zero)
Expand All @@ -23,7 +23,7 @@ def iter(
Args:
group:
Group variable. Defaults to None.
axis:
0 for rows, 1 for columns. Defaults to 0.
Expand Down
5 changes: 2 additions & 3 deletions src/mopsy/sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ def multi_apply(
group: list = None,
axis: Union[int, bool] = 0,
) -> Tuple[np.ndarray, Optional[Sequence]]:
"""Apply multiple functions, the first axis
of the ndarray specifies the results of the inputs functions in
the same order.
"""Apply multiple functions, the first axis of the ndarray specifies the results of the inputs functions in the
same order.
Args:
func:
Expand Down
2 changes: 1 addition & 1 deletion src/mopsy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


def get_matrix_type(mat: Union[np.ndarray, sp.spmatrix], non_zero: bool = False):
"""Get an internal matrix state
"""Get an internal matrix state.
Args:
mat:
Expand Down
11 changes: 5 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""
Dummy conftest.py for mopsy.
"""Dummy conftest.py for mopsy.
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
If you don't know what this is for, just leave it empty.
Read more about conftest.py under:
- https://docs.pytest.org/en/stable/fixture.html
- https://docs.pytest.org/en/stable/writing_plugins.html
"""

# import pytest
1 change: 0 additions & 1 deletion tests/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ def test_apply_cols():
def test_multiapply_cols():
rmat = multi_apply([mean], mat, 1, None, False)
assert rmat is not None

3 changes: 1 addition & 2 deletions tests/test_sparse_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def test_sparse_add_row():
mat = eye(5).tocsr()
tmat = sparse_append(mat, np.array([0, 0, 0, 0, 0]), axis=0)

assert tmat is not None
assert tmat.shape[0] == mat.shape[0] + 1
assert type(tmat) == type(mat)
Expand All @@ -23,4 +23,3 @@ def test_sparse_add_col():
assert tmat is not None
assert tmat.shape[1] == mat.shape[1] + 1
assert type(tmat) == type(mat)

0 comments on commit 12dfcd8

Please sign in to comment.