https://github.com/bsdz/calcengine Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Issues - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} bsdz / calcengine * Notifications * Star 98 * Fork 2 Simple Python Calculation Engine MIT License 98 stars 2 forks Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 0 tags Code Clone HTTPS GitHub CLI [https://github.com/b] Use Git or checkout with SVN using the web URL. [gh repo clone bsdz/c] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @bsdz bsdz Update pyproject.toml ... 13ed0e6 Jul 8, 2021 Update pyproject.toml Re-instate setuptools. 13ed0e6 Git stats * 8 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .vscode Initial commit Aug 2, 2020 calcengine Initial commit Aug 2, 2020 demo/spreadsheet Add simple demo animation Aug 6, 2020 tests Initial commit Aug 2, 2020 .flake8 Initial commit Aug 2, 2020 .gitignore Initial commit Aug 2, 2020 LICENSE Initial commit Aug 2, 2020 README.md Update README.md Jul 8, 2021 poetry.lock Add simple demo animation Aug 6, 2020 pyproject.toml Update pyproject.toml Jul 8, 2021 scratch.md Initial commit Aug 2, 2020 View code calcengine Installation Core Dependencies Usage Demo application Installation To do similar packages README.md calcengine A simple lazy Python Calculation Engine. Installation The module is still in development. You can install it by cloning this repository and using the poetry install command. git clone git@github.com:bsdz/calcengine.git cd calcengine python3 -mvenv --prompt calceng .venv . ./.venv/bin/activate poetry install Alternatively, you can add to your existing poetry project: poetry add git+https://github.com/bsdz/calcengine.git Or install via pip: pip install git+https://github.com/bsdz/calcengine.git#master Core Dependencies The core module for the calculation engine only uses core python standard library. The demo spreadsheet application uses pyqt5, pandas, matplotlib and pillow. Usage First instantiate a CalcEngine and use watch decorator to register functions as nodes. Note that a function along with any arguments and keyword arguments make a unique node. from calcengine import CalcEngine ce = CalcEngine() @ce.watch() def a(): print("..in a") return 100 @ce.watch() def b(): print("..in b") return a() @ce.watch() def c(x, y): print(f"..in c with x={x} and y={y}") return 2 * a() + x * y @ce.watch() def d(x, y=0): print(f"..in d with x={x} and y={y}") return 3 * b() + x - y @ce.watch() def e(): print("..in e") _x = d(5, y=-3) return c(2, 3) - 5 + _x @ce.watch() def f(): print("..in f") return d(0) + e() Calling a function will cache all values and path during first run. >>> f() ..in f ..in d with x=0 and y=0 ..in b ..in a ..in e ..in d with x=5 and y=-3 ..in c with x=2 and y=3 809 And obviously a 2nd invocation will retrieve the final value from cache. >>> f() 809 Invalidating a node by calling function helper method. >>> e.invalidate() >>> f() ..in f ..in e 809 Invalidating a node without arguments if previous call did have arguments won't have any effect. >>> d.invalidate() >>> f() 809 Whereas with arguments specified exactly as prior call will. Note the sensitivity of argument specification. >>> d.invalidate(5, y=-3) >>> f() ..in f ..in e ..in d with x=5 and y=-3 809 It is also possible to add a trigger that will be called on completion of a function. This might be used to produce some form of data binding in applications. def my_trigger(res): print(f"got {res}") >>> c.node_calculated.append(my_trigger) >>> c.invalidate(2, 3) >>> f() call f call e call c with x=2 and y=3 got 206 809 Demo application Included is a simple spreadsheet demo. Read more here Demo animation Installation To install the dependencies required by the demo. When cloning this repo also include the "demo" extras. poetry install -E demo python demo/spreadsheet/main.py To do * Support watching global variables. * Support multiprocessing. * Support asyncio?. similar packages Some similar packages spotted. None of them tested. * pyungo * dask * schedula * graphkit * mdf About Simple Python Calculation Engine Resources Readme License MIT License Releases No releases published Packages 0 No packages published Languages * Python 100.0% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.