New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for spatial kernels in topology (depends on #823). #929

Merged
merged 8 commits into from Apr 19, 2018

Conversation

Projects
None yet
3 participants
@heplesser
Contributor

heplesser commented Apr 17, 2018

This PR adds test for spatial kernels to NEST, based on code from Daniel Hjertholm's master thesis.

It can only be merged once #823 is merged, since it requires the gamma kernel.

@babsey Could you also review?

@stinebuu

Great to have a test for the kernels, that is certainly needed! This looks mostly good, however I do wonder if the plotting really should be included. I do see the need for it if new kernels are included, but the test file is already quite long, the SpacialTester class is in particular long, and at least as far as I am aware, we usually reserve plotting etc for examples and not for tests?

Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py
class SpatialTester(object):
'''Tests for spatially structured networks.'''

This comment has been minimized.

@stinebuu

stinebuu Apr 18, 2018

Contributor

Could you add a comment somewhere explaining that this is a base class? I was quite confused about why the class contained functions that was not implemented, I hadn't seen that the file contains several classes that builds on this and that they have the implementations of the functions.

@stinebuu

stinebuu Apr 18, 2018

Contributor

Could you add a comment somewhere explaining that this is a base class? I was quite confused about why the class contained functions that was not implemented, I hadn't seen that the file contains several classes that builds on this and that they have the implementations of the functions.

This comment has been minimized.

@heplesser

heplesser Apr 18, 2018

Contributor

Removed the subclass.

@heplesser

heplesser Apr 18, 2018

Contributor

Removed the subclass.

Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py
Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py

heplesser added a commit that referenced this pull request Apr 18, 2018

Merge pull request #823 from babsey/Topology_gamma_kernel
Add gamma kernel in topology. Test will follow with #929.
@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Apr 18, 2018

Contributor

@stinebuu I have restructured and simplified the code. I decided to keep the plotting in for now (but split it out into a separate subclass), since code placement would otherwise have become a bit problematic when supporting a test without plotting and an example with plotting. I have also merged all recent changes from master, so #823 with the gamma kernel is now included.

Contributor

heplesser commented Apr 18, 2018

@stinebuu I have restructured and simplified the code. I decided to keep the plotting in for now (but split it out into a separate subclass), since code placement would otherwise have become a bit problematic when supporting a test without plotting and an example with plotting. I have also merged all recent changes from master, so #823 with the gamma kernel is now included.

@babsey

This comment has been minimized.

Show comment
Hide comment
@babsey

babsey Apr 18, 2018

Contributor

Thank you for asking me to review it.
I had a great opportunity to review 790 lines. Please forgive me for taking some time. 😄

Some technical points concerning me are:

  • DEBUG_MODE is on. I assume it should be off.
  • the code has functions (sqrt,exp) from math and some from numpy
  • np.sum could be faster than sum.

I do not consider the correct outcome of the spatial testing because I trust @heplesser and @stine that this testing suite is working.

Contributor

babsey commented Apr 18, 2018

Thank you for asking me to review it.
I had a great opportunity to review 790 lines. Please forgive me for taking some time. 😄

Some technical points concerning me are:

  • DEBUG_MODE is on. I assume it should be off.
  • the code has functions (sqrt,exp) from math and some from numpy
  • np.sum could be faster than sum.

I do not consider the correct outcome of the spatial testing because I trust @heplesser and @stine that this testing suite is working.

@heplesser heplesser requested a review from babsey Apr 18, 2018

@stinebuu

@heplesser thank you, the code is a lot more readable to me now, and I like the solution with the plotting. I have two small comments, but otherwise approve.

# for debugging
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
# make sure we can open a window; DISPLAY may not be set

This comment has been minimized.

@stinebuu

stinebuu Apr 18, 2018

Contributor

What does DISPLAY refer to?

@stinebuu

stinebuu Apr 18, 2018

Contributor

What does DISPLAY refer to?

This comment has been minimized.

@babsey

babsey Apr 18, 2018

Contributor

It's an environment variable for X11 programs. You can check yours in terminal.
echo $DISPLAY

In this case matplotlib needs to have DISPLAY environment for opening a window.

@babsey

babsey Apr 18, 2018

Contributor

It's an environment variable for X11 programs. You can check yours in terminal.
echo $DISPLAY

In this case matplotlib needs to have DISPLAY environment for opening a window.

This comment has been minimized.

@stinebuu

stinebuu Apr 18, 2018

Contributor

Nice!

@stinebuu

stinebuu Apr 18, 2018

Contributor

Nice!

Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py
@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Apr 18, 2018

Contributor

@babsey I have now also explicitly added as a reviewer, so you get a nice "Submit review" button with "comment/require changes/approve" radio buttons to click :).

  • DEBUG_MODE is off now, I accidentally pushed a version with it on first.
  • I will use math everywhere except where I really need NumPy. The complicated case distinctions in _pdf operate on scalars only, and for them math versions are faster than np versions of mathematical functions.
  • Since the operands to sum() are lists, not arrays, I think np.sum() would not make much of a difference. Anyways, the main optimization potential for these tests is in _pdf and _cdf, but that will need to wait till another time.

I will push in a little while.

Contributor

heplesser commented Apr 18, 2018

@babsey I have now also explicitly added as a reviewer, so you get a nice "Submit review" button with "comment/require changes/approve" radio buttons to click :).

  • DEBUG_MODE is off now, I accidentally pushed a version with it on first.
  • I will use math everywhere except where I really need NumPy. The complicated case distinctions in _pdf operate on scalars only, and for them math versions are faster than np versions of mathematical functions.
  • Since the operands to sum() are lists, not arrays, I think np.sum() would not make much of a difference. Anyways, the main optimization potential for these tests is in _pdf and _cdf, but that will need to wait till another time.

I will push in a little while.

Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py
Show outdated Hide outdated topology/pynest/tests/test_spatial_kernels.py
(math.sqrt(2) * math.log((.1 - 0) / 1))},
'gaussian': {'p_center': 1., 'sigma': self._L / 4.,
'mean': 0., 'c': 0.},
'gamma': {'kappa': 3., 'theta': self._L / 4.}}

This comment has been minimized.

@babsey

babsey Apr 18, 2018

Contributor

I tested it, an adequate parameter set for gamma would be
'gamma': {'kappa': 4., 'theta': self._L / 20.}}

@babsey

babsey Apr 18, 2018

Contributor

I tested it, an adequate parameter set for gamma would be
'gamma': {'kappa': 4., 'theta': self._L / 20.}}

This comment has been minimized.

@heplesser

heplesser Apr 18, 2018

Contributor

In which sense adequate? Wouldn't essentially any parameter set with kappa != 1 be useful?

@heplesser

heplesser Apr 18, 2018

Contributor

In which sense adequate? Wouldn't essentially any parameter set with kappa != 1 be useful?

This comment has been minimized.

@babsey

babsey Apr 18, 2018

Contributor

You are right, it is a personal view.

@babsey

babsey Apr 18, 2018

Contributor

You are right, it is a personal view.

@babsey

This comment has been minimized.

Show comment
Hide comment
@babsey

babsey Apr 18, 2018

Contributor

The Travis passed. I also approve the merger.

Contributor

babsey commented Apr 18, 2018

The Travis passed. I also approve the merger.

@heplesser heplesser merged commit ea137fb into nest:master Apr 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@heplesser heplesser deleted the heplesser:spatial_kernel_test branch Apr 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment