diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 60260b44..affcdb3c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/Quantco/pre-commit-mirrors-black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black-conda additional_dependencies: [flake8-docstrings, flake8-rst-docstrings] @@ -8,21 +8,21 @@ repos: - --safe - --target-version=py36 - repo: https://github.com/Quantco/pre-commit-mirrors-flake8 - rev: v3.7.9 + rev: v3.8.4 hooks: - id: flake8-conda - repo: https://github.com/Quantco/pre-commit-mirrors-isort - rev: 4.3.21 + rev: 5.7.0 hooks: - id: isort-conda additional_dependencies: [toml] - repo: https://github.com/Quantco/pre-commit-mirrors-mypy - rev: "0.770" + rev: "0.812" hooks: - id: mypy-conda additional_dependencies: - python=3.8 - repo: https://github.com/Quantco/pre-commit-mirrors-pyupgrade - rev: 1.26.0 + rev: 2.10.0 hooks: - id: pyupgrade-conda diff --git a/src/quantcore/matrix/benchmark/main.py b/src/quantcore/matrix/benchmark/main.py index b69e6b52..349f5005 100644 --- a/src/quantcore/matrix/benchmark/main.py +++ b/src/quantcore/matrix/benchmark/main.py @@ -98,7 +98,8 @@ def _to_standardized_mat(mat): times = pd.DataFrame( index=pd.MultiIndex.from_product( - [ops_to_run, matrices.keys()], names=["operation", "storage"], + [ops_to_run, matrices.keys()], + names=["operation", "storage"], ), columns=["memory", "time"], ).reset_index() diff --git a/src/quantcore/matrix/categorical_matrix.py b/src/quantcore/matrix/categorical_matrix.py index a3fb8925..266ef960 100644 --- a/src/quantcore/matrix/categorical_matrix.py +++ b/src/quantcore/matrix/categorical_matrix.py @@ -58,7 +58,9 @@ def recover_orig(self) -> np.ndarray: return self.cat.categories[self.cat.codes] def _matvec_setup( - self, other: Union[List, np.ndarray], cols: np.ndarray = None, + self, + other: Union[List, np.ndarray], + cols: np.ndarray = None, ) -> Tuple[np.ndarray, Optional[np.ndarray]]: other = np.asarray(other) if other.ndim > 1: diff --git a/src/quantcore/matrix/dense_matrix.py b/src/quantcore/matrix/dense_matrix.py index 223f859d..bb48edd7 100644 --- a/src/quantcore/matrix/dense_matrix.py +++ b/src/quantcore/matrix/dense_matrix.py @@ -59,8 +59,8 @@ def cross_sandwich( L_cols: Optional[np.ndarray] = None, R_cols: Optional[np.ndarray] = None, ): - from .sparse_matrix import SparseMatrix from .categorical_matrix import CategoricalMatrix + from .sparse_matrix import SparseMatrix if isinstance(other, SparseMatrix) or isinstance(other, CategoricalMatrix): return other.cross_sandwich(self, d, rows, R_cols, L_cols).T diff --git a/tests/test_matrices.py b/tests/test_matrices.py index dffcc8c5..9a78add3 100644 --- a/tests/test_matrices.py +++ b/tests/test_matrices.py @@ -198,7 +198,8 @@ def test_to_array_standardized_mat(mat: mx.StandardizedMatrix): @pytest.mark.parametrize("mat", get_matrices()) @pytest.mark.parametrize( - "other_type", [lambda x: x, np.asarray, mx.DenseMatrix], + "other_type", + [lambda x: x, np.asarray, mx.DenseMatrix], ) @pytest.mark.parametrize("cols", [None, [], [1], np.array([1])]) @pytest.mark.parametrize("other_shape", [[], [1], [2]]) @@ -266,7 +267,8 @@ def process_mat_vec_subsets(mat, vec, mat_rows, mat_cols, vec_idxs): @pytest.mark.parametrize("mat", get_matrices()) @pytest.mark.parametrize( - "other_type", [lambda x: x, np.array, mx.DenseMatrix], + "other_type", + [lambda x: x, np.array, mx.DenseMatrix], ) @pytest.mark.parametrize("rows", [None, [], [2], np.arange(2)]) @pytest.mark.parametrize("cols", [None, [], [1], np.arange(1)]) @@ -335,7 +337,8 @@ def test_cross_sandwich( @pytest.mark.parametrize("mat", get_matrices()) @pytest.mark.parametrize( - "vec_type", [lambda x: x, np.array, mx.DenseMatrix], + "vec_type", + [lambda x: x, np.array, mx.DenseMatrix], ) @pytest.mark.parametrize("rows", [None, [], [1], np.arange(2)]) @pytest.mark.parametrize("cols", [None, [], [0], np.arange(1)]) @@ -391,7 +394,8 @@ def test_transpose(mat): @pytest.mark.parametrize("mat", get_matrices()) @pytest.mark.parametrize( - "vec_type", [lambda x: x, np.array, mx.DenseMatrix], + "vec_type", + [lambda x: x, np.array, mx.DenseMatrix], ) def test_rmatmul(mat: Union[mx.MatrixBase, mx.StandardizedMatrix], vec_type): vec_as_list = [3.0, -0.1, 0] diff --git a/tests/test_split_matrix.py b/tests/test_split_matrix.py index e4a1f4bf..5caeb62a 100644 --- a/tests/test_split_matrix.py +++ b/tests/test_split_matrix.py @@ -125,7 +125,8 @@ def test_sandwich_sparse_dense(X: np.ndarray, Acols, Bcols): # TODO: ensure cols are in order @pytest.mark.parametrize("mat", [split_mat(), split_with_cat(), split_with_cat_64()]) @pytest.mark.parametrize( - "cols", [None, [0], [1, 2, 3], [1, 5]], + "cols", + [None, [0], [1, 2, 3], [1, 5]], ) def test_sandwich(mat: mx.SplitMatrix, cols): for i in range(10):