From bdc19e18e49c229460221034fe99466be05326e5 Mon Sep 17 00:00:00 2001 From: Ben Ruijl Date: Mon, 13 May 2024 12:02:17 +0200 Subject: [PATCH] Release Symbolica 0.5.0 --- Cargo.toml | 2 +- Readme.md | 2 +- pyproject.toml | 2 +- src/api/python.rs | 29 +++++++++++++++++++++++------ symbolica.pyi | 33 +++++++++++++++++++++++++++------ 5 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c9ff133..babff1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ name = "symbolica" readme = "Readme.md" repository = "https://github.com/benruijl/symbolica" rust-version = "1.73" -version = "0.4.0" +version = "0.5.0" [profile.release] codegen-units = 1 diff --git a/Readme.md b/Readme.md index b2d3d70..85dfacf 100644 --- a/Readme.md +++ b/Readme.md @@ -62,7 +62,7 @@ If you want to use Symbolica as a library in Rust, simply include it in the `Car ```toml [dependencies] -symbolica = "0.4" +symbolica = "0.5" ``` # Examples diff --git a/pyproject.toml b/pyproject.toml index 7a542c4..d62a2d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ keywords = ["math", "algebra", "polynomial", "expression", "manipulation"] license = {file = "License.md"} name = "symbolica" readme = "Readme.md" -version = "0.4.0" +version = "0.5.0" classifiers = [ "Development Status :: 3 - Alpha", diff --git a/src/api/python.rs b/src/api/python.rs index adef866..b1d85b8 100644 --- a/src/api/python.rs +++ b/src/api/python.rs @@ -1280,9 +1280,10 @@ macro_rules! req_wc_cmp { #[pymethods] impl PythonExpression { - /// Create a new symbol from a `name`. Can be turned into a symmetric symbol - /// using `is_symmetric=True` or into an antisymmetric symbol using `is_antisymmetric=True`. - /// The symbol can be made multilinear using `is_linear=True`. If no attributes + /// Create a new symbol from a `name`. Symbols carry information about their attributes. + /// The symbol can signal that it is symmetric if it is used as a function + /// using `is_symmetric=True`, antisymmetric using `is_antisymmetric=True`, and + /// multilinear using `is_linear=True`. If no attributes /// are specified, the attributes are inherited from the symbol if it was already defined, /// otherwise all attributes are set to `false`. /// @@ -1296,7 +1297,7 @@ impl PythonExpression { /// >>> print(e) /// x**2 + 5 /// - /// Define a regular symbol and use it as a function symbol: + /// Define a regular symbol and use it as a function: /// >>> f = Expression.symbol('f') /// >>> e = f(1,2) /// >>> print(e) @@ -1351,7 +1352,14 @@ impl PythonExpression { Ok(Atom::new_var(id).into()) } - /// Create a Symbolica variable for every name in `*names`. + /// Create a Symbolica symbol for every name in `*names`. See `Expression.symbol` for more information. + /// + /// Examples + /// -------- + /// >>> f, x = Expression.symbols('x', 'f') + /// >>> e = f(1,x) + /// >>> print(e) + /// f(1,x) #[pyo3(signature = (*args,is_symmetric=None,is_antisymmetric=None,is_linear=None))] #[classmethod] pub fn symbols( @@ -3095,7 +3103,16 @@ impl PythonExpression { } } -/// A Symbolica term streamer. +/// A series expansion class. +/// +/// Supports standard arithmetic operations, such +/// as addition and multiplication. +/// +/// Examples +/// -------- +/// >>> x = Expression.symbol('x') +/// >>> s = Expression.parse("(1-cos(x))/sin(x)").series(x, 0, 4) +/// >>> print(s) #[pyclass(name = "Series", module = "symbolica")] pub struct PythonSeries { pub series: Series, diff --git a/symbolica.pyi b/symbolica.pyi index ec382d7..e3da1bf 100644 --- a/symbolica.pyi +++ b/symbolica.pyi @@ -114,13 +114,14 @@ class Expression: @classmethod def symbol(_cls, name: str, is_symmetric: Optional[bool] = None, is_antisymmetric: Optional[bool] = None, is_linear: Optional[bool] = None) -> Expression: """ - Create a new symbol from a `name`. Can be turned into a symmetric function - using `is_symmetric=True` or into an antisymmetric function using `is_antisymmetric=True`. - The function can be made multilinear using `is_linear=True`. If no attributes + Create a new symbol from a `name`. Symbols carry information about their attributes. + The symbol can signal that it is symmetric if it is used as a function + using `is_symmetric=True`, antisymmetric using `is_antisymmetric=True`, and + multilinear using `is_linear=True`. If no attributes are specified, the attributes are inherited from the symbol if it was already defined, otherwise all attributes are set to `false`. - Once attributes are defined on a function, they cannot be redefined later. + Once attributes are defined on a symbol, they cannot be redefined later. Examples -------- @@ -130,7 +131,7 @@ class Expression: >>> print(e) x**2 + 5 - Define a regular symbol and use it as a function symbol: + Define a regular symbol and use it as a function: >>> f = Expression.symbol('f') >>> e = f(1,2) >>> print(e) @@ -154,7 +155,14 @@ class Expression: @classmethod def symbols(_cls, *names: str, is_symmetric: Optional[bool] = None, is_antisymmetric: Optional[bool] = None, is_linear: Optional[bool] = None) -> Sequence[Expression]: """ - Create a Symbolica function for every name in `*names`. + Create a Symbolica symbol for every name in `*names`. See `Expression.symbol` for more information. + + Examples + -------- + >>> f, x = Expression.symbols('x', 'f') + >>> e = f(1,x) + >>> print(e) + f(1,x) """ @overload @@ -1360,6 +1368,19 @@ class Transformer: class Series: + """ + A series expansion class. + + Supports standard arithmetic operations, such + as addition and multiplication. + + Examples + -------- + >>> x = Expression.symbol('x') + >>> s = Expression.parse("(1-cos(x))/sin(x)").series(x, 0, 4) + >>> print(s) + """ + def __add__(self, other: Series) -> Series: """Add two series together, returning the result."""