def test_erd_algebra(): erd0 = dj.ERD(B) erd1 = erd0 + 3 erd2 = dj.ERD(E) - 3 erd3 = erd1 * erd2 erd4 = (erd0 + E).add_parts() - B - E assert_true(erd0.nodes_to_show == set(cls.full_table_name for cls in [B])) assert_true(erd1.nodes_to_show == set(cls.full_table_name for cls in (B, B.C, E, E.F))) assert_true(erd2.nodes_to_show == set(cls.full_table_name for cls in (A, B, D, E, L))) assert_true(erd3.nodes_to_show == set(cls.full_table_name for cls in (B, E))) assert_true(erd4.nodes_to_show == set(cls.full_table_name for cls in (B.C, E.F)))
def test_erd(): assert_true(dj.diagram.diagram_active, "Failed to import networkx and pydot") erd = dj.ERD(schema, context=namespace) graph = erd._make_graph() assert_true( set(cls.__name__ for cls in (A, B, D, E, L)).issubset(graph.nodes()) )
def erd(*args): mods = (ephys, lab, experiment, tracking, psth, ccf, histology, report, publication) for mod in mods: modname = str().join(mod.__name__.split('.')[1:]) fname = os.path.join('images', '{}.png'.format(modname)) print('saving', fname) dj.ERD(mod, context={modname: mod}).save(fname)
def test_erd(): erd = dj.ERD(schema) graph = erd._make_graph(schema.context) assert_true( set(cls.__name__ for cls in (A, B, D, E, L)).issubset(graph.nodes())) pos = erd._layout(graph) assert_true( set(cls.__name__ for cls in (A, B, D, E, L)).issubset(pos.keys()))
imaging.Sync.Mesc, imaging.SystemConfig, imaging.SystemConfig.Tracking2D, imaging.SystemConfig.Tracking1D, imaging.SystemConfig.Sync, ) tables_fov = ( imaging.Scope, imaging.SystemConfig, imaging.Session, imaging.Session.SystemConfig, imaging.ImagingFOVRaw, imaging.ImagingFOVRaw.Beads, imaging.ImagingFOV, imaging.ImagingAnalysis, imaging.Cell, imaging.Cell.Rois, imaging.RoisCorr, imaging.Projection, imaging.ProjectionCorr, ) group = tables_fov d = dj.ERD(group[0]) for i in range(len(group[1:])): d += dj.ERD(group[i]) d # For some reason, this approach sometimes seems to skip the final table in the list. No idea why. fig.save(r"../../../docs/_static/imaging/schemas/erd_sync.png")
def erd(*args): for mod in (ephys, lab, experiment, tracking, psth, ccf, publication): modname = str().join(mod.__name__.split('.')[1:]) fname = os.path.join('pipeline', './images/{}.png'.format(modname)) print('saving', fname) dj.ERD(mod, context={modname: mod}).save(fname)
@author: thinh """ import os import re os.chdir('..') import h5py as h5 import numpy as np from decimal import Decimal import datajoint as dj from pipeline import reference, subject, acquisition, stimulation, analysis #, behavior, ephys, action from pipeline import utilities # Merge all schema and generate the overall ERD (then save in "/images") all_erd = dj.ERD(reference) + dj.ERD(subject) + dj.ERD(stimulation) + dj.ERD( acquisition) + dj.ERD( analysis) #+ dj.ERD(behavior) + dj.ERD(ephys) + dj.ERD(action) all_erd.save('./images/all_erd.png') acq_erd = dj.ERD(acquisition) acq_erd.save('./images/acquisition_erd.png') analysis_erd = dj.ERD(analysis) analysis_erd.save('./images/analysis_erd.png') # ================== Dataset ================== path = os.path.join('.', 'data', 'whole_cell_nwb2.0') fnames = os.listdir(path) for fname in fnames:
def test_make_image(): erd = dj.ERD(schema, context=namespace) img = erd.make_image() assert_true(img.ndim == 3 and img.shape[2] in (3, 4))
def test_repr_svg(): erd = dj.ERD(schema_advanced, context=namespace) svg = erd._repr_svg_() assert_true(svg.startswith('<svg') and svg.endswith('svg>'))
def test_erd(): erd = dj.ERD(schema, context=namespace) graph = erd._make_graph() assert_true( set(cls.__name__ for cls in (A, B, D, E, L)).issubset(graph.nodes()))
def erd(): """for convenience""" dj.ERD(schema).draw()
def print_erd(): _, schema = start_connection() dj.ERD(schema).draw()
def erd(*args): for mod in (ephys, lab, experiment, ccf,): modname = str().join(mod.__name__.split('.')[1:]) fname = os.path.join('pipeline', '{}.png'.format(modname)) print('saving', fname) dj.ERD(mod, context={modname: mod}).save(fname)
# Let's go ahead and work out the definition of the table. @schema class ActivityStatistics(dj.Computed): definition = """ -> Neuron --- mean: float # mean activity stdev: float # standard deviation of activity max: float # maximum activity """ # Did you notice that we are now inheriting from `dj.Computed`? `Computed` is yet another table tier that signifies that **the entries of this table are computed using data in other tables**. `Computed` tables are represented as red circles in the ERD. dj.ERD(schema) # Just like the `Imported` tables, `Computed` tables make use of the same `make` and `populate` logic for defining new entries in the table. Let's go ahead and implement `make` method. # + # ENTER YOUR CODE! - complete the `make` method @schema class ActivityStatistics(dj.Computed): definition = """ -> Neuron --- mean: float # mean activity stdev: float # standard deviation of activity max: float # maximum activity
def erd(): """a shortcut for convenience""" dj.ERD(schema).draw(prefix=False)
z: int = 5 """type: int""" class Stuff: """A regular Python class that does not use DataJoint. All of its attributes (that you want to use in DataJoint) must have type hints.""" other: OtherStuff = None x: int = 3 """type: int""" y: str = "something" """type: str""" # Set DataJoint definitions in each class based on inspection # of class attributes. set_dj_definition(Stuff) # Schematize each of these classes (will include foreign keys) from pyrfume.odorants import Molecule, Vendor, ChemicalOrder schema = dj.schema('u_%s_odorants' % dj.config['database.user'], locals()) for cls in [Molecule, Vendor, ChemicalOrder]: locals()[cls.__name__] = schematize(cls, schema) # May require a Jupyter notebook or other canvas dj.ERD(schema).draw()