diff --git a/.zed/tasks.json b/.zed/tasks.json index 427ba70..4631d31 100644 --- a/.zed/tasks.json +++ b/.zed/tasks.json @@ -1,7 +1,7 @@ [ { "label": "Run Rust tests", - "command": "cargo test -p gammalooprs $env.ZED_SYMBOL --no-default-features --lib -- --nocapture", + "command": "cargo test -p gammalooprs $env.ZED_SYMBOL --no-default-features --lib -- --nocapture --exact", "tags": ["rust-test"] }, { diff --git a/python/gammaloop/interface/gammaloop_interface.py b/python/gammaloop/interface/gammaloop_interface.py index 69269d1..96b9255 100644 --- a/python/gammaloop/interface/gammaloop_interface.py +++ b/python/gammaloop/interface/gammaloop_interface.py @@ -291,11 +291,9 @@ def _update_config_chunk(self, root_path: str, config_chunk: dict[str, Any], upd try: value = eval(value) except: - raise GammaLoopError(f"Invalid value for setting { - setting_path}. It is a string that needs to evaluate to a python dictionary:\n{pformat(updater)}") + raise GammaLoopError(f"Invalid value for setting {setting_path}. It is a string that needs to evaluate to a python dictionary:\n{pformat(updater)}") if not isinstance(value, dict): - raise GammaLoopError(f"Invalid value for setting { - setting_path}. It is a string that needs to evaluate to a python dictionary:\n{pformat(updater)}") + raise GammaLoopError(f"Invalid value for setting {setting_path}. It is a string that needs to evaluate to a python dictionary:\n{pformat(updater)}") else: raise GammaLoopError( f"Invalid value for setting {setting_path}. Default value of type '{type(config_chunk[key]).__name__}' is:\n{pformat(config_chunk[key])}\nand you supplied this value of type '{type(value).__name__}':\n{pformat(value)}") diff --git a/src/api/python.rs b/src/api/python.rs index aa5b247..4f6d4e5 100644 --- a/src/api/python.rs +++ b/src/api/python.rs @@ -8,7 +8,7 @@ use crate::{ SerializableIntegrationState, }, model::Model, - numerator::{AppliedFeynmanRule, PythonState, UnInit}, + numerator::{Numerator, PythonState}, utils::F, ExportSettings, HasIntegrand, Settings, }; @@ -242,15 +242,14 @@ impl PythonWorker { .map_err(|e| exceptions::PyException::new_err(e.to_string())) .unwrap(); self.amplitudes.map_mut_graphs(|g| { - g.statefull_apply::<_, UnInit, AppliedFeynmanRule>(|d, b| { - d.map_numerator(|n| { - n.from_graph( - b, - export_settings.numerator_settings.global_prefactor.as_ref(), - ) - }) - }) - .expect("could not apply Feynman rules") + let a = Numerator::default() + .from_graph( + &g.bare_graph, + export_settings.numerator_settings.global_prefactor.as_ref(), + ) + .forget_type(); + + g.derived_data.as_mut().unwrap().numerator = a; }); } @@ -351,11 +350,12 @@ impl PythonWorker { format: &str, export_yaml_str: &str, ) -> PyResult { - self.apply_feynman_rules(export_yaml_str); - + let export_settings: ExportSettings = serde_yaml::from_str(export_yaml_str) + .map_err(|e| exceptions::PyException::new_err(e.to_string())) + .unwrap(); for amplitude in self.amplitudes.container.iter_mut() { amplitude - .export_expressions(export_root, Self::printer_options(format)) + .export_expressions(export_root, Self::printer_options(format), &export_settings) .map_err(|e| exceptions::PyException::new_err(e.to_string()))?; } Ok("Exported expressions".to_string()) diff --git a/src/cross_section.rs b/src/cross_section.rs index 2ce0978..acc0e93 100644 --- a/src/cross_section.rs +++ b/src/cross_section.rs @@ -3,7 +3,7 @@ use crate::graph::{BareGraph, Graph, SerializableGraph}; use crate::model::{Model, Particle}; use crate::momentum::Signature; use crate::numerator::{ - AppliedFeynmanRule, ContractionSettings, Evaluators, GetSingleAtom, NumeratorState, + AppliedFeynmanRule, ContractionSettings, Evaluators, GetSingleAtom, Numerator, NumeratorState, PythonState, TypedNumeratorState, UnInit, }; use crate::{utils::*, ExportSettings, Externals, Polarizations, Settings}; @@ -918,6 +918,7 @@ impl Amplitude { &self, export_root: &str, printer_ops: PrintOptions, + export_settings: &ExportSettings, ) -> Result<(), Report> { let path = Path::new(export_root) .join("sources") @@ -925,13 +926,13 @@ impl Amplitude { .join(self.name.as_str()) .join("expressions"); for amplitude_graph in self.amplitude_graphs.iter() { - let num = &litude_graph - .graph - .derived_data - .as_ref() - .unwrap() - .numerator + let num = Numerator::default() + .from_graph( + &litude_graph.graph.bare_graph, + export_settings.numerator_settings.global_prefactor.as_ref(), + ) .get_single_atom(); + let dens: Vec<(String, String)> = amplitude_graph .graph .bare_graph diff --git a/src/graph.rs b/src/graph.rs index b1e9e6a..8084baa 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -573,20 +573,17 @@ impl Edge { match self.edge_type { EdgeType::Incoming => { let [lorentz, spin, color] = in_slots.dual().kroneker(&out_slots); - println!("Incoming color: {}", color); + [lorentz * spin, color] } EdgeType::Outgoing => { let [lorentz, spin, color] = out_slots.dual().kroneker(&in_slots); - // println!("Outgoing color: {}", color); - println!("Outgoing color: {}", color); + [lorentz * spin, color] } EdgeType::Virtual => { let mut atom = self.propagator.numerator.clone(); - println!("in prop:{atom}"); - let pfun = Pattern::parse("P(x_)").unwrap(); if self.particle.is_antiparticle() { atom = pfun.replace_all( @@ -667,9 +664,6 @@ impl Edge { color_atom.replace_all_multiple(&reps), ]; - println!("out prop:{}", out[0]); - println!("out color:{}", out[1]); - out } } diff --git a/src/numerator.rs b/src/numerator.rs index ee250a3..d726fc8 100644 --- a/src/numerator.rs +++ b/src/numerator.rs @@ -1413,12 +1413,12 @@ impl GammaSimplified { while let Some(a) = it.next() { for (_, v) in a.match_stack { match v { - Match::Single(s) => { + Match::Single(_) => { if max_nargs < 1 { max_nargs = 1; } } - Match::Multiple(s, v) => { + Match::Multiple(_, v) => { if max_nargs < v.len() { max_nargs = v.len(); }