Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
701bf76
fix #483 and #516: .proj() preserves original order. Also rename cla…
dimitri-yatsenko Nov 13, 2018
38f1dba
Merge branch 'dev'
dimitri-yatsenko Nov 13, 2018
08e61e6
complete renaming query -> expression
dimitri-yatsenko Nov 13, 2018
025dd93
rename class Expression -> QueryExpression
dimitri-yatsenko Nov 13, 2018
1d5b593
add test for create_virtual_module and for issue #516
dimitri-yatsenko Nov 13, 2018
f0c8b8f
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Nov 13, 2018
a348758
fix doc strings to use QueryExpression
dimitri-yatsenko Nov 13, 2018
8edb4d7
add test for QueryExpression iterator
dimitri-yatsenko Nov 13, 2018
85dca73
finish renaming query -> expression in fetch.py
dimitri-yatsenko Nov 13, 2018
470682a
update version and CHANGELOG for release 0.11.1
dimitri-yatsenko Nov 13, 2018
65ea0e7
minor
dimitri-yatsenko Nov 13, 2018
8cca325
minor
dimitri-yatsenko Nov 14, 2018
77644ee
increase timeout for nosetests in travis
dimitri-yatsenko Nov 14, 2018
b46b64b
change terminology from `relations` to `query expressions` in doc str…
dimitri-yatsenko Nov 14, 2018
277398f
undo travis setting -- travis still not working on GitHub
dimitri-yatsenko Nov 16, 2018
06d5cc3
undo inconsequential change from previous commit to try to figure out…
dimitri-yatsenko Nov 16, 2018
10f7393
simplify context management, move test initialization into setup_clas…
dimitri-yatsenko Nov 17, 2018
29ca4c9
remove make_module_code for lack of potential use, tagging this commi…
dimitri-yatsenko Nov 17, 2018
bae0900
remove erd.topological_sort -- it is never called
dimitri-yatsenko Nov 17, 2018
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
Prev Previous commit
Next Next commit
add test for create_virtual_module and for issue #516
  • Loading branch information
dimitri-yatsenko committed Nov 13, 2018
commit 1d5b5933fe52b54c200d3807c5c749342d069ae3
4 changes: 2 additions & 2 deletions datajoint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class key:
from .errors import DataJointError, DuplicateError


def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False):
def create_virtual_module(module_name, schema_name, create_schema=False, create_tables=False, connection=None):
"""
Creates a python module with the given name from the name of a schema on the server and
automatically adds classes to it corresponding to the tables in the schema.
Expand All @@ -88,7 +88,7 @@ def create_virtual_module(module_name, schema_name, create_schema=False, create_
:return: the python module containing classes from the schema object and the table classes
"""
module = ModuleType(module_name)
_schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables)
_schema = schema(schema_name, create_schema=create_schema, create_tables=create_tables, connection=connection)
_schema.spawn_missing_classes(context=module.__dict__)
module.__dict__['schema'] = _schema
return module
8 changes: 6 additions & 2 deletions tests/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Test2(dj.Manual):
value : int # value
"""


@schema
class Test3(dj.Manual):
definition = """
Expand All @@ -37,6 +38,7 @@ class Test3(dj.Manual):
value : varchar(300)
"""


@schema
class TestExtra(dj.Manual):
"""
Expand All @@ -47,7 +49,9 @@ class TestExtra(dj.Manual):

@schema
class TestNoExtra(dj.Manual):
''' clone of Test but with no extra fields '''
"""
clone of Test but with no extra fields
"""
definition = Test.definition


Expand Down Expand Up @@ -142,7 +146,7 @@ def make(self, key):
@schema
class Trial(dj.Imported):
definition = """ # a trial within an experiment
-> Experiment.proj(exp='experiment_id')
-> Experiment.proj(animal='subject_id')
trial_id :smallint # trial number
---
start_time :double # (s)
Expand Down
3 changes: 1 addition & 2 deletions tests/schema_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ class TestUpdate(dj.Lookup):

contents = [
(0, 'my_string', 0.0, np.random.randn(10, 2)),
(1, 'my_other_string', 1.0, np.random.randn(20, 1)),
]
(1, 'my_other_string', 1.0, np.random.randn(20, 1))]


@schema
Expand Down
14 changes: 7 additions & 7 deletions tests/test_declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ def test_attributes():
assert_list_equal(experiment.primary_key,
['subject_id', 'experiment_id'])

assert_list_equal(trial.heading.names,
['subject_id', 'exp', 'trial_id', 'start_time'])
assert_list_equal(trial.heading.names, # tests issue #516
['animal', 'experiment_id', 'trial_id', 'start_time'])
assert_list_equal(trial.primary_key,
['subject_id', 'exp', 'trial_id'])
['animal', 'experiment_id', 'trial_id'])

assert_list_equal(ephys.heading.names,
['subject_id', 'exp', 'trial_id', 'sampling_frequency', 'duration'])
['animal', 'experiment_id', 'trial_id', 'sampling_frequency', 'duration'])
assert_list_equal(ephys.primary_key,
['subject_id', 'exp', 'trial_id'])
['animal', 'experiment_id', 'trial_id'])

assert_list_equal(channel.heading.names,
['subject_id', 'exp', 'trial_id', 'channel', 'voltage', 'current'])
['animal', 'experiment_id', 'trial_id', 'channel', 'voltage', 'current'])
assert_list_equal(channel.primary_key,
['subject_id', 'exp', 'trial_id', 'channel'])
['animal', 'experiment_id', 'trial_id', 'channel'])
assert_true(channel.heading.attributes['voltage'].is_blob)

@staticmethod
Expand Down
10 changes: 10 additions & 0 deletions tests/test_virtual_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from nose.tools import assert_true
import datajoint as dj
from datajoint.user_tables import UserTable
from . import schema
from . import CONN_INFO


def test_virtual_module():
module = dj.create_virtual_module('module', schema.schema.database, connection=dj.conn(**CONN_INFO))
assert_true(issubclass(module.Experiment, UserTable))