Hello !
I was wondering if anyone has solved the problem of getting an image created in python to NetLogo’s import-xx primitives.
I imagine there are several possible approaches, but it seems like a common enough need that someone might have solved the problem already.
Any word of solutions?
Thanks!
-Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development
Hi Jeremy –
Thanks for your note! Clarification below…
In the py extension, there is only the py:runresult primitive for getting information back from python processes.
In the scenario I’m working with, I have created an image (actually, it’ll be many frames).. that I want to bring into netlogo via import-drawing and/or import-pcolors.
If I use py:runresult, I get an error that the image is not JSON serializable.
Have others run into this or similar problem & solved it?
Thanks!
-Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development
From:
<netlog...@googlegroups.com> on behalf of "jeremy...@northwestern.edu" <jeremy...@northwestern.edu>
Date: Monday, May 6, 2024 at 11:00 AM
To: netlogo-devel <netlog...@googlegroups.com>
Subject: [netlogo-devel] Re: Python returning image to NetLogo for "import-drawing" or "import-pcolors"
You don't often get email from jeremy...@northwestern.edu. Learn why this is important |
--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
netlogo-deve...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/netlogo-devel/573498f5-65f4-4312-81f8-41013412f1dbn%40googlegroups.com.
Hi Corey,
This is just a shot in the dark, as I don’t know the py extension code, but how about having your procedure return the file name of the image rather than the image itself.
--
Aaron Brandes, Software Developer
Center for Connected Learning and Computer-Based Modeling
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/3C0ACB63-9800-4600-AA23-FDCF69691100%40smu.edu.
That’s great: I’ll give that a try. Thanks! -Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development
From:
<netlog...@googlegroups.com> on behalf of "jeremy...@northwestern.edu" <jeremy...@northwestern.edu>
Date: Monday, May 6, 2024 at 12:47 PM
To: netlogo-devel <netlog...@googlegroups.com>
Subject: Re: [netlogo-devel] Re: Python returning image to NetLogo for "import-drawing" or "import-pcolors"
You don't often get email from jeremy...@northwestern.edu. Learn why this is important |
Okay, so if you have the image data available in the Python environment in the extension, then you can get it back to the NetLogo side by converting it to a base64 string, then using the ImportA Extension to put that data where you need it. The process for encoding it in base64 will vary depending on the format, but it should be an option as it's a common operation.
I hope that helps, let me know if you need more details.
-Jeremy
On Monday, May 6, 2024 at 12:13:18 PM UTC-5 Brady, Corey wrote:
Hi Jeremy –
Thanks for your note! Clarification below…
In the py extension, there is only the py:runresult primitive for getting information back from python processes.
In the scenario I’m working with, I have created an image (actually, it’ll be many frames).. that I want to bring into netlogo via import-drawing and/or import-pcolors.
If I use py:runresult, I get an error that the image is not JSON serializable.
Have others run into this or similar problem & solved it?
Thanks!
-Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development
From: <netlog...@googlegroups.com> on behalf of "jeremy...@northwestern.edu" <jeremy...@northwestern.edu>
Date: Monday, May 6, 2024 at 11:00 AM
To: netlogo-devel <netlog...@googlegroups.com>
Subject: [netlogo-devel] Re: Python returning image to NetLogo for "import-drawing" or "import-pcolors"
You don't often get email from jeremy...@northwestern.edu. Learn why this is important
Hey Corey,
Do you have more details on what the problem you're having is? What isn't working about just using the import primitives as-is? Do you mean importing image data that's generated in the Python extension in a NetLogo model, or just generally from Python?
Thanks.
-Jeremy
On Sunday, May 5, 2024 at 3:19:01 PM UTC-5 Brady, Corey wrote:
Hello !
I was wondering if anyone has solved the problem of getting an image created in python to NetLogo’s import-xx primitives.
I imagine there are several possible approaches, but it seems like a common enough need that someone might have solved the problem already.
Any word of solutions?
Thanks!
-Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development
Error! Filename not specified.
--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/573498f5-65f4-4312-81f8-41013412f1dbn%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
netlogo-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-devel/f99c09fe-c402-4900-8400-14bbf46a950bn%40googlegroups.com.
Hi Aaron – Thanks for your reply! I think/hope that the base64 option will be more performant, since I can avoid writing/reading to disk. Thanks! -Corey
Corey Brady
Associate Professor, Mathematics Education and the Learning Sciences
Department of Teaching and Learning
Simmons School of Education and Human Development