Skip to content

Commit

Permalink
Migrate commandline interface to clap (#49)
Browse files Browse the repository at this point in the history
* Migrate commandline interface to clap

* Use an older approach

* Fix happy accidents

* Make docs compatible with 0.6

* Re-format that code
  • Loading branch information
odarbelaeze authored Aug 26, 2024
1 parent ea5ea17 commit b7b20db
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 150 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vegas-lattice"
version = "0.5.2"
version = "0.6.0"
authors = ["Oscar David Arbeláez Echeverri <[email protected]>"]
description = "CLI and library to work with lattices"
documentation = "https://docs.rs/vegas-lattice"
Expand All @@ -20,6 +20,6 @@ maintenance = { status = "actively-developed" }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
docopt = "1.1"
image = "0.24"
rand = "0.8"
clap = { version = "4.5.16", features = ["cargo"] }
26 changes: 11 additions & 15 deletions docs/bcc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"size": [
1.0,
1.0,
1.0
],
"size": [1.0, 1.0, 1.0],
"sites": [
{"kind": "A", "position": [0.0, 0.0, 0.0], "tags": null},
{"kind": "B", "position": [0.0, 0.0, 0.0], "tags": null}
{ "kind": "A", "position": [0.0, 0.0, 0.0], "tags": null },
{ "kind": "B", "position": [0.5, 0.5, 0.5], "tags": null }
],
"vertices": [
{"source": 0, "target": 1, "delta": [0, 0, 0], "tags": null},
{"source": 0, "target": 1, "delta": [0, -1, 0], "tags": null},
{"source": 0, "target": 1, "delta": [-1, 0, 0], "tags": null},
{"source": 0, "target": 1, "delta": [-1, -1, 0], "tags": null},
{"source": 0, "target": 1, "delta": [0, 0, -1], "tags": null},
{"source": 0, "target": 1, "delta": [0, -1, -1], "tags": null},
{"source": 0, "target": 1, "delta": [-1, 0, -1], "tags": null},
{"source": 0, "target": 1, "delta": [-1, -1, -1], "tags": null}
{ "source": 0, "target": 1, "delta": [0, 0, 0], "tags": null },
{ "source": 0, "target": 1, "delta": [0, -1, 0], "tags": null },
{ "source": 0, "target": 1, "delta": [-1, 0, 0], "tags": null },
{ "source": 0, "target": 1, "delta": [-1, -1, 0], "tags": null },
{ "source": 0, "target": 1, "delta": [0, 0, -1], "tags": null },
{ "source": 0, "target": 1, "delta": [0, -1, -1], "tags": null },
{ "source": 0, "target": 1, "delta": [-1, 0, -1], "tags": null },
{ "source": 0, "target": 1, "delta": [-1, -1, -1], "tags": null }
]
}
16 changes: 7 additions & 9 deletions docs/input.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"size": [1, 1, 1],
"sites": [
{"kind": "Fe", "position": [0, 0, 0]}
],
"vertices": [
{"source": 0, "target": 0, "delta": [1, 0, 0]},
{"source": 0, "target": 0, "delta": [0, 1, 0]},
{"source": 0, "target": 0, "delta": [0, 0, 1]}
]
"size": [1, 1, 1],
"sites": [{ "kind": "Fe", "position": [0, 0, 0] }],
"vertices": [
{ "source": 0, "target": 0, "delta": [1, 0, 0] },
{ "source": 0, "target": 0, "delta": [0, 1, 0] },
{ "source": 0, "target": 0, "delta": [0, 0, 1] }
]
}
5 changes: 5 additions & 0 deletions src/alloy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ impl Alloy {
}
}

pub fn from_targets(targets: Vec<(&str, u32)>) -> Self {
let (kinds, ratios): (Vec<_>, Vec<_>) = targets.into_iter().unzip();
Self::new(kinds, ratios)
}

/// Picks a kind of atom from the alloy
pub fn pick<R: Rng + ?Sized>(&self, rng: &mut R) -> String {
self.kinds[self.weights.sample(rng)].clone()
Expand Down
Loading

0 comments on commit b7b20db

Please sign in to comment.