From 966e1b627c8c34e047b15945bc2ff070c7e73c4e Mon Sep 17 00:00:00 2001 From: Junzhuo ZHOU Date: Wed, 5 Feb 2025 01:06:04 -0800 Subject: [PATCH] Update dependency (#15) * use lexical to parse integer * bump version to 0.9.2 * update dependencies --- Cargo.toml | 6 +-- src/ccsn.rs | 5 +-- src/library/test.rs | 96 +++++++++++++++++++++------------------------ 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f90652..c00b323 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,6 @@ __test_runtime_assert = [] log = { version = "0.4", features = ["std", "serde"] } simple_logger = "5.0" serde = { version = "1.0", features = ["derive"] } -bson = "2.13" serde_json = "1.0" thiserror = "2.0" strum = "0.26" @@ -85,6 +84,7 @@ hashmatch = "0.1.1" pyo3 = "0.23.4" pyo3-stub-gen = "0.7" # pyo3-stub-gen = { path = "../pyo3-stub-gen/pyo3-stub-gen" } +bincode = "1.3.3" [dependencies] liberty-macros = { path = "macros" } @@ -103,14 +103,14 @@ nom.workspace = true biodivine-lib-bdd.workspace = true mut_set.workspace = true duplicate.workspace = true -num-traits.workspace = true cfg-if.workspace = true hashmatch.workspace = true pyo3 = { workspace = true, optional = true } pyo3-stub-gen = { workspace = true, optional = true } + [dev-dependencies] dev_utils.workspace = true simple_logger.workspace = true criterion.workspace = true -bson.workspace = true +bincode.workspace = true \ No newline at end of file diff --git a/src/ccsn.rs b/src/ccsn.rs index e851573..a047ba9 100644 --- a/src/ccsn.rs +++ b/src/ccsn.rs @@ -15,7 +15,6 @@ use crate::{ Ctx, }; use core::fmt::{self, Write}; -use num_traits::Zero as _; /// Use the `ccsn_first_stage` group to specify CCS noise for the first stage of the channel- /// connected block (CCB). @@ -234,13 +233,13 @@ impl GroupFn for CCSNStage { fn before_build(builder: &mut Self::Builder, _scope: &mut BuilderScope) { if let Some(miller_cap_fall) = builder.miller_cap_fall.as_mut() { if miller_cap_fall.is_sign_negative() { - miller_cap_fall.set_zero(); + *miller_cap_fall = 0.0; log::warn!("miller_cap_fall is negative!"); } } if let Some(miller_cap_rise) = builder.miller_cap_rise.as_mut() { if miller_cap_rise.is_sign_negative() { - miller_cap_rise.set_zero(); + *miller_cap_rise = 0.0; log::warn!("miller_cap_rise is negative!"); } } diff --git a/src/library/test.rs b/src/library/test.rs index ca2c7e2..8bf6a73 100644 --- a/src/library/test.rs +++ b/src/library/test.rs @@ -1,6 +1,4 @@ #![cfg(test)] -use num_traits::One; - use crate::{ ast::{AttriValues, SimpleDefined}, DefaultCtx, @@ -177,7 +175,6 @@ library (undefined) { #[test] fn entry() { - use num_traits::Zero; let mut library = Library::default(); library.comments_this_entry().or_insert("comment1".into()); library @@ -222,51 +219,48 @@ library (undefined) { ); } -// #[test] -// fn serde() { -// use num_traits::Zero; -// let mut library = Library::default(); -// library.comments_this_entry().or_insert("comment1".into()); -// library -// .cell -// .entry("CELL1".into()) -// .and_modify(|cell| cell.area = Some(NotNan::one())) -// .or_insert_with(|cell| cell.area = Some(NotNan::zero())); -// library -// .cell -// .entry("CELL2".into()) -// .and_modify(|cell| cell.area = Some(NotNan::one())) -// .or_insert_with(|cell| cell.area = Some(NotNan::zero())); -// library -// .cell -// .entry("CELL2".into()) -// .and_modify(|cell| cell.area = Some(NotNan::one())) -// .or_insert_with(|cell| cell.area = Some(NotNan::zero())); -// let want = r#"/* comment1 */ -// library (undefined) { -// | technology (cmos); -// | delay_model : table_lookup; -// | time_unit : 1ns; -// | voltage_unit : 1V; -// | slew_upper_threshold_pct_rise : 80.0; -// | slew_lower_threshold_pct_rise : 20.0; -// | slew_derate_from_library : 1.0; -// | slew_lower_threshold_pct_fall : 20.0; -// | slew_upper_threshold_pct_fall : 80.0; -// | input_threshold_pct_fall : 50.0; -// | input_threshold_pct_rise : 50.0; -// | output_threshold_pct_rise : 50.0; -// | output_threshold_pct_fall : 50.0; -// | cell (CELL1) { -// | | area : 0.0; -// | } -// | cell (CELL2) { -// | | area : 1.0; -// | } -// } -// "#; -// fmt_cmp(&library, want); -// let serialized = bson::bson!(library).unwrap(); -// println!("serialized = {}", serialized); -// fmt_cmp(&bson::from_bson(&serialized).unwrap(), want); -// } +#[test] +fn serde() { + let mut library = Library::default(); + library.comments_this_entry().or_insert("comment1".into()); + library + .cell + .entry("CELL1".into()) + .and_modify(|cell| cell.area = Some(1.0)) + .or_insert_with(|cell| cell.area = Some(0.0)); + library + .cell + .entry("CELL2".into()) + .and_modify(|cell| cell.area = Some(1.0)) + .or_insert_with(|cell| cell.area = Some(0.0)); + library + .cell + .entry("CELL2".into()) + .and_modify(|cell| cell.area = Some(1.0)) + .or_insert_with(|cell| cell.area = Some(0.0)); + let want = r#"/* comment1 */ +library (undefined) { +| delay_model : table_lookup; +| time_unit : 1ns; +| voltage_unit : 1V; +| slew_upper_threshold_pct_rise : 80.0; +| slew_lower_threshold_pct_rise : 20.0; +| slew_derate_from_library : 1.0; +| slew_lower_threshold_pct_fall : 20.0; +| slew_upper_threshold_pct_fall : 80.0; +| input_threshold_pct_fall : 50.0; +| input_threshold_pct_rise : 50.0; +| output_threshold_pct_rise : 50.0; +| output_threshold_pct_fall : 50.0; +| cell (CELL1) { +| | area : 0.0; +| } +| cell (CELL2) { +| | area : 1.0; +| } +} +"#; + fmt_cmp(&library, want); + let serialized = bincode::serialize(&library).unwrap(); + fmt_cmp(&bincode::deserialize(&serialized).unwrap(), want); +}