Skip to content

Commit

Permalink
Merge branch 'benruijl:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
GraDje13 authored Dec 10, 2024
2 parents bbdfde9 + fe31c83 commit 371df9d
Show file tree
Hide file tree
Showing 25 changed files with 3,402 additions and 1,119 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ crate-type = ["lib"]
name = "symbolica"

[features]
default = []
default = ["tracing_only_warnings"]
# if using this, make sure jemalloc is compiled with --disable-initial-exec-tls
# if symbolica is used as a dynamic library (as is the case for the Python API)
faster_alloc = ["tikv-jemallocator"]
Expand All @@ -37,6 +37,7 @@ python_api = ["pyo3", "bincode"]
python_no_module = ["python_api"]
# build a module that is independent of the specific Python version
python_abi3 = ["pyo3/abi3", "pyo3/abi3-py37"]
tracing_only_warnings = ["tracing/release_max_level_warn"]

[dependencies.pyo3]
features = ["extension-module", "abi3", "py-clone"]
Expand Down Expand Up @@ -67,6 +68,6 @@ smallvec = "1.13"
smartstring = "1.0"
tikv-jemallocator = {version = "0.5.4", optional = true}
tinyjson = "2.5"
tracing = {version = "0.1", features = ["max_level_trace", "release_max_level_warn"]}
tracing = "0.1"
wide = "0.7"
wolfram-library-link = {version = "0.2.9", optional = true}
13 changes: 6 additions & 7 deletions examples/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ use symbolica::{atom::Atom, fun, state::State};

fn main() {
let input = Atom::parse("x*(1+a)+x*5*y+f(5,x)+2+y^2+x^2 + x^3").unwrap();
let x = State::get_symbol("x");
let x = State::get_symbol("x").into();
let key = State::get_symbol("key");
let coeff = State::get_symbol("val");

let (r, rest) = input.coefficient_list(x);
let r = input.coefficient_list::<i8>(std::slice::from_ref(&x));

println!("> Coefficient list:");
for (key, val) in r {
println!("\t{} {}", key, val);
}
println!("\t1 {}", rest);

println!("> Collect in x:");
let out = input.collect(
x,
let out = input.collect::<i8>(
&x,
Some(Box::new(|x, out| {
out.set_from_view(&x);
})),
Expand All @@ -25,8 +24,8 @@ fn main() {
println!("\t{}", out);

println!("> Collect in x with wrapping:");
let out = input.collect(
x,
let out = input.collect::<i8>(
&x,
Some(Box::new(move |a, out| {
out.set_from_view(&a);
*out = fun!(key, out);
Expand Down
Loading

0 comments on commit 371df9d

Please sign in to comment.