Skip to content

Commit

Permalink
Set expansion depth to non-zero value
Browse files Browse the repository at this point in the history
  • Loading branch information
benruijl committed May 28, 2024
1 parent 8b29ba8 commit d3057f1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/derivative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,12 @@ impl<'a> AtomView<'a> {
depth: Rational,
) -> Result<Series<AtomField>, &'static str> {
// heuristic current depth
let mut current_depth = if depth.is_negative() {
let mut current_depth = if depth.is_negative() || depth.is_zero() {
Rational::one()
} else {
depth.clone()
};

Workspace::get_local().with(|ws| loop {
let info = Series::new(
&AtomField::new(),
Expand Down Expand Up @@ -822,6 +823,18 @@ mod test {
assert_eq!(t2.absolute_order(), (22, 3).into());
}

#[test]
fn series_zero() {
let v1 = State::get_symbol("v1");

let input = Atom::parse("1/v1^2+1/v1+v1").unwrap();
let t = input
.series(v1, Atom::new_num(0).as_view(), 0.into())
.unwrap();

assert_eq!(t.to_atom().expand(), Atom::parse("v1^-2+v1^-1").unwrap());
}

#[test]
fn series_poles() {
let v1 = State::get_symbol("v1");
Expand Down

0 comments on commit d3057f1

Please sign in to comment.