How to use merlin - 10 common examples

To help you get started, we’ve selected a few merlin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyre / pyre / tests / merlin.pkg / components / merlin_curator.py View on Github external
def test():
    # access to the merlin executive
    from merlin import merlin

    # get the curator
    curator = merlin.curator
    # create a project description object
    project = merlin.newProject(name="test")
    # archive it
    curator.saveProject(project)
    # refresh the folder
    merlin.pfs['project'].discover()
    # and load it back in
    project = curator.loadProject()

    # check the name
    assert project.name == "test"

    # and return
    return project
github pyre / pyre / tests / merlin.pkg / components / merlin_spell.py View on Github external
def test():
    # access to the merlin executive
    from merlin import merlin
    # get the spellbook
    spellbook = merlin.spellbook

    # ask it to find a spell
    spell = spellbook.resolve(plexus=merlin, spec="sample")

    # and return
    return spell
github pyre / pyre / tests / merlin.pkg / components / merlin_packages.py View on Github external
def test():
    # access to the merlin executive
    from merlin import merlin

    # get the package manager
    packages = merlin.pyre_host.packager
    # check it is accessible
    assert packages

    # and return
    return packages
github pyre / pyre / tests / merlin.pkg / components / merlin_spell.py View on Github external
def test():
    # access to the merlin executive
    from merlin import merlin
    # get the spellbook
    spellbook = merlin.spellbook

    # ask it to find a spell
    spell = spellbook.resolve(plexus=merlin, spec="sample")

    # and return
    return spell
github emanuega / MERlin / merlin / analysis / testtask.py View on Github external
import numpy as np

from merlin.core import analysistask

'''This module contains dummy analysis tasks for running tests'''


class SimpleAnalysisTask(analysistask.AnalysisTask):

    def __init__(self, dataSet, parameters=None, analysisName=None):
        super().__init__(dataSet, parameters, analysisName)

    def _run_analysis(self):
        pass

    def get_estimated_memory(self):
        return 100

    def get_estimated_time(self):
        return 1

    def get_dependencies(self):
        if 'dependencies' in self.parameters:
            return self.parameters['dependencies']
github emanuega / MERlin / test / test_spatialfeature.py View on Github external
testCoords2 = [(0, 0), (2, 0), (2, 2), (0, 2), (0, 0)]

feature1 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)]], 0)
feature2 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords2)]], 0)
feature3 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords1)]],
                                         0, zCoordinates=np.array([0, 0.5]))
feature4 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords2)]],
                                         0, zCoordinates=np.array([0, 0.5]))

p1 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])]], 0)
p2 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1), (1, 1), (1, 0.5)])]], 0)
p3 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1.5), (1, 1.5), (1, 0.5)])]], 0)
p4 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 1), (0, 2), (1, 2), (1, 1)])]], 0)
p5 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(4, 4), (4, 5), (5, 5), (5, 4)])]], 0)
allCells = [p1, p2, p3, p4, p5]


def test_feature_from_label_matrix():
    testLabels = np.zeros((1, 4, 4))
    testLabels[0, 1:3, 1:3] = 1

    feature = spatialfeature.SpatialFeature.feature_from_label_matrix(
        testLabels, 0)

    assert len(feature.get_boundaries()[0]) == 1
github emanuega / MERlin / test / test_spatialfeature.py View on Github external
feature3 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords1)]],
                                         0, zCoordinates=np.array([0, 0.5]))
feature4 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords2)]],
                                         0, zCoordinates=np.array([0, 0.5]))

p1 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])]], 0)
p2 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1), (1, 1), (1, 0.5)])]], 0)
p3 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1.5), (1, 1.5), (1, 0.5)])]], 0)
p4 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 1), (0, 2), (1, 2), (1, 1)])]], 0)
p5 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(4, 4), (4, 5), (5, 5), (5, 4)])]], 0)
allCells = [p1, p2, p3, p4, p5]


def test_feature_from_label_matrix():
    testLabels = np.zeros((1, 4, 4))
    testLabels[0, 1:3, 1:3] = 1

    feature = spatialfeature.SpatialFeature.feature_from_label_matrix(
        testLabels, 0)

    assert len(feature.get_boundaries()[0]) == 1
    assert feature.get_boundaries()[0][0].equals(geometry.Polygon(
        list(zip([2.1, 2.1, 2.0, 1.0, 0.9, 0.9, 1.0, 2.0, 2.1],
                 [2.0, 1.0, 0.9, 0.9, 1.0, 2.0, 2.1, 2.1, 2.0]))))
github emanuega / MERlin / test / test_spatialfeature.py View on Github external
from merlin.util import spatialfeature


testCoords1 = [(1, 1), (1, 2), (2, 2), (2, 1), (1, 1)]
testCoords2 = [(0, 0), (2, 0), (2, 2), (0, 2), (0, 0)]

feature1 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)]], 0)
feature2 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords2)]], 0)
feature3 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords1)]],
                                         0, zCoordinates=np.array([0, 0.5]))
feature4 = spatialfeature.SpatialFeature([[geometry.Polygon(testCoords1)],
                                          [geometry.Polygon(testCoords2)]],
                                         0, zCoordinates=np.array([0, 0.5]))

p1 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0), (0, 1), (1, 1), (1, 0)])]], 0)
p2 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1), (1, 1), (1, 0.5)])]], 0)
p3 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 0.5), (0, 1.5), (1, 1.5), (1, 0.5)])]], 0)
p4 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(0, 1), (0, 2), (1, 2), (1, 1)])]], 0)
p5 = spatialfeature.SpatialFeature(
    [[geometry.Polygon([(4, 4), (4, 5), (5, 5), (5, 4)])]], 0)
allCells = [p1, p2, p3, p4, p5]


def test_feature_from_label_matrix():
    testLabels = np.zeros((1, 4, 4))
    testLabels[0, 1:3, 1:3] = 1
github emanuega / MERlin / merlin / plots / testplots.py View on Github external
import numpy as np
from matplotlib import pyplot as plt

from merlin.plots._base import AbstractPlot
from merlin.plots._base import PlotMetadata


class TestPlot(AbstractPlot):

    def __init__(self, analysisTask):
        super().__init__(analysisTask)

    def get_required_tasks(self):
        return {'test_task': 'all'}

    def get_required_metadata(self):
        return [TestPlotMetadata]

    def _generate_plot(self, inputTasks, inputMetadata):
        fig = plt.figure(figsize=(10, 10))
        plt.plot(inputMetadata['testplots/TestPlotMetadata'].get_mean_values(),
                 'x')
        return fig
github emanuega / MERlin / merlin / analysis / testtask.py View on Github external
pass

    def get_estimated_memory(self):
        return 100

    def get_estimated_time(self):
        return 1

    def get_dependencies(self):
        if 'dependencies' in self.parameters:
            return self.parameters['dependencies']
        else:
            return []


class SimpleParallelAnalysisTask(analysistask.ParallelAnalysisTask):

    def __init__(self, dataSet, parameters=None, analysisName=None):
        super().__init__(dataSet, parameters, analysisName)

    def _run_analysis(self, fragmentIndex):
        pass

    def get_estimated_memory(self):
        return 100

    def get_estimated_time(self):
        return 1

    def get_dependencies(self):
        if 'dependencies' in self.parameters:
            return self.parameters['dependencies']