Fix, clippy now working better

This commit is contained in:
elvis
2025-09-28 17:11:43 +02:00
parent dee8a3a5ff
commit 164e1d883c
7 changed files with 461 additions and 139 deletions

1
clippy.toml Normal file
View File

@ -0,0 +1 @@
ignore-interior-mutability = ["rsprocess::system::System", "rsprocess::system::PositiveSystem", ".."]

View File

@ -638,9 +638,16 @@ impl PositiveSet {
/// Returns all elements that are present in self and are positive in other.
pub fn mask(&self, other: &Self) -> Self {
Self::from_iter(self.iter().filter(|el| {
other.contains(&PositiveType::from((*el.0, IdState::Positive)))
}).map(|el| (*el.0, *el.1)))
Self::from_iter(
self.iter()
.filter(|el| {
other.contains(&PositiveType::from((
*el.0,
IdState::Positive,
)))
})
.map(|el| (*el.0, *el.1)),
)
}
fn remove_elements(&mut self, other: Vec<IdType>) {
@ -664,6 +671,7 @@ impl PositiveSet {
self_copy.is_empty()
}
// Returns only the positive entities.
pub fn positives(&self) -> Self {
self.iter()
.filter(|el| *el.1 == IdState::Positive)
@ -671,10 +679,20 @@ impl PositiveSet {
.collect::<PositiveSet>()
}
// Returns only the negative entities.
pub fn negatives(&self) -> Self {
self.iter()
.filter(|el| *el.1 == IdState::Negative)
.map(|el| (*el.0, *el.1))
.collect::<PositiveSet>()
}
pub fn add_unique(&self, other: &Self) -> Self {
other
.iter()
.filter(|e| !self.contains(&PositiveType::from((*e.0, *e.1))))
.map(|el| (*el.0, *el.1))
.collect::<PositiveSet>()
.union(self)
}
}

View File

@ -18,10 +18,12 @@ use super::process::{BasicProcess, PositiveProcess, Process};
use super::reaction::{
BasicReaction, ExtensionReaction, PositiveReaction, Reaction,
};
use super::set::{BasicSet, PositiveSet, Set};
use super::set::{BasicSet, ExtensionsSet, PositiveSet, Set};
use super::trace::Trace;
use super::transitions::TransitionsIterator;
use super::translator::{Formatter, PrintableWithTranslator, Translator};
use crate::trace::{EnabledReactions, SlicingElement, SlicingTrace};
use crate::transitions::TraceIterator;
pub trait BasicSystem
where
@ -49,6 +51,14 @@ where
&self,
) -> Result<impl Iterator<Item = (Self::Label, Self)>, String>;
#[allow(clippy::type_complexity)]
fn to_slicing_iterator(
&self,
) -> Result<
impl Iterator<Item = (Self::Set, Self::Set, Vec<usize>, Self)>,
String,
>;
fn environment(&self) -> &Self::Environment;
fn available_entities(&self) -> &Self::Set;
fn context(&self) -> &Self::Process;
@ -89,7 +99,12 @@ pub trait ExtensionsSystem: BasicSystem {
limit: usize,
) -> Result<Vec<(Self::Set, Self::Set, Self::Set)>, String>;
fn traces(self, n: usize) -> Result<Vec<Trace<Self::Label, Self>>, String>;
fn traces(&self, n: usize)
-> Result<Vec<Trace<Self::Label, Self>>, String>;
fn slice_trace(
&self,
) -> Result<SlicingTrace<Self::Set, Self::Reaction, Self>, String>;
}
impl<T: BasicSystem> ExtensionsSystem for T {
@ -242,14 +257,18 @@ impl<T: BasicSystem> ExtensionsSystem for T {
/// Return the first n traces. Equivalent to visiting the execution tree
/// depth first and returning the first n leaf nodes and their path to the
/// root.
fn traces(self, n: usize) -> Result<Vec<Trace<Self::Label, Self>>, String> {
fn traces(
&self,
n: usize,
) -> Result<Vec<Trace<Self::Label, Self>>, String> {
if n == 0 {
return Ok(vec![]);
}
let sys = self.clone();
let mut n = n;
let mut res: Vec<Trace<Self::Label, Self>> = vec![];
let mut current_trace: Trace<Self::Label, Self> = Trace::default();
current_trace.push((None, Rc::new(self)));
current_trace.push((None, Rc::new(sys)));
let mut branch = vec![0];
let mut depth = 0;
let mut new_branch = true;
@ -293,6 +312,57 @@ impl<T: BasicSystem> ExtensionsSystem for T {
Ok(res)
}
#[allow(clippy::field_reassign_with_default)]
#[allow(clippy::type_complexity)]
fn slice_trace(
&self,
) -> Result<SlicingTrace<Self::Set, Self::Reaction, Self>, String> {
let mut trace = SlicingTrace::default();
trace.context_elements = Rc::new(self.context_elements());
trace.products_elements = Rc::new(self.products_elements());
trace.reactions = Rc::new(self.reactions().clone());
trace.systems.push(Rc::new(self.clone()));
trace.elements.push(SlicingElement::from((
Self::Set::default(),
self.available_entities().clone(),
)));
let current: Option<(Self::Set, Self::Set, Vec<usize>, Self)> =
self.to_slicing_iterator()?.next();
if current.is_none() {
return Ok(trace);
}
let current = current.unwrap();
let (context, products, enabled_reactions, mut current) = current;
trace
.elements
.push(SlicingElement::from((context, products)));
trace
.enabled_reactions
.push(EnabledReactions::from(enabled_reactions));
trace.systems.push(Rc::new(current.clone()));
loop {
let t = current.to_slicing_iterator()?.next();
if let Some((context, products, enabled_reactions, next_sys)) = t {
current = next_sys;
trace
.elements
.push(SlicingElement::from((context, products)));
trace
.enabled_reactions
.push(EnabledReactions::from(enabled_reactions));
trace.systems.push(Rc::new(current.clone()));
} else {
break;
}
}
// trace.enabled_reactions.pop();
Ok(trace)
}
}
// -----------------------------------------------------------------------------
@ -433,6 +503,14 @@ impl BasicSystem for System {
TransitionsIterator::<Self::Set, Self, Self::Process>::try_from(self)
}
#[allow(refining_impl_trait)] // otherwise impl cannot be resolved to
// concrete type and the compiler complains
fn to_slicing_iterator(
&self,
) -> Result<TraceIterator<'_, Self::Set, Self, Self::Process>, String> {
unimplemented!()
}
fn environment(&self) -> &Self::Environment {
&self.delta
}
@ -454,7 +532,8 @@ impl BasicSystem for System {
if c.is_some() {
c.as_ref().unwrap().clone()
} else {
let all_elements_context = self.delta
let all_elements_context = self
.delta
.all_elements()
.union(&self.context_process.all_elements())
.subtraction(&self.products_elements());
@ -469,10 +548,12 @@ impl BasicSystem for System {
if p.is_some() {
p.as_ref().unwrap().clone()
} else {
let products_elements = self.reaction_rules
let products_elements = self
.reaction_rules
.iter()
.fold(Self::Set::default(), |acc: Self::Set, r|
acc.union(&r.products));
.fold(Self::Set::default(), |acc: Self::Set, r| {
acc.union(&r.products)
});
*p = Some(products_elements.clone());
products_elements
@ -729,6 +810,15 @@ impl BasicSystem for PositiveSystem {
TransitionsIterator::<Self::Set, Self, Self::Process>::try_from(self)
}
fn to_slicing_iterator(
&self,
) -> Result<
impl Iterator<Item = (Self::Set, Self::Set, Vec<usize>, Self)>,
String,
> {
TraceIterator::<Self::Set, Self, Self::Process>::try_from(self)
}
fn environment(&self) -> &Self::Environment {
&self.delta
}
@ -750,10 +840,14 @@ impl BasicSystem for PositiveSystem {
if c.is_some() {
c.as_ref().unwrap().clone()
} else {
let all_elements_context = self.delta
let all_elements_context = self
.delta
.all_elements()
.union(&self.context_process.all_elements())
.subtraction(&self.products_elements());
.subtraction(&self.products_elements())
.iter()
.map(|e| (*e.0, IdState::Positive))
.collect::<Self::Set>();
*c = Some(all_elements_context.clone());
all_elements_context
@ -765,10 +859,15 @@ impl BasicSystem for PositiveSystem {
if p.is_some() {
p.as_ref().unwrap().clone()
} else {
let products_elements = self.reaction_rules
let products_elements = self
.reaction_rules
.iter()
.fold(Self::Set::default(), |acc: Self::Set, r|
acc.union(&r.products));
.fold(Self::Set::default(), |acc: Self::Set, r| {
acc.union(&r.products)
})
.iter()
.map(|e| (*e.0, IdState::Positive))
.collect::<Self::Set>();
*p = Some(products_elements.clone());
products_elements
@ -938,4 +1037,11 @@ impl PositiveSystem {
products_elements: Rc::new(RefCell::new(None)),
}
}
pub fn negated_products_elements(&self) -> PositiveSet {
self.products_elements()
.iter()
.map(|el| (*el.0, IdState::Negative))
.collect::<PositiveSet>()
}
}

View File

@ -1,5 +1,6 @@
use super::set::PositiveSet;
use super::system::BasicSystem;
use crate::system::ExtensionsSystem;
#[test]
fn one_transition() {
@ -344,3 +345,88 @@ fn conversion_entities() {
])
);
}
#[test]
fn slice_trace() {
use std::rc::Rc;
use super::environment::Environment;
use super::process::Process;
use super::reaction::Reaction;
use super::set::Set;
use super::system::{PositiveSystem, System};
let mut translator = crate::translator::Translator::new();
let mut tr = |a| translator.encode(a);
let system = System::from(
Rc::new(Environment::from([])),
Set::from([tr("a"), tr("b")]),
Process::EntitySet {
entities: Set::from([tr("c")]),
next_process: Rc::new(Process::EntitySet {
entities: Set::from([]),
next_process: Rc::new(Process::Nill),
}),
},
Rc::new(vec![Reaction::from(
Set::from([tr("a")]),
Set::from([]),
Set::from([tr("b")]),
)]),
);
let system: PositiveSystem = system.into();
let res_slice = system.slice_trace().unwrap();
let res_run = system.run().unwrap();
assert_eq!(res_slice.systems, res_run);
}
#[test]
fn slice_trace_2() {
use std::rc::Rc;
use super::environment::Environment;
use super::process::Process;
use super::reaction::Reaction;
use super::set::Set;
use super::system::{PositiveSystem, System};
let mut translator = crate::translator::Translator::new();
let mut tr = |a| translator.encode(a);
let system = System::from(
Rc::new(Environment::from([])),
Set::from([tr("a"), tr("b")]),
Process::EntitySet {
entities: Set::from([tr("c")]),
next_process: Rc::new(Process::EntitySet {
entities: Set::from([]),
next_process: Rc::new(Process::Nill),
}),
},
Rc::new(vec![
Reaction::from(
Set::from([tr("a")]),
Set::from([tr("b")]),
Set::from([tr("b")]),
),
Reaction::from(
Set::from([tr("b")]),
Set::from([tr("a")]),
Set::from([tr("a")]),
),
]),
);
let system: PositiveSystem = system.into();
let res_slice = system.slice_trace().unwrap();
let res_run = system.run().unwrap();
assert_eq!(res_slice.systems, res_run);
}

View File

@ -86,6 +86,15 @@ pub struct SlicingElement<S> {
pub reaction_products: S,
}
impl<S> From<(S, S)> for SlicingElement<S> {
fn from(value: (S, S)) -> Self {
Self {
context: value.0,
reaction_products: value.1,
}
}
}
impl<S> Debug for SlicingElement<S>
where
S: Debug,
@ -126,6 +135,28 @@ pub struct EnabledReactions {
pub data: Vec<usize>,
}
impl From<Vec<usize>> for EnabledReactions {
fn from(value: Vec<usize>) -> Self {
Self { data: value }
}
}
impl From<&[usize]> for EnabledReactions {
fn from(value: &[usize]) -> Self {
Self {
data: value.to_vec(),
}
}
}
impl<const N: usize> From<[usize; N]> for EnabledReactions {
fn from(value: [usize; N]) -> Self {
Self {
data: value.to_vec(),
}
}
}
impl PrintableWithTranslator for EnabledReactions {
fn print(
&self,
@ -160,10 +191,11 @@ impl EnabledReactions {
}
#[derive(Clone)]
pub struct SlicingTrace<S: BasicSet,
pub struct SlicingTrace<
S: BasicSet,
R: BasicReaction<Set = S>,
Sys: BasicSystem<Set = S, Reaction = R>>
{
Sys: BasicSystem<Set = S, Reaction = R>,
> {
pub elements: Vec<SlicingElement<S>>,
pub enabled_reactions: Vec<EnabledReactions>,
@ -174,10 +206,11 @@ pub struct SlicingTrace<S: BasicSet,
pub products_elements: Rc<S>,
}
impl<S: BasicSet,
impl<
S: BasicSet,
R: BasicReaction<Set = S>,
Sys: BasicSystem<Set = S, Reaction = R>>
Default for SlicingTrace<S, R, Sys>
Sys: BasicSystem<Set = S, Reaction = R>,
> Default for SlicingTrace<S, R, Sys>
{
fn default() -> Self {
Self {
@ -191,10 +224,11 @@ impl<S: BasicSet,
}
}
impl<S: BasicSet + Debug,
impl<
S: BasicSet + Debug,
R: BasicReaction<Set = S>,
Sys: BasicSystem<Set = S, Reaction = R>>
SlicingTrace<S, R, Sys>
Sys: BasicSystem<Set = S, Reaction = R>,
> SlicingTrace<S, R, Sys>
{
pub fn is_empty(&self) -> bool {
self.elements.is_empty()
@ -205,7 +239,6 @@ impl<S: BasicSet + Debug,
}
}
impl SlicingTrace<Set, Reaction, System> {
pub fn slice(&self, marking: Set) -> Result<Self, String> {
let mut reversed_elements = Vec::with_capacity(self.elements.len());
@ -295,7 +328,8 @@ impl SlicingTrace<PositiveSet, PositiveReaction, PositiveSystem> {
for r in self.enabled_reactions[i].iter() {
if !reversed_elements[reverse_i - 1]
.reaction_products
.intersection(self.reactions[*r].products()).is_empty()
.intersection(self.reactions[*r].products())
.is_empty()
{
reversed_enabled_reactions[reverse_i - 1].data.push(*r);
reversed_elements[reverse_i].context.push(
@ -328,11 +362,11 @@ impl SlicingTrace<PositiveSet, PositiveReaction, PositiveSystem> {
}
}
impl<S: BasicSet,
impl<
S: BasicSet,
R: BasicReaction<Set = S>,
Sys: BasicSystem<Set = S, Reaction = R>,>
PrintableWithTranslator for SlicingTrace<S, R, Sys>
Sys: BasicSystem<Set = S, Reaction = R>,
> PrintableWithTranslator for SlicingTrace<S, R, Sys>
{
fn print(
&self,

View File

@ -2,7 +2,7 @@ use std::rc::Rc;
use crate::element::IdState;
use crate::reaction::{BasicReaction, PositiveReaction, Reaction};
use crate::set::{ExtensionsSet, PositiveSet, Set, BasicSet};
use crate::set::{BasicSet, ExtensionsSet, PositiveSet, Set};
use crate::system::{PositiveSystem, System};
use crate::trace::*;
use crate::translator::Translator;
@ -82,9 +82,10 @@ fn slice_atoi() {
.map(|el| translator.encode(*el))
.collect::<Vec<_>>()
.into();
let products_elements =
["rorgt", "stat3", "il21r", "il6r", "nfat", "stat1", "tbet", "il21",
"il23r"]
let products_elements = [
"rorgt", "stat3", "il21r", "il6r", "nfat", "stat1", "tbet", "il21",
"il23r",
]
.iter()
.map(|el| translator.encode(*el))
.collect::<Vec<_>>()
@ -205,49 +206,104 @@ fn slice_positive_atoi() {
);
let converted_system: PositiveSystem = system.into();
let mut reactions = Rc::try_unwrap(converted_system.reaction_rules).unwrap();
reactions.sort_by(|a, b| a.reactants.cmp(&b.reactants)
.then(a.products.cmp(&b.products)));
let mut reactions =
Rc::try_unwrap(converted_system.reaction_rules).unwrap();
reactions.sort_by(|a, b| {
a.reactants
.cmp(&b.reactants)
.then(a.products.cmp(&b.products))
});
println!("Computed Reactions:");
for (pos, r) in reactions.iter().enumerate() {
println!("\t({pos}) {},", crate::translator::Formatter::from(&translator, r));
println!(
"\t({pos}) {},",
crate::translator::Formatter::from(&translator, r)
);
}
reactions
};
let elements = [
(vec![("il23r", IdState::Positive), ("il21", IdState::Positive),
("rorgt", IdState::Negative), ("stat3", IdState::Negative),
("il21r", IdState::Negative), ("il6r", IdState::Negative),
("nfat", IdState::Negative), ("stat1", IdState::Negative),
("tbet", IdState::Negative), ("tgfbr", IdState::Negative),
("foxp3", IdState::Negative)],
vec![("tcr", IdState::Positive), ("tgfb", IdState::Negative),
("il6", IdState::Negative), ("il27", IdState::Negative)]),
(vec![("il21r", IdState::Positive), ("stat3", IdState::Positive),
("nfat", IdState::Positive), ("rorgt", IdState::Negative),
("il6r", IdState::Negative), ("stat1", IdState::Negative),
("tbet", IdState::Negative), ("il21", IdState::Negative),
("il23r", IdState::Negative), ("tgfbr", IdState::Negative),
("foxp3", IdState::Negative)],
vec![("il27", IdState::Positive), ("tgfb", IdState::Negative),
("il6", IdState::Negative), ("tcr", IdState::Negative)]),
(vec![("stat1", IdState::Positive), ("rorgt", IdState::Negative),
("stat3", IdState::Negative), ("il21r", IdState::Negative),
("il6r", IdState::Negative), ("nfat", IdState::Negative),
("tbet", IdState::Negative), ("il21", IdState::Negative),
("il23r", IdState::Negative), ("tgfbr", IdState::Negative),
("foxp3", IdState::Negative)],
vec![("il27", IdState::Negative), ("tgfb", IdState::Negative),
("il6", IdState::Negative), ("tcr", IdState::Negative)]),
(vec![("tbet", IdState::Positive), ("rorgt", IdState::Negative),
("stat3", IdState::Negative), ("il21r", IdState::Negative),
("il6r", IdState::Negative), ("nfat", IdState::Negative),
("stat1", IdState::Negative), ("il21", IdState::Negative),
("il23r", IdState::Negative), ("tgfbr", IdState::Negative),
("foxp3", IdState::Negative)],
vec![]),
(
vec![
("il23r", IdState::Positive),
("il21", IdState::Positive),
("rorgt", IdState::Negative),
("stat3", IdState::Negative),
("il21r", IdState::Negative),
("il6r", IdState::Negative),
("nfat", IdState::Negative),
("stat1", IdState::Negative),
("tbet", IdState::Negative),
("tgfbr", IdState::Negative),
("foxp3", IdState::Negative),
],
vec![
("tcr", IdState::Positive),
("tgfb", IdState::Negative),
("il6", IdState::Negative),
("il27", IdState::Negative),
],
),
(
vec![
("il21r", IdState::Positive),
("stat3", IdState::Positive),
("nfat", IdState::Positive),
("rorgt", IdState::Negative),
("il6r", IdState::Negative),
("stat1", IdState::Negative),
("tbet", IdState::Negative),
("il21", IdState::Negative),
("il23r", IdState::Negative),
("tgfbr", IdState::Negative),
("foxp3", IdState::Negative),
],
vec![
("il27", IdState::Positive),
("tgfb", IdState::Negative),
("il6", IdState::Negative),
("tcr", IdState::Negative),
],
),
(
vec![
("stat1", IdState::Positive),
("rorgt", IdState::Negative),
("stat3", IdState::Negative),
("il21r", IdState::Negative),
("il6r", IdState::Negative),
("nfat", IdState::Negative),
("tbet", IdState::Negative),
("il21", IdState::Negative),
("il23r", IdState::Negative),
("tgfbr", IdState::Negative),
("foxp3", IdState::Negative),
],
vec![
("il27", IdState::Negative),
("tgfb", IdState::Negative),
("il6", IdState::Negative),
("tcr", IdState::Negative),
],
),
(
vec![
("tbet", IdState::Positive),
("rorgt", IdState::Negative),
("stat3", IdState::Negative),
("il21r", IdState::Negative),
("il6r", IdState::Negative),
("nfat", IdState::Negative),
("stat1", IdState::Negative),
("il21", IdState::Negative),
("il23r", IdState::Negative),
("tgfbr", IdState::Negative),
("foxp3", IdState::Negative),
],
vec![],
),
]
.iter()
.map(|elements| SlicingElement {
@ -256,21 +312,23 @@ fn slice_positive_atoi() {
.1
.iter()
.map(|el| (translator.encode(el.0), el.1))
.collect::<Vec<_>>()),
.collect::<Vec<_>>(),
),
reaction_products: Into::<PositiveSet>::into(
elements
.0
.iter()
.map(|el| (translator.encode(el.0), el.1))
.collect::<Vec<_>>()),
.collect::<Vec<_>>(),
),
})
.collect::<Vec<_>>();
let enabled_reactions = {
let mut enabled_reactions = vec![];
for slice_el in elements.iter().rev().skip(1).rev() {
let available_enteties = slice_el.context.union(&slice_el.reaction_products);
let available_enteties =
slice_el.context.union(&slice_el.reaction_products);
enabled_reactions.push(vec![]);
for (pos, r) in reactions.iter().enumerate() {
if r.enabled(&available_enteties) {
@ -278,28 +336,29 @@ fn slice_positive_atoi() {
}
}
}
enabled_reactions.into_iter()
.map(|r| EnabledReactions {
data: r,
})
enabled_reactions
.into_iter()
.map(|r| EnabledReactions { data: r })
.collect::<Vec<_>>()
};
let context_elements =
Into::<Set>::into(
let context_elements = Into::<Set>::into(
["tgfb", "il6", "tcr", "il27"]
.iter()
.map(|el| translator.encode(*el))
.collect::<Vec<_>>()
).to_positive_set(IdState::Positive);
let products_elements =
Into::<Set>::into(
["rorgt", "stat3", "il21r", "il6r", "nfat", "stat1", "tbet", "il21",
"il23r", "tgfbr", "foxp3"]
.collect::<Vec<_>>(),
)
.to_positive_set(IdState::Positive);
let products_elements = Into::<Set>::into(
[
"rorgt", "stat3", "il21r", "il6r", "nfat", "stat1", "tbet", "il21",
"il23r", "tgfbr", "foxp3",
]
.iter()
.map(|el| translator.encode(*el))
.collect::<Vec<_>>()
).to_positive_set(IdState::Positive);
.collect::<Vec<_>>(),
)
.to_positive_set(IdState::Positive);
let trace: SlicingTrace<PositiveSet, PositiveReaction, PositiveSystem> =
SlicingTrace {
@ -312,13 +371,13 @@ fn slice_positive_atoi() {
products_elements: Rc::new(products_elements),
};
let marking =
Into::<Set>::into(
let marking = Into::<Set>::into(
["tbet"]
.iter()
.map(|el| translator.encode(*el))
.collect::<Vec<_>>()
).to_positive_set(IdState::Positive);
.collect::<Vec<_>>(),
)
.to_positive_set(IdState::Positive);
let sliced = trace.slice(marking).unwrap();
@ -334,14 +393,19 @@ fn slice_positive_atoi() {
})
.collect::<Vec<_>>();
reaction_products.iter_mut().for_each(|x| x.sort());
let mut correct_reaction_products: Vec<Vec<(String, IdState)>> =
[vec![("foxp3", IdState::Negative)],
let mut correct_reaction_products: Vec<Vec<(String, IdState)>> = [
vec![("foxp3", IdState::Negative)],
vec![("nfat", IdState::Positive), ("tgfbr", IdState::Negative)],
vec![("stat1", IdState::Positive), ("foxp3", IdState::Negative),
("rorgt", IdState::Negative)],
vec![("tbet", IdState::Positive)]]
.iter().map(|x| x.iter().map(|y| (y.0.to_string(), y.1))
.collect::<Vec<_>>()).collect::<Vec<_>>();
vec![
("stat1", IdState::Positive),
("foxp3", IdState::Negative),
("rorgt", IdState::Negative),
],
vec![("tbet", IdState::Positive)],
]
.iter()
.map(|x| x.iter().map(|y| (y.0.to_string(), y.1)).collect::<Vec<_>>())
.collect::<Vec<_>>();
correct_reaction_products.iter_mut().for_each(|x| x.sort());
assert_eq!(reaction_products, correct_reaction_products);
@ -358,13 +422,15 @@ fn slice_positive_atoi() {
})
.collect::<Vec<_>>();
context.iter_mut().for_each(|x| x.sort());
let mut correct_context =
[vec![("tcr", IdState::Positive)],
let mut correct_context = [
vec![("tcr", IdState::Positive)],
vec![("il27", IdState::Positive)],
vec![],
vec![]]
.iter().map(|x| x.iter().map(|y| (y.0.to_string(), y.1))
.collect::<Vec<_>>()).collect::<Vec<_>>();
vec![],
]
.iter()
.map(|x| x.iter().map(|y| (y.0.to_string(), y.1)).collect::<Vec<_>>())
.collect::<Vec<_>>();
correct_context.iter_mut().for_each(|x| x.sort());
assert_eq!(context, correct_context);

View File

@ -187,6 +187,7 @@ impl<'a> Iterator
);
let new_system = PositiveSystem::from(
Rc::clone(&self.system.delta),
// products.add_unique(&self.system.negated_products_elements()),
products,
(*k).clone(),
Rc::clone(&self.system.reaction_rules),
@ -224,6 +225,14 @@ impl<'a> TryFrom<&'a PositiveSystem>
}
}
impl<'a> Iterator for TraceIterator<'a, Set, System, Process> {
type Item = (Set, Set, Vec<usize>, System);
fn next(&mut self) -> Option<Self::Item> {
unimplemented!()
}
}
impl<'a> Iterator
for TraceIterator<'a, PositiveSet, PositiveSystem, PositiveProcess>
{
@ -249,14 +258,16 @@ impl<'a> Iterator
let new_system = PositiveSystem::from(
Rc::clone(&self.system.delta),
all_products,
// all_products.add_unique(&self.system.
// negated_products_elements()),
all_products.clone(),
(*k).clone(),
Rc::clone(&self.system.reaction_rules),
);
Some((
context.as_ref().clone(),
self.system.available_entities().clone(),
all_products.mask(&self.system.products_elements()),
enabled_reaction_positions,
new_system,
))