Skip to content

Commit

Permalink
add readme and github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jpopesculian committed May 17, 2024
1 parent f64da7a commit 61cdae7
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 12 deletions.
17 changes: 6 additions & 11 deletions .github/workflows/CI.yml → .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# This file is autogenerated by maturin v1.4.0
# To update, run
#
# maturin generate-ci github
#
name: CI
name: Release

on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
merge_group:
workflow_dispatch:

permissions:
Expand All @@ -23,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le]
target: [x86_64, x86] # aarch64, armv7, s390x, ppc64le
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -33,7 +28,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
args: --release --out dist
sccache: 'true'
manylinux: auto
- name: Upload wheels
Expand All @@ -57,7 +52,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand All @@ -79,7 +74,7 @@ jobs:
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
pull_request:
merge_group:
push:
branches:
- main

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all --check
- run: cargo clippy --all-features -- -D warnings
- run: cargo test --all-features
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@
name = "xyz-parse"
version = "0.1.0"
edition = "2021"
authors = ["Julian Popescu <[email protected]>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
homepage = "https://github.com/aqora-io/xyz-parse"
documentation = "https://docs.rs/xyz-parse/"
repository = "https://github.com/aqora-io/xyz-parse"
description = "Simple parser for the XYZ file format"
keywords = ["xyz", "chemistry", "parser", "parse"]
categories = ["parsing"]

[lib]
path = "src/lib.rs"
name = "xyz_parse"
crate-type = ["cdylib"]

[features]
default = ["python"]
default = []
python = ["pyo3"]

[dependencies]
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# xyz-parse

A parser for the [XYZ file format](https://en.wikipedia.org/wiki/XYZ_file_format)

The formatting of the .xyz file format is as follows:

```rust
<number of atoms>
comment line
<element> <X> <Y> <Z>
...
```

Currently the parser does not support extended XYZ format, but may do so in the future
2 changes: 2 additions & 0 deletions src/atom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use rust_decimal::Decimal;
use std::{borrow::Cow, error::Error, fmt, str::FromStr};

/// An error that can occur when parsing an [`Atom`]
#[derive(Debug, Clone)]
pub enum AtomParseError<'a> {
InvalidCoordinate(Cow<'a, str>, rust_decimal::Error),
Expand Down Expand Up @@ -36,6 +37,7 @@ impl<'a> fmt::Display for AtomParseError<'a> {

impl Error for AtomParseError<'static> {}

/// An atom in a molecule
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Atom<'a> {
pub symbol: Cow<'a, str>,
Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
//! A parser for the [XYZ file format](https://en.wikipedia.org/wiki/XYZ_file_format)
//!
//! The formatting of the .xyz file format is as follows:
//!
//! ```
//! <number of atoms>
//! comment line
//! <element> <X> <Y> <Z>
//! ...
//! ```
//!
//! Currently the parser does not support extended XYZ format, but may do so in the future
mod atom;
mod molecule;
mod xyz;
Expand All @@ -9,6 +22,7 @@ pub use atom::*;
pub use molecule::*;
pub use xyz::*;

/// Parse an [`Xyz`] string
pub fn parse_xyz(s: &str) -> Result<Xyz, XyzParseError> {
Xyz::parse(s)
}
2 changes: 2 additions & 0 deletions src/molecule.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::atom::{Atom, AtomParseError};
use std::{borrow::Cow, error::Error, fmt, str::FromStr};

/// An error that can occur when parsing a [`Molecule`]
#[derive(Debug, Clone)]
pub enum MoleculeParseError<'a> {
NoAtomNumber,
Expand Down Expand Up @@ -57,6 +58,7 @@ impl Error for MoleculeParseError<'static> {
}
}

/// A molecule
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Molecule<'a> {
pub comment: Cow<'a, str>,
Expand Down
3 changes: 3 additions & 0 deletions src/xyz.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::molecule::{Molecule, MoleculeParseError};
use std::{error::Error, fmt, str::FromStr};

/// An error that can occur while parsing an [`Xyz`]
#[derive(Debug, Clone)]
pub enum XyzParseError<'a> {
InvalidMolecule(usize, MoleculeParseError<'a>),
Expand Down Expand Up @@ -32,6 +33,7 @@ impl Error for XyzParseError<'static> {
}
}

/// A list of molecules
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Xyz<'a> {
pub molecules: Vec<Molecule<'a>>,
Expand Down Expand Up @@ -88,6 +90,7 @@ mod tests {
use super::*;
use crate::{atom::Atom, molecule::Molecule};
use rust_decimal::Decimal;
use std::borrow::Cow;

const PYRIDINE: &str = r#"11
Expand Down

0 comments on commit 61cdae7

Please sign in to comment.