Skip to content

Commit

Permalink
Prepare for release 1.0.7 (#225)
Browse files Browse the repository at this point in the history
- Fix changelog
- Fix docs formatting
- More tests for _logical_and and _logical_or
  • Loading branch information
GianlucaFicarelli authored Jun 23, 2023
1 parent c833b8e commit f205a75
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 61 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ New Features
~~~~~~~~~~~~
- Added ``CircuitIds.intersection`` to take the intersection of two ``CircuitIds``.

Improvements
~~~~~~~~~~~~
- Improve performance when querying a population with get() and ids().

Bug Fixes
~~~~~~~~~
- Fix CircuitIds.sample() to always return different samples.
- Ensure that the report DataFrames have the same schema even when empty.
- Improve performance when querying a population with get() and ids().

Version v1.0.6
--------------
Expand Down
8 changes: 5 additions & 3 deletions bluepysnap/_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,13 @@ def spikes_firing_animation(
ax(matplotlib.Axis): matplotlib Axis to draw on (if not specified, pyplot.gca()
and plt.figure() are used).
Returns :
Returns:
(matplotlib.animation.FuncAnimation, matplotlib.Axis): the matplotlib animation object and
the corresponding axis.
the corresponding axis.
Notes:
Examples:
From scripts:
>>> import matplotlib.pyplot as plt
>>> from bluepysnap import Simulation
>>> report = Simulation("config.json").spikes["my_population"]
Expand All @@ -262,6 +263,7 @@ def spikes_firing_animation(
>>> # to save the animation : do not plt.show() and just anim.save('my_movie.mp4')
From notebooks:
>>> from IPython.display import HTML
>>> from bluepysnap import Simulation
>>> report = Simulation("config.json").spikes["my_population"]
Expand Down
40 changes: 21 additions & 19 deletions bluepysnap/edges/edge_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def _topology_property_names(self):
def config(self):
"""Access the configuration for the population.
This configuration is extended with
This configuration is extended with:
* 'components' of the circuit config
* 'edges_file': the path the h5 file containing the population.
"""
Expand Down Expand Up @@ -154,7 +155,7 @@ def container_property_names(self, container):
Returns:
list: A list of strings corresponding to the properties that you can use from the
container class
container class
Examples:
>>> from bluepysnap.sonata_constants import Edge
Expand Down Expand Up @@ -244,6 +245,7 @@ def ids(self, group=None, limit=None, sample=None, raise_missing_property=True):
Args:
group (None/int/CircuitEdgeId/CircuitEdgeIds/sequence): Which IDs will be
returned depends on the type of the ``group`` argument:
- ``None``: return all IDs.
- ``int``, ``CircuitEdgeId``: return a single edge ID.
- ``CircuitEdgeIds`` return IDs of edges the edge population in an array.
Expand Down Expand Up @@ -299,8 +301,8 @@ def get(self, edge_ids, properties):
Returns:
pandas.Series/pandas.DataFrame:
A pandas Series indexed by edge IDs if ``properties`` is scalar.
A pandas DataFrame indexed by edge IDs if ``properties`` is list.
- A pandas Series indexed by edge IDs if ``properties`` is scalar.
- A pandas DataFrame indexed by edge IDs if ``properties`` is list.
Notes:
The EdgePopulation.property_names function will give you all the usable properties
Expand Down Expand Up @@ -394,9 +396,9 @@ def pathway_edges(self, source=None, target=None, properties=None):
properties: None / edge property name / list of edge property names
Returns:
List of edge IDs, if ``properties`` is None;
Pandas Series indexed by edge IDs if ``properties`` is string;
Pandas DataFrame indexed by edge IDs if ``properties`` is list.
- List of edge IDs, if ``properties`` is None;
- Pandas Series indexed by edge IDs if ``properties`` is string;
- Pandas DataFrame indexed by edge IDs if ``properties`` is list.
"""
if source is None and target is None:
raise BluepySnapError("Either `source` or `target` should be specified")
Expand Down Expand Up @@ -424,9 +426,9 @@ def afferent_edges(self, node_id, properties=None):
Returns:
pandas.Series/pandas.DataFrame/list:
A pandas Series indexed by edge ID if ``properties`` is a string.
A pandas DataFrame indexed by edge ID if ``properties`` is a list.
A list of edge IDs, if ``properties`` is None.
- A pandas Series indexed by edge ID if ``properties`` is a string.
- A pandas DataFrame indexed by edge ID if ``properties`` is a list.
- A list of edge IDs, if ``properties`` is None.
"""
return self.pathway_edges(source=None, target=node_id, properties=properties)

Expand All @@ -438,9 +440,9 @@ def efferent_edges(self, node_id, properties=None):
properties: None / edge property name / list of edge property names
Returns:
List of edge IDs, if ``properties`` is None;
Pandas Series indexed by edge IDs if ``properties`` is string;
Pandas DataFrame indexed by edge IDs if ``properties`` is list.
- List of edge IDs, if ``properties`` is None;
- Pandas Series indexed by edge IDs if ``properties`` is string;
- Pandas DataFrame indexed by edge IDs if ``properties`` is list.
"""
return self.pathway_edges(source=node_id, target=None, properties=properties)

Expand All @@ -453,9 +455,9 @@ def pair_edges(self, source_node_id, target_node_id, properties=None):
properties: None / edge property name / list of edge property names
Returns:
List of edge IDs, if ``properties`` is None;
Pandas Series indexed by edge IDs if ``properties`` is string;
Pandas DataFrame indexed by edge IDs if ``properties`` is list.
- List of edge IDs, if ``properties`` is None;
- Pandas Series indexed by edge IDs if ``properties`` is string;
- Pandas DataFrame indexed by edge IDs if ``properties`` is list.
"""
return self.pathway_edges(
source=source_node_id, target=target_node_id, properties=properties
Expand Down Expand Up @@ -554,9 +556,9 @@ def iter_connections(
``return_edge_count`` and ``return_edge_ids`` are mutually exclusive.
Yields:
(source_node_id, target_node_id, edge_ids) if return_edge_ids == True;
(source_node_id, target_node_id, edge_count) if return_edge_count == True;
(source_node_id, target_node_id) otherwise.
- (source_node_id, target_node_id, edge_ids) if ``return_edge_ids`` is True;
- (source_node_id, target_node_id, edge_count) if ``return_edge_count`` is True;
- (source_node_id, target_node_id) otherwise.
"""
if return_edge_ids and return_edge_count:
raise BluepySnapError(
Expand Down
45 changes: 23 additions & 22 deletions bluepysnap/edges/edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ def ids(self, group=None, sample=None, limit=None):
Args:
group (None/int/CircuitEdgeId/CircuitEdgeIds/sequence): Which IDs will be
returned depends on the type of the ``group`` argument:
returned depends on the type of the ``group`` argument:
- ``None``: return all CircuitEdgeIds.
- ``CircuitEdgeId``: return the ID in a CircuitEdgeIds object.
- ``CircuitEdgeIds``: return the IDs in a CircuitNodeIds object.
- ``int``: returns a CircuitEdgeIds object containing the corresponding edge ID
for all populations.
for all populations.
- ``sequence``: returns a CircuitEdgeIds object containing the corresponding edge
IDs for all populations.
IDs for all populations.
sample (int): If specified, randomly choose ``sample`` number of
IDs from the match result. If the size of the sample is greater than
the size of all the EdgePopulations then all ids are taken and shuffled.
Expand All @@ -68,8 +69,8 @@ def ids(self, group=None, sample=None, limit=None):
Returns:
CircuitEdgeIds: returns a CircuitEdgeIds containing all the edge IDs and the
corresponding populations. For performance reasons we do not test if the edge ids
are present or not in the circuit.
corresponding populations. For performance reasons we do not test if the edge ids
are present or not in the circuit.
Notes:
This envision also the maybe future selection of edges on queries.
Expand All @@ -91,8 +92,8 @@ def get(self, edge_ids=None, properties=None): # pylint: disable=arguments-rena
Returns:
pandas.Series/pandas.DataFrame:
A pandas Series indexed by edge IDs if ``properties`` is scalar.
A pandas DataFrame indexed by edge IDs if ``properties`` is list.
- A pandas Series indexed by edge IDs if ``properties`` is scalar.
- A pandas DataFrame indexed by edge IDs if ``properties`` is list.
Notes:
The Edges.property_names function will give you all the usable properties
Expand Down Expand Up @@ -171,9 +172,9 @@ def pathway_edges(self, source=None, target=None, properties=None):
properties: None / edge property name / list of edge property names
Returns:
CircuitEdgeIDs, if ``properties`` is None;
Pandas Series indexed by CircuitEdgeIDs if ``properties`` is string;
Pandas DataFrame indexed by CircuitEdgeIDs if ``properties`` is list.
- CircuitEdgeIDs, if ``properties`` is None;
- Pandas Series indexed by CircuitEdgeIDs if ``properties`` is string;
- Pandas DataFrame indexed by CircuitEdgeIDs if ``properties`` is list.
"""
if source is None and target is None:
raise BluepySnapError("Either `source` or `target` should be specified")
Expand All @@ -198,9 +199,9 @@ def afferent_edges(self, node_id, properties=None):
Returns:
pandas.Series/pandas.DataFrame/list:
A pandas Series indexed by edge ID if ``properties`` is a string.
A pandas DataFrame indexed by edge ID if ``properties`` is a list.
A list of edge IDs, if ``properties`` is None.
- A pandas Series indexed by edge ID if ``properties`` is a string.
- A pandas DataFrame indexed by edge ID if ``properties`` is a list.
- A list of edge IDs, if ``properties`` is None.
"""
return self.pathway_edges(source=None, target=node_id, properties=properties)

Expand All @@ -212,9 +213,9 @@ def efferent_edges(self, node_id, properties=None):
properties: None / edge property name / list of edge property names
Returns:
List of edge IDs, if ``properties`` is None;
Pandas Series indexed by edge IDs if ``properties`` is string;
Pandas DataFrame indexed by edge IDs if ``properties`` is list.
- List of edge IDs, if ``properties`` is None;
- Pandas Series indexed by edge IDs if ``properties`` is string;
- Pandas DataFrame indexed by edge IDs if ``properties`` is list.
"""
return self.pathway_edges(source=node_id, target=None, properties=properties)

Expand All @@ -227,9 +228,9 @@ def pair_edges(self, source_node_id, target_node_id, properties=None):
properties: None / edge property name / list of edge property names
Returns:
List of edge IDs, if ``properties`` is None;
Pandas Series indexed by edge IDs if ``properties`` is string;
Pandas DataFrame indexed by edge IDs if ``properties`` is list.
- List of edge IDs, if ``properties`` is None;
- Pandas Series indexed by edge IDs if ``properties`` is string;
- Pandas DataFrame indexed by edge IDs if ``properties`` is list.
"""
return self.pathway_edges(
source=source_node_id, target=target_node_id, properties=properties
Expand Down Expand Up @@ -282,9 +283,9 @@ def iter_connections(
``return_edge_count`` and ``return_edge_ids`` are mutually exclusive.
Yields:
(source_node_id, target_node_id, edge_ids) if return_edge_ids == True;
(source_node_id, target_node_id, edge_count) if return_edge_count == True;
(source_node_id, target_node_id) otherwise.
- (source_node_id, target_node_id, edge_ids) if ``return_edge_ids`` is True;
- (source_node_id, target_node_id, edge_count) if ``return_edge_count`` is True;
- (source_node_id, target_node_id) otherwise.
"""
if return_edge_ids and return_edge_count:
raise BluepySnapError(
Expand Down
7 changes: 4 additions & 3 deletions bluepysnap/frame_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ def report(self):
Returns:
pandas.DataFrame: A DataFrame containing the data from the report. Row's indices are the
different timestamps and the column's MultiIndex are :
- (population_name, node_id, compartment id) for the CompartmentReport
- (population_name, node_id) for the SomaReport
different timestamps and the column's MultiIndex are:
- (population_name, node_id, compartment id) for the CompartmentReport
- (population_name, node_id) for the SomaReport
"""
dataframes = {}
for population in self.frame_report.population_names:
Expand Down
5 changes: 3 additions & 2 deletions bluepysnap/nodes/node_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def target_in_edges(self):
def config(self):
"""Access the configuration for the population.
This configuration is extended with
This configuration is extended with:
* 'components' of the circuit config
* 'nodes_file': the path the h5 file containing the population.
"""
Expand All @@ -273,7 +274,7 @@ def container_property_names(self, container):
Returns:
list: A list of strings corresponding to the properties that you can use from the
container class
container class
Examples:
>>> from bluepysnap.sonata_constants import Node
Expand Down
21 changes: 11 additions & 10 deletions bluepysnap/nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,21 @@ def ids(self, group=None, sample=None, limit=None):
Args:
group (CircuitNodeId/CircuitNodeIds/int/sequence/str/mapping/None): Which IDs will be
returned depends on the type of the ``group`` argument:
returned depends on the type of the ``group`` argument:
- ``CircuitNodeId``: return the ID in a CircuitNodeIds object if it belongs to
the circuit.
the circuit.
- ``CircuitNodeIds``: return the IDs in a CircuitNodeIds object if they belong to
the circuit.
the circuit.
- ``int``: if the node ID is present in all populations, returns a CircuitNodeIds
object containing the corresponding node ID for all populations.
object containing the corresponding node ID for all populations.
- ``sequence``: if all the values contained in the sequence are present in all
populations, returns a CircuitNodeIds object containing the corresponding node
IDs for all populations.
populations, returns a CircuitNodeIds object containing the corresponding node
IDs for all populations.
- ``str``: use a node set name as input. Returns a CircuitNodeIds object containing
nodes selected by the node set.
nodes selected by the node set.
- ``mapping``: Returns a CircuitNodeIds object containing nodes matching a
properties filter.
properties filter.
- ``None``: return all node IDs of the circuit in a CircuitNodeIds object.
sample (int): If specified, randomly choose ``sample`` number of
IDs from the match result. If the size of the sample is greater than
Expand All @@ -83,8 +84,8 @@ def ids(self, group=None, sample=None, limit=None):
Returns:
CircuitNodeIds: returns a CircuitNodeIds containing all the node IDs and the
corresponding populations. All the explicitly requested IDs must be present inside
the circuit.
corresponding populations. All the explicitly requested IDs must be present inside
the circuit.
Raises:
BluepySnapError: when a population from a CircuitNodeIds is not present in the circuit.
Expand Down
2 changes: 1 addition & 1 deletion bluepysnap/spike_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def report(self):
Returns:
pandas.DataFrame: A DataFrame containing the data from the report. Row's indices are the
different timestamps and the columns are ids and population names.
different timestamps and the columns are ids and population names.
"""
res = pd.DataFrame()
for population in self.spike_report.population_names:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def test_resolve_ids():
([np.array([False])], np.array([False])),
([np.array([True, True]), np.array([True, False])], np.array([True, False])),
([np.array([100, 100]), np.array([True, False])], np.array([True, False])),
([pd.Series([100, 100]), np.array([True, False])], np.array([True, False])),
(
[np.array([True, False, True, False]), np.array([True, True, False, False])],
np.array([True, False, False, False]),
Expand Down Expand Up @@ -112,6 +113,7 @@ def test__logical_and(masks, expected):
([np.array([False])], np.array([False])),
([np.array([True, True]), np.array([True, False])], np.array([True, True])),
([np.array([100, 100]), np.array([True, False])], np.array([True, True])),
([pd.Series([100, 100]), np.array([True, False])], np.array([True, True])),
(
[np.array([True, False, True, False]), np.array([True, True, False, False])],
np.array([True, True, True, False]),
Expand Down

0 comments on commit f205a75

Please sign in to comment.