sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.45k stars 481 forks source link

New package: Brian, a simulator for spiking neural networks #9675

Closed 09b1d729-77bf-490e-b469-c1103143400f closed 14 years ago

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago

I've created a Sage package from an already existing Python package called Brian (see http://www.briansimulator.org/ for more information). The description that is provided in this webpage is the following:

Brian is a simulator for spiking neural networks available on almost all platforms. The motivation for this project is that a simulator should not only save the time of processors, but also the time of scientists. It is easy to learn and use, highly flexible and easily extensible. The Brian package itself and simulations using it are all written in the Python programming language.

I'm not sure whether this package should be proposed as experimental or optional. For the moment I've put it as an experimental package. However, I think it could be optional, because as a Python package it has been widely tested and works perfectly, so I don't think there'll be a lot of problems as a Sage package. Please, let me know your opinion on that.

I must say I detected some problems with Brian units related to the Sage classes 'RealNumber' and 'Integer', so I created a patch so that when Brian is imported these two classes are redefined as follows:

RealNumber=float
Integer=int

This solves the problems.

I attach the .spkg here (I know it's better just to provide a link, but I don't have anywhere else to upload it to).

Please, let me know what you think!

CC: @mwhansen @sagetrac-mvngu @haraldschilly

Component: packages: experimental

Keywords: brian brain simulator neuronal dynamics

Author: Oriol Castejon

Reviewer: Karl-Dieter Crisman

Issue created by migration from https://trac.sagemath.org/ticket/9675

kcrisman commented 14 years ago
comment:2

Cool!
You may also want to see this thread on sage-devel about where to put spkgs.

As to the redefining, that seems... problematic. There are other Sage Python packages that must encounter the same problems - you may want to ask on the list about how they deal with this. (I suppose numpy and matplotlib would be likely candidates for this.)

What platforms does Brian work on out of the box?

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:3

Replying to @kcrisman:

Cool!
You may also want to see this thread on sage-devel about where to put spkgs.

Thanks, I didn't know about Google Code!

As to the redefining, that seems... problematic. There are other Sage Python packages that must encounter the same problems - you may want to ask on the list about how they deal with this. (I suppose numpy and matplotlib would be likely candidates for this.)

Yes, I'll give it a try, but I'm not sure if I'll be able to find another solution. I'll let you know.

What platforms does Brian work on out of the box?

Well, in the website they say: All platforms running Python, so at least Windows, Linux and Mac. I can't say more than that, as I've tried it just on Linux.

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:4

Replying to @kcrisman:

As to the redefining, that seems... problematic.

And turning of the preparser via:

preparser(false)

would also be problematic?

kcrisman commented 14 years ago
comment:5

Replying to @sagetrac-uri:

Replying to @kcrisman:

As to the redefining, that seems... problematic.

And turning of the preparser via:

preparser(false)

would also be problematic?

Well, the issues is that a lot of Sage would no longer work as advertised. That is fine if one is only using Brian, but presumably the point of having Brian as an optional package is that one could go back and forth with other parts of Sage. I don't know exactly what other such packages do, though. I highly suggest just emailing sage-devel (perhaps in reply to your original message) and asking what ways around this there are; I assume they exist. Good luck!

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:6

Finally, Brian developers helped me to find a way to solve the problem without needing to redefine any Sage class nor to turn off the preparser. I've upload it on Google Code, you can download it here. However, I'll re-upload it here in Trac page to avoid confusions.

kcrisman commented 14 years ago

Reviewer: Karl-Dieter Crisman

kcrisman commented 14 years ago
comment:7

This seems to build fine, the script is ok. In terms of experimental, positive review - it didn't crash anything, and commands actually do things and give output that is consistent with it.

To release manager - what happens now? It gets uploaded to the Sage mirrors as experimental package, maybe? Who does that?

But in the interests of improving it - I don't see why this couldn't be an optional package, if you can find another potential maintainer (different ticket). If so, you'd definitely want to have a SPKG-TEST file or whatever, since there are builtin tests. But...

When I do

sage: import brian
sage: brian.tests()

I get that I'm missing nose. I doubt that nose will be a Sage package anytime soon - or should it, if it makes tests that much easier? Perhaps upstream would consider having a non-nose option for testing.

When I try the brian website examples, it tells me that the Sage matplotlib backend doesn't support show(). That would be another thing to figure out.

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:8

The package has unchecked-in changes:

$ hg stat
? .hgignore
? SPKG.txt
? patches/units.py
? patches/units.py.patch
? spkg-install

Oriol, could you add these files to the repository and commit the changes with the ticket number in the commit string.

Also, could you please add yourself to the account name-real name map? Thanks!

kcrisman commented 14 years ago
comment:9

Oh, I'm so sorry, Mitesh - here I was checking whether the spkg worked but forgot to actually rebuild the spkg from its constituents. If I ran sage-pkg on it would it have shown this?

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:10

Replying to @qed777:

The package has unchecked-in changes:

$ hg stat
? .hgignore
? SPKG.txt
? patches/units.py
? patches/units.py.patch
? spkg-install

Oriol, could you add these files to the repository and commit the changes with the ticket number in the commit string.

Ok, done. Please, let me know if it's allright, it's the first time I added files to the repository and I want to be sure I did everything correctly.

Also, could you please add yourself to the account name-real name map?

Done!

Thanks!

Thanks to you for your commments!!

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:11

Replying to @kcrisman:

But in the interests of improving it - I don't see why this couldn't be an optional package, if you can find another potential maintainer (different ticket). If so, you'd definitely want to have a SPKG-TEST file or whatever, since there are builtin tests. But...

When I do

sage: import brian
sage: brian.tests()

I get that I'm missing nose. I doubt that nose will be a Sage package anytime soon - or should it, if it makes tests that much easier? Perhaps upstream would consider having a non-nose option for testing.

I don't really know what to say about that... I don't know nose and haven't looked at these tests much. I'll think about it, though. However, is it really necessary to include tests on the packages, in order to be set as optional instead of experimental?

When I try the brian website examples, it tells me that the Sage matplotlib backend doesn't support show(). That would be another thing to figure out.

Yes, I had already seen that. The problem is not in Brian but in the matplotlib package itself... there're other ways to see the images, for example replacing the show() command for:

sage: savefig('figure.png')

which creates the file figure.png in the working directory. Maybe that should be specified in the documentation. What do you think?

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:12

Replying to @sagetrac-uri:

Replying to @qed777:

Oriol, could you add these files to the repository and commit the changes with the ticket number in the commit string.

Ok, done. Please, let me know if it's allright, it's the first time I added files to the repository and I want to be sure I did everything correctly.

I apologize if I've missed it, but is there a link to the updated package?

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:13

Replying to @qed777:

I apologize if I've missed it, but is there a link to the updated package?

You can download it clicking here, but it's the same link I provided before (there's been no update, I just added the files to the repository).

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:14

Replying to @sagetrac-uri:

..but it's the same link I provided before (there's been no update, I just added the files to the repository).

ok, just to avoid confusions, what I mean by that is that the link is the same because I didn't change the name of the package (from brian-1.2.1.p0 to brian-1.2.1.p1) because there's been no update. So you'll download the right file with the old link.

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago

Brian package (.spkg file)

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:15

Attachment: brian-1.2.1.p0.spkg.gz

kcrisman commented 14 years ago
comment:16

# 9221 is related (making nose an optional/standard package).

kcrisman commented 14 years ago
comment:17

Okay, I checked this all out again, and now the HG is fine, and I can't find any garbage files, and it still applies fine to Sage 4.5.3, and I think this is more than ready to be an experimental package.

If you want, you can find people to test it on a couple other platforms to make sure it's ready for optional package status - I'm not sure exactly what the protocol for that is, though it seems to me that it's more than ready compared to other denizens of http://www.sagemath.org/packages/optional/. But that could also be another ticket. At the very least it should get loaded up to the mirrors. Make it so!

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:18

Harald, Mike, or Minh, could one of you add attachment: brian-1.2.1.p0.spkg to the experimental / contributed package repository?

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:19

Replying to @kcrisman:

# 9221 is related (making nose an optional/standard package).

Small correction: #9921 is about this, though there is a discussion about nose at #9221.

kcrisman commented 14 years ago
comment:20

Replying to @qed777:

Replying to @kcrisman:

# 9221 is related (making nose an optional/standard package).

Small correction: #9921 is about this, though there is a discussion about nose at #9221.

Aagh! That's the same mistake Jason made on #9221 in referring (or not) to #9921... sorry.

7c09a680-e216-4024-bb8e-9bfd4aa7f313 commented 14 years ago
comment:21

Replying to @qed777:

Harald, Mike, or Minh, could one of you add attachment: brian-1.2.1.p0.spkg to the experimental / contributed package repository?

Done. See

http://www.sagemath.org/packages/experimental/

e14f4152-4982-4ace-8c95-73a0599b109b commented 14 years ago
comment:22

Thanks, Minh!

09b1d729-77bf-490e-b469-c1103143400f commented 14 years ago
comment:23

Great, thank you all! I'll open a new ticket to see if it can be accepted as an optional package.

5d2aaf09-c963-473a-bf79-1f742a72700f commented 14 years ago
comment:24

There's been some discussion on other tickets about the virtues of nose, so it might not be that unlikely to make it standard in Sage.