示例#1
0
    def __new__(mcs, name, bases, namespace):
        """..."""
        logger = Logger(client="DataClassConstructor", level="STUDY")
        logger.study(
            """Construct new class with
            mcs {},
            name {},
            bases {}"""\
            .format(
                mcs, name, bases))
        logger.study("""namespace has data_base_class__? {}""".format(
            namespace.get("__data_base_class__", False)))
        if not namespace.get("__data_base_class__", False):
            if "index" not in namespace:
                logger.alert("""
                Provide class attribute 'index':
                A dict mapping the name of an index variable to its description.
                The names will be used to name the dataframe index,
                and the description to provide documentation.
                """)
                raise TypeError(
                    "Missing class attribute 'index' in class definition of '{}'"\
                    .format(name))
            if "measurements" not in namespace:
                logger.alert("""
                Provide class attribute 'measurements':
                A dict mapping the name of measurement variable to its description.
                The names will be used to name the dataframe columns, 
                and the description to provide documentation.
                """)
                raise TypeError(
                    "Missing class attribute 'measurements' in class definition of '{}'"\
                    .format(name))

        return super().__new__(mcs, name, bases, namespace)
示例#2
0
# You should have received a copy of the GNU Lesser General Public License along with
# DMT source-code.  If not, see <https://www.gnu.org/licenses/>.
"""
The connectome of a circuit.
"""

from tqdm import tqdm
import numpy as np
import pandas as pd
from dmt.tk.field import Field, WithFields, lazyfield
from dmt.tk.journal import Logger
from neuro_dmt import terminology
from .synapse import Synapse

LOGGER = Logger(client=__file__)


class Connection(WithFields):
    """
    A connection between two cells.
    A Connection instance will make sense only when defined for a circuit, as
    cells are tracked by their gid.
    """
    pre_gid = Field("""
        gid of the pre-synaptic cell.
        """)
    post_gid = Field("""
        gid of the post-synaptic cell.
        """)
    synapse_count = Field("""
示例#3
0
from ..builder import *
from . import test_composition
from .test_composition import *
from . import *
"""
TODO: The author of a document should enter the content as methods.
What should the arguments of these methods be?


In literate programming, code is embedded into written language.
With Python, we can leverage doc-strings to embed written language
part of a document into Python code.
A narrative should be added as the doc-string.
In this case this doc-string will appear in the abstract.
"""
LOGGER = Logger(client=__file__, level=Logger.Level.STUDY)


def test_context_management():
    """Test context management functionality of `DocumentBuilder`"""

    adapter = MockAdapter()
    model = MockModel()
    path_save = get_path_save().joinpath("context")
    path_save.mkdir(parents=False, exist_ok=True)

    with LabReportBuilder("Report") as document:
        assert document.title == "Report"
        assert document.abstract.document_builder == document

        report = Document("Report")
示例#4
0
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License along with
# DMT source-code.  If not, see <https://www.gnu.org/licenses/>. 

"""
Test develop mock circuit.
(An attempt at a loose approach towards test / behavior driven development.)
"""

import pandas as pd
from dmt.tk.journal import Logger
from .. import CircuitComposition, SimpleUniformRandomConnectivity

__log = Logger(client = "test develop mock circuit")

__layers = (1, 2, 3, 4, 5, 6)

__thickness_layer ={
    1: 122.3,
    2: 113.5,
    3: 302.9,
    4: 176.4,
    5: 477.9,
    6: 647.3}

__cell_density_layer ={
    1: 18566,
    2: 131561,
    3: 81203,
示例#5
0
文件: suite.py 项目: BlueBrain/DMT
from dmt.tk.author import Author
from dmt.tk.phenomenon import Phenomenon
from dmt.tk.plotting import LinePlot, HeatMap
from dmt.tk.plotting.multi import MultiPlot
from dmt.tk.parameters import Parameters
from dmt.data.observation import measurement
from neuro_dmt import terminology
from neuro_dmt.analysis.circuit import BrainCircuitAnalysis
from neuro_dmt.analysis.reporting import\
    CircuitAnalysisReport,\
    CheetahReporter
from neuro_dmt.utils import measurement_method
from neuro_dmt.utils.geometry import Cuboid
from neuro_dmt.analysis.circuit.tools import PathwayMeasurement

LOGGER = Logger(client=__file__, level="DEBUG")


class AdapterInterface(Interface):
    """
    Document the methods that will be used by this analysis to measure a
    circuit model. Users must adapt the functionality of their circuit model
    to provide the methods defined in this `Interface`. They may implement
    their adapter as a class or a module.
    """
    def get_provenance(self, circuit_model):
        """
        Provide a dictionary with following keys:

        1. label: that names the circuit model
        2. authors: group that built the circuit model
示例#6
0
from dmt.data.observation import measurement
from neuro_dmt.analysis.circuit import BrainCircuitAnalysis
from neuro_dmt.analysis.circuit.connectome.interfaces import\
    ConnectionProbabilityInterface,\
    ConnectionProbabilityBySomaDistanceInterface,\
    AfferentConnectionCountBySomaDistanceInterface,\
    AfferentConnectionCountInterface
from ...mock.circuit import MockBlueBrainCircuitModel
from ...mock.test.mock_circuit_light import\
    circuit_composition,\
    circuit_connectivity
from ...model import BlueBrainCircuitModel
from ...model.cell_type import CellType
from ...adapter import BlueBrainCircuitAdapter

logger = Logger(client="test connectome analysis.")

def test_atlas_method_mocks():
    """
    Mock for the `BlueBrainCircuitModel` should handle methods that would
    be delegated to an atlas by a real instance.
    """
    mock_circuit_model =\
        MockBlueBrainCircuitModel(
            circuit_composition,
            circuit_connectivity,
            label="BlueBrainCircuitModelMockLight")
    n_cells = mock_circuit_model.cells.shape[9]
    assert np.int32(mock_circuit_model.voxel_cell_count.sum()) == n_cells

示例#7
0
# the terms of the GNU Lesser General Public License version 3.0 as published by the
# Free Software Foundation.

# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

# You should have received a copy of the GNU Lesser General Public License along with
# DMT source-code.  If not, see <https://www.gnu.org/licenses/>.
"""
A mock circuit that we can use to test.
"""

import numpy as np
import pandas as pd
from dmt.tk.journal import Logger
from dmt.tk.field import Field, WithFields
from neuro_dmt.utils.geometry.roi import Cuboid
from .composition import CircuitComposition
from .connectivity import\
    CircuitConnectivity,\
    SimpleUniformRandomConnectivity,\
    SimpleUniformRandomConnectivityWithMtypeDependence
from .builder import CircuitBuilder
from .model import MockCircuitModel
from .adapter import MockCircuitAdapter
from .synapse import Synapse
from .cell import Cell

logger = Logger(client=__file__)