Skip to content

Commit

Permalink
random refined
Browse files Browse the repository at this point in the history
  • Loading branch information
mhfan committed Feb 7, 2025
1 parent 54e90b7 commit 2f0642c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
- name: Build Project with Dioxus and TailwindCSS
run: |
cargo binstall dioxus-cli
cargo t --no-default-features #cargo nextest r
#cargo r --bin syncd -F syncdep --no-default-features
npm install tailwindcss @tailwindcss/cli #-D -g
npx tailwindcss -i input.css -o assets/tailwind.css -m
dx build -r --platform web #--verbose --trace
#cargo r --bin syncd -F syncdep
cargo t #cargo nextest r
#- name: Setup GitHub Pages
# uses: actions/configure-pages@v4
Expand Down
19 changes: 12 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ pub const UNICODE_SUPERS: [char; 16] = [ //&str = r"⁰¹²³⁴⁵⁶⁷⁸⁹

#[derive(PartialEq, Debug)] pub enum AtomicWeight {
//Interval(core::ops::RangeInclusive<f64>), // conversional?
//Uncert { value: f64, uncert: f64 }, // uncertainty
//Measure { value: f64, uncert: f64 }, // uncertainty
Abridged { value: f32, uncert: f32 },
MassNumber(u32),
}
Expand Down Expand Up @@ -508,17 +508,22 @@ impl std::str::FromStr for AtomicWeight {
}
}

impl From<u32> for AtomicWeight { fn from(n: u32) -> Self { Self::MassNumber(n) } }
impl From<(f32, f32)> for AtomicWeight {
fn from((value, uncert): (f32, f32)) -> Self { Self::Abridged { value, uncert } }
}

use core::fmt;
impl fmt::Display for AtomicWeight {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AtomicWeight::MassNumber(num) => if 0 < *num {
write!(f, "[{num}]") } else { write!(f, "[???]") },
match *self {
AtomicWeight::MassNumber(num) =>
if 0 < num { write!(f, "[{num}]") } else { write!(f, "[???]") },
AtomicWeight::Abridged { value, uncert } => {
if *uncert == 0. { return write!(f, "{value}") }
//return write!(f, "{value} ± {uncert}")?;
if uncert == 0. { return write!(f, "{value}") }
if f.alternate() { return write!(f, "{value} ± {uncert}") }

if *uncert < 1. {
if uncert < 1. {
let mut prec = (-uncert.log10()).ceil() as i32;
let mut digit = uncert * 10f32.powi(prec);
while f32::EPSILON * 10. < digit.fract() &&
Expand Down
2 changes: 1 addition & 1 deletion src/ostates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ impl ChemElem { // Auto-generated by syncd.rs, DO NOT EDIT.
H => &[ -1, 1, ],
He => &[ 0, ],
Li => &[ -1, 1, ],
Be => &[ 0, 1, 2, ],
Be => &[ 1, 2, ],
B => &[-5, -1, 0, 1, 2, 3, ],
C => &[ -4,-3,-2,-1, 0, 1, 2, 3, 4, ],
N => &[ -3,-2,-1, 0, 1, 2, 3, 4, 5, ],
Expand Down

0 comments on commit 2f0642c

Please sign in to comment.