mmontone / burgled-batteries.syntax Goto Github PK
View Code? Open in Web Editor NEWEmbedded Python syntax for burgled-batteries
License: MIT License
Embedded Python syntax for burgled-batteries
License: MIT License
Hello,
I'm runnning sbcl, newest version, burgled-batteries.syntax from quciklisp.
If i try to pass a double to some function b-b.syntax thinks it's a call to objects attribute.
'[numpy.sin(1.5d0)](BURGLED-BATTERIES.SYNTAX::CALL* %28BURGLED-BATTERIES.SYNTAX::REF*) "sin"
(PYTHON.CFFI:OBJECT.GET-ATTR*
(PYTHON.CFFI:NUMBER.INT* 1) "5d0"))
maybe I mistake, but still it would be a cool feature if would just work like this.
Best regargs,
Aleksey
Hi,
continuing improving this great dist.
Like the title says:
BURGLED-BATTERIES> (plot1)
BURGLED-BATTERIES> (plot1)
DEBUGGER:
Unhandled memory fault at #x1.
[Condition of type SB-SYS:MEMORY-FAULT-ERROR]
Restarts:
0: [RETRY] Retry SLIME REPL evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {10053B0033}>)
Backtrace:
0: (SB-SYS:MEMORY-FAULT-ERROR)
1: ("foreign function: call_into_lisp")
2: ("foreign function: post_signal_tramp")
3: ("foreign function: #x2011718BAA")
4: ((SB-PCL::EMF RUN*) # # "import matplotlib.pyplot as plt")
5: (RUN "import matplotlib.pyplot as plt")
6: ((FLET #:CLEANUP-FUN-0 :IN PLOT1)) [cleanup]
7: (PLOT1)
8: (SB-INT:SIMPLE-EVAL-IN-LEXENV (PLOT1) #)
9: (EVAL (PLOT1))
--more--
That thing doesnt happen if I work without the syntax, i.e. only in burgled-batteries package.
I think that importing the library is the problem. Somehow it seems that the function plot1 doesnt clean the symbol in the namespace which holds the matplotlib library after finishing. That also happens with other libraries you try to import inside a function.
I couldn't locate that error more precisely unfortunately.
Best regards,
Aleksey
Hello, me again.
I've found that arguments in calls to python functions are getting reverted somehow.
If I call the plot function of matplotlib.pyplot like this
(let* (($x (list 1.0d0 2.0d0 3.0d0 4.0d0)) ($y (map 'list #'(lambda (x) (* x x)) $x)))
(let (($plt [matplotlib.pyplot]))
(progn
[$plt.plot($x, $y, "-" , linewidth=5)]
[matplotlib.pyplot.show()])))
then plot is called as plot( '-', y, x, **kwargs) as you can see in the quoted output:
(LET* (($X (LIST 1.0d0 2.0d0 3.0d0 4.0d0))
($Y (MAP 'LIST #'(LAMBDA (X) (* X X)) $X)))
(LET (($PLT
(PYTHON.CFFI:OBJECT.GET-ATTR*
(BURGLED-BATTERIES.SYNTAX::REF* "matplotlib") "pyplot")))
(PROGN
(LET ((#:KWARGS1550 (MAKE-HASH-TABLE)))
(SETF (GETHASH "linewidth" #:KWARGS1550) (PYTHON.CFFI:NUMBER.INT* 5))
(BURGLED-BATTERIES::WITH-CPYTHON-POINTER (#:PYFUN1551
(PYTHON.CFFI:OBJECT.GET-ATTR-STRING*
$PLT "plot"))
(PYTHON.CFFI:OBJECT.CALL* #:PYFUN1551
(LIST (PYTHON.CFFI:STRING.FROM-STRING* "-")
$Y $X)
#:KWARGS1550)))
(BURGLED-BATTERIES.SYNTAX::CALL*
(PYTHON.CFFI:OBJECT.GET-ATTR*
(BURGLED-BATTERIES.SYNTAX::REF* "matplotlib") "pyplot")
"show"))))
On the other hand
(let* (($x (list 1.0d0 2.0d0 3.0d0 4.0d0)) ($y (map 'list #'(lambda (x) (* x x)) $x)))
(let (($plt [matplotlib.pyplot]))
(progn
[$plt.plot("-" , $x, $y, linewidth=5)]
[matplotlib.pyplot.show()])))
works perfectly fine.
Also I'd like to make a suggestion. It would be really nice to be able to define an *args list and a **kwarags hashtable and pass it to some python function, e.g. like this
(let* (($x (list 1.0d0 2.0d0 3.0d0 4.0d0)) ($y (map 'list #'(lambda (x) (* x x)) $x)))
(let (($plt [matplotlib.pyplot])
($args (list $x $y "-"))
($kwargs some-lisp-hashtable-with-arguments)
(progn
[$plt.plot(*$args, **$kwargs)]
[matplotlib.pyplot.show()])))
Many thanks for your software and in advance for yout help.
(N.B. I am trying solving numerical problems( FEM, finite volumes etc with lisp and C and do want to plot the solutions and other stuff. Unfortunately, the only plotting librarary suitable for pulbications ( ps-output, nice looking, many features) is matplotlib which is written in python. Therefore, very very nice to have your packages!!)
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.