pygae / pyganja Goto Github PK
View Code? Open in Web Editor NEWVisualisation library for geometric algebra with cefpython and ganja.js
License: MIT License
Visualisation library for geometric algebra with cefpython and ganja.js
License: MIT License
>>> from pyganja import *
/usr/lib/python3/dist-packages/bpython/curtsiesfrontend/repl.py:251: UserWarning: Failed to import cef_gui, cef functions will be unavailable
module = self.loader.load_module(name)
>>> gs = GanjaScene()
>>> gs
Traceback (most recent call last):
File "<input>", line 1, in <module>
gs
File "/usr/local/lib/python3.6/dist-packages/pyganja/GanjaScene.py", line 105, in __repr__
new_str = str.replace(new_str, ']}', """].map(x=>x.length=="""+str(self.mv_length)+"""?new Element(x):x)}""")
AttributeError: 'GanjaScene' object has no attribute 'mv_length'
I used the follow in Google colab notebook
!pip install clifford
!pip install pyganja
from clifford.tools.g3c import random_line
from pyganja import *
draw([random_line() for i in range(10)])
And I get the follow error
/usr/local/lib/python3.6/dist-packages/pyganja/__init__.py:2: UserWarning: Failed to import cef_gui, cef functions will be unavailable
from .script_api import *
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-a7564f120d39> in <module>()
2 from pyganja import *
3
----> 4 draw([random_line() for i in range(10)])
3 frames
/usr/local/lib/python3.6/dist-packages/pyganja/script_api.py in _to_scene_string(objects)
256 if isinstance(objects, list):
257 sc = GanjaScene()
--> 258 sc.add_objects(objects, color=color, static=static)
259 return str(sc)
260 elif isinstance(objects, str):
NameError: name 'color' is not defined
Would recommend releasing during business hours next time ;)
See:
enkimute/ganja.js#35
Users would like the option of using 2D PGA and 2D CGA (and likely other algebras too), for example:
https://discourse.bivector.net/t/problems-displaying-ganja-pga-scenes-with-jupyter/346
MIT probably makes sense, as ganja.js
uses that.
Would be nice to have the readme contents here: https://pypi.org/project/pyganja/
There are some simple instructions about how to do that here: https://packaging.python.org/guides/making-a-pypi-friendly-readme/
Also it should be able to handle str(GanjaScene)
VSCode can directly open jupyter notebooks (https://code.visualstudio.com/docs/python/jupyter-support). However PyGanja's draw doesn't show up in them.
Finding pyganja works superbly in Jupyter notebooks,
but Jupyterlab places restriction against unmediated javascript.
Option is to write an extension, but thought to ask if you
have recommendation in this direction.
Thank you for your incredibly good work!
-ae-
Works locally, but when installed via PyPI gives:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\wiese\\AppData\\Roaming\\Python\\Python35\\site-packages\\pyganja/static/ganja.js/ganja.js'
Script does not have permission to write to the site-extensions directory, need to move away from files
In the case that a user does not have jupyter or cefpython we should simply generate html and point the users browser to that html
Continuation of pygae/clifford#170
The plots are no longer repeated, but they still appear in the wrong places: https://clifford.readthedocs.io/en/latest/Example%201%20Interpolating%20Conformal%20Objects.html
This is due to something like:
<script>
call_soon(()=>document.write("a"));
</script>
b
<script>
call_soon(()=>document.write("c"));
</script>
which can output bac
or even bca
depending on how call_soon
behaves (in this case, requirejs
)
See pygae/clifford#85
Example error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\projects\pyganja\pyganja\script_api.py", line 237, in draw
render_scene_string_appropriately(str(sc))
File "E:\projects\pyganja\pyganja\script_api.py", line 223, in render_scene_string_appropriately
render_cef_script(scene_string, sig=sig, grid=grid, scale=scale, gl=gl)
File "E:\projects\pyganja\pyganja\script_api.py", line 185, in render_cef_script
p.start()
File "E:\Miniconda3\envs\py3\lib\multiprocessing\process.py", line 105, in start
self._popen = self._Popen(self)
File "E:\Miniconda3\envs\py3\lib\multiprocessing\context.py", line 223, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "E:\Miniconda3\envs\py3\lib\multiprocessing\context.py", line 322, in _Popen
return Popen(process_obj)
File "E:\Miniconda3\envs\py3\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
reduction.dump(process_obj, to_child)
File "E:\Miniconda3\envs\py3\lib\multiprocessing\reduction.py", line 60, in dump
ForkingPickler(file, protocol).dump(obj)
AttributeError: Can't pickle local object 'render_cef_script.<locals>.render_script'
>>> Traceback (most recent call last):
File "<string>", line 1, in <module>
File "E:\Miniconda3\envs\py3\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "E:\Miniconda3\envs\py3\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.