<commit_before>// Cymbalum, an extensible molecular simulation engine
// Copyright (C) 2015-2016 <NAME> — BSD license

//! Data about bonds and angles in the system.
use std::cmp::{min, max};
use std::collections::HashSet;
use std::iter::IntoIterator;
use std::ops::Range;
use std::hash::{Hash, SipHasher, Hasher};

use types::Array2;
use system::Particle;

/// A `Bond` between the atoms at indexes `i` and `j`
///
/// This structure ensure unicity of a `Bond` representation by enforcing
/// `i < j`
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Bond {
    i: usize,
    j: usize,
}

impl Bond {
    /// Create a new Bond between the atoms at indexes `first` and `second`
    pub fn new(first: usize, second: usize) -> Bond {
        assert!(first != second);
        let i = min(first, second);
        let j = max(first, second);
        Bond{i: i, j: j}
    }

    /// Get the first particle in the bond
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the bond
    #[inline] pub fn j(&self) -> usize {self.j}
}

/// An `Angle` formed by the atoms at indexes `i`, `j` and `k`
///
/// This structure ensure unicity of the `Angle` representation by enforcing
/// `i < k`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Angle {
    i: usize,
    j: usize,
    k: usize,
}

impl Angle {
    /// Create a new Angle between the atoms at indexes `first`, `second` and `third`
    pub fn new(first: usize, second: usize, third: usize) -> Angle {
        assert!(first != second);
        assert!(first != third);
        assert!(second != third);
        let i = min(first, third);
        let k = max(first, third);
        Angle{i: i, j: second, k: k}
    }

    /// Get the first particle in the angle
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the angle
    #[inline] pub fn j(&self) -> usize {self.j}

    /// Get the third particle in the angle
    #[inline] pub fn k(&self) -> usize {self.k}
}


/// A `Dihedral` angle formed by the atoms at indexes `i`, `j`, `k` and `m`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Dihedral {
    i: usize,
    j: usize,
    k: usize,
    m: usize,
}

impl Dihedral {
    /// Create a new Dihedral between the atoms at indexes `first`, `second`, `third` and `fourth`
    pub fn new(first: usize, second: usize, third: usize, fourth: usize) -> Dihedral {
        assert!(first != second);
        assert!(second != third);
        assert!(third != fourth);
        let (i, j, k, m) = if max(first, second) < max(third, fourth) {
            (first, second, third, fourth)
        } else {
            (fourth, third, second, first)
        };
        Dihedral{i: i, j: j, k: k, m: m}
    }

    /// Get the first particle in the dihedral angle
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the dihedral angle
    #[inline] pub fn j(&self) -> usize {self.j}

    /// Get the third particle in the dihedral angle
    #[inline] pub fn k(&self) -> usize {self.k}

    /// Get the fourth particle in the dihedral angle
    #[inline] pub fn m(&self) -> usize {self.m}
}

/******************************************************************************/
mod connect {
    #![allow(dead_code)]
    #![cfg_attr(feature="lint", allow(if_not_else))]
    bitflags! {
        /// The `Connectivity` bitflag encode the topological distance between
        /// two particles in the molecule, i.e. the number of bonds between the
        /// particles.
        flags Connectivity: u16 {
            /// The particles are separated by one bond
            const CONNECT_12   = 0b0001,
            /// The particles are separated by two bonds
            const CONNECT_13   = 0b0010,
            /// The particles are separated by three bonds
            const CONNECT_14   = 0b0100,
            /// The particles are separated by more than three bonds
            const CONNECT_FAR  = 0b1000,
        }
    }

    impl Default for Connectivity {
        fn default() -> Connectivity {<commit_msg>Use u8 instead of u16 for bitflags<commit_after>// Cymbalum, an extensible molecular simulation engine
// Copyright (C) 2015-2016 <NAME> — BSD license

//! Data about bonds and angles in the system.
use std::cmp::{min, max};
use std::collections::HashSet;
use std::iter::IntoIterator;
use std::ops::Range;
use std::hash::{Hash, SipHasher, Hasher};

use types::Array2;
use system::Particle;

/// A `Bond` between the atoms at indexes `i` and `j`
///
/// This structure ensure unicity of a `Bond` representation by enforcing
/// `i < j`
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Bond {
    i: usize,
    j: usize,
}

impl Bond {
    /// Create a new Bond between the atoms at indexes `first` and `second`
    pub fn new(first: usize, second: usize) -> Bond {
        assert!(first != second);
        let i = min(first, second);
        let j = max(first, second);
        Bond{i: i, j: j}
    }

    /// Get the first particle in the bond
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the bond
    #[inline] pub fn j(&self) -> usize {self.j}
}

/// An `Angle` formed by the atoms at indexes `i`, `j` and `k`
///
/// This structure ensure unicity of the `Angle` representation by enforcing
/// `i < k`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Angle {
    i: usize,
    j: usize,
    k: usize,
}

impl Angle {
    /// Create a new Angle between the atoms at indexes `first`, `second` and `third`
    pub fn new(first: usize, second: usize, third: usize) -> Angle {
        assert!(first != second);
        assert!(first != third);
        assert!(second != third);
        let i = min(first, third);
        let k = max(first, third);
        Angle{i: i, j: second, k: k}
    }

    /// Get the first particle in the angle
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the angle
    #[inline] pub fn j(&self) -> usize {self.j}

    /// Get the third particle in the angle
    #[inline] pub fn k(&self) -> usize {self.k}
}


/// A `Dihedral` angle formed by the atoms at indexes `i`, `j`, `k` and `m`
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Dihedral {
    i: usize,
    j: usize,
    k: usize,
    m: usize,
}

impl Dihedral {
    /// Create a new Dihedral between the atoms at indexes `first`, `second`, `third` and `fourth`
    pub fn new(first: usize, second: usize, third: usize, fourth: usize) -> Dihedral {
        assert!(first != second);
        assert!(second != third);
        assert!(third != fourth);
        let (i, j, k, m) = if max(first, second) < max(third, fourth) {
            (first, second, third, fourth)
        } else {
            (fourth, third, second, first)
        };
        Dihedral{i: i, j: j, k: k, m: m}
    }

    /// Get the first particle in the dihedral angle
    #[inline] pub fn i(&self) -> usize {self.i}

    /// Get the second particle in the dihedral angle
    #[inline] pub fn j(&self) -> usize {self.j}

    /// Get the third particle in the dihedral angle
    #[inline] pub fn k(&self) -> usize {self.k}

    /// Get the fourth particle in the dihedral angle
    #[inline] pub fn m(&self) -> usize {self.m}
}

/******************************************************************************/
mod connect {
    #![allow(dead_code)]
    #![cfg_attr(feature="lint", allow(if_not_else))]
    bitflags! {
        /// The `Connectivity` bitflag encode the topological distance between
        /// two particles in the molecule, i.e. the number of bonds between the
        /// particles.
        flags Connectivity: u8 {
            /// The particles are separated by one bond
            const CONNECT_12   = 0b0001,
            /// The particles are separated by two bonds
            const CONNECT_13   = 0b0010,
            /// The particles are separated by three bonds
            const CONNECT_14   = 0b0100,
            /// The particles are separated by more than three bonds
            const CONNECT_FAR  = 0b1000,
        }
    }

    impl Default for Connectivity {
        fn default() -> Connectivity {
{'fraction_non_alphanumeric': 0.1530214424951267, 'fraction_numerical': 0.009259259259259259, 'mean_word_length': 2.4390448261416005, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5289826', 'n_tokens_mistral': 2558, 'n_tokens_neox': 2531, 'n_words': 976}