# Usage TaylorSeries.jl in to packages with different settings

**URL:** <https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 17, 2022, 11:50am UTC](https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191 "2022-05-17T11:50:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomas\_Radlicka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_radlicka/32/35484_2.png) [@Tomas\_Radlicka](https://discourse.julialang.org/u/Tomas_Radlicka)\
**Post date:** [May 17, 2022, 11:50am UTC](https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191/1 "2022-05-17T11:50:57Z")

</div>

I am using the TaylorSeries.jl in two independent packages (let’s say A.jl and B.jl), but I use them in one project.

The TaylorSeries.jl in A.jl is initialized as:

```julia
using TaylorSeries
function __init__ ()
    set_variables("dx dy dE",order=5)
end

```

In the package B.jl am using more variables:

```julia
using TaylorSeries.jl
function __init__ ()
    set_variables("x y dx dy dE",order=5)
end

```

When I use these packages in the project as

```julia
using A.jl
using B.jl

```

the setting of B.jl rewrites the setting of A.jl. It seems that both A.jl and B.jl share the same set of TaylorSeries. jl internal variables: e.g.  
`A.TaylorSeries.coeff_table` gives the same result as `B.TaylorSeries.coeff_table`

Does anybody know if this can be fixed somehow?

---

<div class="post-metadata">

**Author:** ![lbenet](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@lbenet](https://discourse.julialang.org/u/lbenet)\
**Post date:** [May 31, 2022, 3:35pm UTC](https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191/2 "2022-05-31T15:35:19Z")

</div>

Hi!

Thanks for posting your question and welcome to Julia!

You are right, in `TaylorSeries.jl` the multivariable case uses internal tables which behave as global variables; those tables have the information of what specific coefficient is associated with what monomial. Then, loading `B.jl` after `A.jl` changes those tables, which can certainly be the source of problems. If I recall correctly, this is mentioned in the documentation.

I do not know your actual problem, or if `dx dy dE` in `A.jl` represent the same variables in `B.jl`. Assuming that the names of the variables represent the same quantities in both packages, my initial suggestion is to use the same variables and ordering in `A.jl` and `B.jl`. This is certainly a waste of precious memory for `A.jl`, but should allow that everything works fine.

---

<div class="post-metadata">

**Author:** ![Tomas\_Radlicka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_radlicka/32/35484_2.png) [@Tomas\_Radlicka](https://discourse.julialang.org/u/Tomas_Radlicka)\
**Post date:** [May 31, 2022, 4:18pm UTC](https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191/3 "2022-05-31T16:18:14Z")

</div>

Thanks for the answer. Your suggested solution is one of the options.

I wonder if there is any standard approach to having internal tables of `TaylorSeries.jl` independent for `A,jl` and `B.jl`. Probably it is a property of Julia, that internal tables of a module are shared with all active modules that use it. If this is true, I have to handle that somehow …

---

<div class="post-metadata">

**Author:** ![lbenet](https://avatars.discourse-cdn.com/v4/letter/l/35a633/32.png) [@lbenet](https://discourse.julialang.org/u/lbenet)\
**Post date:** [May 31, 2022, 4:49pm UTC](https://discourse.julialang.org/t/usage-taylorseries-jl-in-to-packages-with-different-settings/81191/4 "2022-05-31T16:49:52Z")

</div>

The issue here is related to a design decision we made long time ago in `TaylorSeries.jl`, and not to Julia. Honestly, I see no simple way how to generalize it to two (a-priori weakly related) packages.

In TaylorSeries we also have the possibility of using _nested_ `Taylor1`s. Have you explore that? While the possibility exists, there is a lot of work to make the package user friendlier (and clear) when dealing with nested `Taylor1`s. Be aware that you may loose performance.

As I suggested previously, you should use the variables consistently across both packages, and that the variables you assign (say `dx`) mean the same in both. Not knowing more details of your actual application makes it difficult to help.
