Skip to content

Commit

Permalink
Merge pull request #332 from mulimoen/clippy
Browse files Browse the repository at this point in the history
Fix outer comments
  • Loading branch information
mulimoen authored Aug 13, 2023
2 parents 905b13e + f5c4e9d commit 9c42de2
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 126 deletions.
56 changes: 20 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
components: rustfmt
- name: Check formatting
run: cargo fmt -- --check
Expand All @@ -36,14 +34,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
- name: Documentation
run: cargo doc --all-features --workspace

Expand All @@ -52,14 +48,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
profile: minimal
components: clippy
- name: Run Clippy
run: cargo clippy --workspace --all-features -- -W clippy::doc_markdown -W clippy::needless_borrow -W clippy::checked_conversions -W clippy::unseparated_literal_suffix -W clippy::unreadable_literal -W clippy::if_not_else -W clippy::needless_continue -W clippy::match_same_arms -W clippy::match_wildcard_for_single_variants -W clippy::explicit_into_iter_loop -W clippy::needless_borrow
Expand Down Expand Up @@ -93,7 +87,7 @@ jobs:
rust: stable
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}

- name: Install suitesparse
Expand All @@ -102,11 +96,9 @@ jobs:
sudo apt-get install libsuitesparse-dev
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true

- name: Build (exclude suitesparse)
run: cargo build --verbose --workspace --exclude suitesparse_ldl_sys --exclude sprs_suitesparse_ldl --exclude sprs_suitesparse_camd --exclude suitesparse_camd_sys --exclude suitesparse_umfpack_sys --exclude sprs_suitesparse_umfpack
Expand All @@ -133,17 +125,15 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install dependencies
run: |
sudo apt-get install libeigen3-dev libsuitesparse-dev
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
profile: minimal
- name: Run benchmarks
run: |
cargo bench --workspace
Expand All @@ -153,14 +143,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
profile: minimal
- name: Run test
run: |
cargo test --no-default-features -p sprs
Expand All @@ -170,10 +158,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
Expand Down Expand Up @@ -202,35 +190,31 @@ jobs:
rust: stable
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: true}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
profile: minimal
- name: Run tests (camd)
run: |
cd suitesparse_bindings/sprs_suitesparse_camd
cargo test --features suitesparse_camd_sys/static -p sprs
cargo test -p suitesparse_camd_sys --features static -p sprs
- name: Run tests (ldl)
run: |
cd suitesparse_bindings/sprs_suitesparse_ldl
cargo test --features suitesparse_ldl_sys/static -p sprs
cargo test -p suitesparse_ldl_sys --features static -p sprs
miri:
name: Miri
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with: {submodules: false}
- name: Install rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
override: true
profile: minimal
components: miri
- name: Run test
run: |
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"sprs-benches",
"sprs-tests",
]
resolver = "2"

[workspace.package]
rust-version = "1.64"
Expand Down
107 changes: 54 additions & 53 deletions sprs-ldl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
///! Cholesky factorization module.
///!
///! Contains LDLT decomposition methods.
///!
///! This decomposition operates on symmetric positive definite matrices,
///! and is written `A = L D L` where L is lower triangular and D is diagonal.
///! It is closely related to the Cholesky decomposition, but is often more
///! numerically stable and can work on some indefinite matrices.
///!
///! The easiest way to use this API is to create a `LdlNumeric` instance from
///! a matrix, then use the `LdlNumeric::solve` method.
///!
///! It is possible to update a decomposition if the sparsity structure of a
///! matrix does not change. In that case the `LdlNumeric::update` method can
///! be used.
///!
///! When only the sparsity structure of a matrix is known, it is possible
///! to precompute part of the factorization by using the `LdlSymbolic` struct.
///! This struct can the be converted into a `LdlNumeric` once the non-zero
///! values are known, using the `LdlSymbolic::factor` method.
// This method is adapted from the LDL library by Tim Davis:
//
// LDL Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved.
//
// LDL License:
//
// Your use or distribution of LDL or any modified version of
// LDL implies that you agree to this License.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
//
// Permission is hereby granted to use or copy this program under the
// terms of the GNU LGPL, provided that the Copyright, this License,
// and the Availability of the original version is retained on all copies.
// User documentation of any code that uses this code or any modified
// version of this code must cite the Copyright, this License, the
// Availability note, and "Used by permission." Permission to modify
// the code and to distribute modified code is granted, provided the
// Copyright, this License, and the Availability note are retained,
// and a notice that the code was modified is included.
//! Cholesky factorization module.
//!
//! Contains LDLT decomposition methods.
//!
//! This decomposition operates on symmetric positive definite matrices,
//! and is written `A = L D L` where L is lower triangular and D is diagonal.
//! It is closely related to the Cholesky decomposition, but is often more
//! numerically stable and can work on some indefinite matrices.
//!
//! The easiest way to use this API is to create a `LdlNumeric` instance from
//! a matrix, then use the `LdlNumeric::solve` method.
//!
//! It is possible to update a decomposition if the sparsity structure of a
//! matrix does not change. In that case the `LdlNumeric::update` method can
//! be used.
//!
//! When only the sparsity structure of a matrix is known, it is possible
//! to precompute part of the factorization by using the `LdlSymbolic` struct.
//! This struct can the be converted into a `LdlNumeric` once the non-zero
//! values are known, using the `LdlSymbolic::factor` method.
//!
//! This method is adapted from the LDL library by Tim Davis:
//!
//! LDL Copyright (c) 2005 by Timothy A. Davis. All Rights Reserved.
//!
//! LDL License:
//!
//! Your use or distribution of LDL or any modified version of
//! LDL implies that you agree to this License.
//!
//! This library is free software; you can redistribute it and/or
//! modify it under the terms of the GNU Lesser General Public
//! License as published by the Free Software Foundation; either
//! version 2.1 of the License, or (at your option) any later version.
//!
//! This library is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//! Lesser General Public License for more details.
//!
//! You should have received a copy of the GNU Lesser General Public
//! License along with this library; if not, write to the Free Software
//! Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
//! USA
//!
//! Permission is hereby granted to use or copy this program under the
//! terms of the GNU LGPL, provided that the Copyright, this License,
//! and the Availability of the original version is retained on all copies.
//! User documentation of any code that uses this code or any modified
//! version of this code must cite the Copyright, this License, the
//! Availability note, and "Used by permission." Permission to modify
//! the code and to distribute modified code is granted, provided the
//! Copyright, this License, and the Availability note are retained,
//! and a notice that the code was modified is included.
use std::ops::Deref;

use num_traits::Num;
Expand Down
16 changes: 8 additions & 8 deletions sprs/src/indexing.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! Abstraction over types of indices
//!
//! Our sparse matrices can use any integer type for its indices among
//! `u16, u32, u64, usize, i16, i32, i64, isize`.
//!
//! By default, sprs matrices will use `usize`, but it can be useful to switch
//! to another index type to reduce the memory usage of sparse matrices, of for
//! compatibility purposes when calling into an existing library through FFI.
use std::fmt::Debug;
///! Abstraction over types of indices
///!
///! Our sparse matrices can use any integer type for its indices among
///! `u16, u32, u64, usize, i16, i32, i64, isize`.
///!
///! By default, sprs matrices will use `usize`, but it can be useful to switch
///! to another index type to reduce the memory usage of sparse matrices, of for
///! compatibility purposes when calling into an existing library through FFI.
use std::ops::AddAssign;

use num_traits::int::PrimInt;
Expand Down
2 changes: 1 addition & 1 deletion sprs/src/sparse/compressed.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Traits to generalize over compressed sparse matrices storages
use crate::indexing::SpIndex;
///! Traits to generalize over compressed sparse matrices storages
use crate::sparse::prelude::*;
use std::ops::Deref;

Expand Down
18 changes: 9 additions & 9 deletions sprs/src/sparse/csmat.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
//! A sparse matrix in the Compressed Sparse Row/Column format
//!
//! In the CSR format, a matrix is a structure containing three vectors:
//! indptr, indices, and data
//! These vectors satisfy the relation
//! for i in [0, nrows],
//! A(i, indices[indptr[i]..indptr[i+1]]) = data[indptr[i]..indptr[i+1]]
//! In the CSC format, the relation is
//! A(indices[indptr[i]..indptr[i+1]], i) = data[indptr[i]..indptr[i+1]]
use ndarray::ArrayView;
use num_traits::{Float, Num, Signed, Zero};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::cmp;
///! A sparse matrix in the Compressed Sparse Row/Column format
///
/// In the CSR format, a matrix is a structure containing three vectors:
/// indptr, indices, and data
/// These vectors satisfy the relation
/// for i in [0, nrows],
/// A(i, indices[indptr[i]..indptr[i+1]]) = data[indptr[i]..indptr[i+1]]
/// In the CSC format, the relation is
/// A(indices[indptr[i]..indptr[i+1]], i) = data[indptr[i]..indptr[i+1]]
use std::default::Default;
use std::iter::{Enumerate, Zip};
use std::mem;
Expand Down
9 changes: 5 additions & 4 deletions sprs/src/sparse/linalg.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Sparse linear algebra
//!
//! This module contains solvers for sparse linear systems. Currently
//! there are solver for sparse triangular systems and symmetric systems.

use crate::{DenseVector, DenseVectorMut};
///! Sparse linear algebra
///!
///! This module contains solvers for sparse linear systems. Currently
///! there are solver for sparse triangular systems and symmetric systems.
use num_traits::Num;

pub mod etree;
Expand Down
5 changes: 3 additions & 2 deletions sprs/src/sparse/linalg/etree.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
///! Data structures to work with elimination trees (etree).
///! etrees arise when considering cholesky factorization, QR factorization, ...
//! Data structures to work with elimination trees (etree).
//! etrees arise when considering cholesky factorization, QR factorization, ...

use std::ops::{Deref, DerefMut};

pub type Parent = Option<usize>;
Expand Down
3 changes: 2 additions & 1 deletion sprs/src/sparse/prod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Sparse matrix product

use crate::dense_vector::{DenseVector, DenseVectorMut};
use crate::indexing::SpIndex;
use crate::sparse::compressed::SpMatView;
///! Sparse matrix product
use crate::sparse::prelude::*;
use crate::Ix2;
use ndarray::{ArrayView, ArrayViewMut, Axis};
Expand Down
2 changes: 1 addition & 1 deletion sprs/src/sparse/special_mats.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Common sparse matrices
use ndarray::ArrayView2;
///! Common sparse matrices
use smallvec::SmallVec;

use crate::indexing::SpIndex;
Expand Down
3 changes: 2 additions & 1 deletion sprs/src/sparse/to_dense.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! Utilities for sparse-to-dense conversion

use super::{CsMatViewI, CsVecViewI};
use crate::indexing::SpIndex;
use crate::{Ix1, Ix2};
///! Utilities for sparse-to-dense conversion
use ndarray::{ArrayViewMut, Axis};

/// Assign a sparse matrix into a dense matrix
Expand Down
Loading

0 comments on commit 9c42de2

Please sign in to comment.