Skip to content
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

Fix output of nest.spatial in Read the Docs #2527

Merged
merged 10 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions doc/htmldoc/ref_material/pynest_apis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ Functions related to randomization
Functions related to spatial distributions
------------------------------------------

.. automodule:: nest.spatial.hl_api_spatial
:members:
.. automodule:: nest.spatial
:members: distance

.. automodule:: nest.spatial
:members:

.. automodule:: nest.spatial_distributions.hl_api_spatial_distributions
:members:
Expand Down
1 change: 1 addition & 0 deletions nestkernel/sparse_node_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ nest::SparseNodeArray::SparseNodeArray()
{
}


void
nest::SparseNodeArray::clear()
{
Expand Down
2 changes: 1 addition & 1 deletion pynest/nest/lib/hl_api_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def Create(model, n=1, params=None, positions=None):
- A list with n dictionaries, one dictionary for each node.
Values may be :py:class:`.Parameter` objects. If omitted,
the model's defaults are used.
positions: :py:class:`.spatial.grid` or :py:class:`.spatial.free` object, optional
positions: :py:class:`.grid` or :py:class:`.free` object, optional
Object describing spatial positions of the nodes. If omitted, the nodes have no spatial attachment.

Returns
Expand Down
27 changes: 27 additions & 0 deletions pynest/nest/spatial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,31 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

import functools as _functools
from .hl_api_spatial import * # noqa
from .hl_api_spatial import DistanceParameter as _DistanceParameter


@_functools.cache
def __getattr__(name):
if name == "distance":
return _DistanceParameter()
raise AttributeError(f"module {__name__} has no attribute {name}")


# Type annotation to hint at dynamic singleton of DistanceParameter()
distance: _DistanceParameter
"""
A singleton instance representing the distance between two nodes in space.

If used alone, the DistanceObject represents simply the Euclidean
distance between two nodes.

Alternatively the distance in a single dimension may be chosen. Three
properties are defined, x, y, and z, which represent the distance in
their respective dimensions. Note that the distance parameter can only
be used in contexts with two nodes, e.g. when connecting.
"""


__all__ = [attr for attr in vars().keys() if not attr.startswith("_")]
16 changes: 0 additions & 16 deletions pynest/nest/spatial/hl_api_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ..ll_api import sli_func

__all__ = [
'distance',
'grid',
'free',
'pos',
Expand All @@ -34,18 +33,6 @@


class DistanceParameter(Parameter):
"""
Object representing the distance between two nodes in space.

If used alone, the DistanceObject represents simply the Euclidean
distance between two nodes.

Alternatively the distance in a single dimension may be chosen. Three
properties are defined, x, y, and z, which represent the distance in
their respective dimensions. Note that the distance parameter can only
be used in contexts with two nodes, e.g. when connecting.
"""

def __init__(self):
distance_parameter = CreateParameter('distance', {})
super().__init__(distance_parameter._datum)
Expand Down Expand Up @@ -83,9 +70,6 @@ def n(dimension):
return CreateParameter('distance', {'dimension': dimension})


distance = DistanceParameter()


class pos:
"""
Position of node in a specific dimension.
Expand Down