Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
67e41ef
Fixed #367
dimitri-yatsenko Oct 12, 2017
f89bf0e
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Oct 12, 2017
159cb51
fixed dependencies
dimitri-yatsenko Oct 12, 2017
bb88117
implemented the Union operator
dimitri-yatsenko Oct 13, 2017
9703126
bugfix in populate
dimitri-yatsenko Oct 13, 2017
4fa1abd
fixed a bug in server-side insert with missing attributes
dimitri-yatsenko Oct 13, 2017
d6b9f2a
work on cascading delete
dimitri-yatsenko Oct 19, 2017
c35ed7a
Merge branch 'master' of https://github.com/dimitri-yatsenko/datajoin…
dimitri-yatsenko Oct 19, 2017
7299058
fixed #375 -- added the max_calls argument to populate
dimitri-yatsenko Oct 19, 2017
3baf487
simplified insert from select
dimitri-yatsenko Oct 20, 2017
4969c36
consolidating the use of hashes
dimitri-yatsenko Oct 20, 2017
ce774be
added module `external` for handling external storage
dimitri-yatsenko Oct 20, 2017
ad650b0
minor fix in external, work in progress
dimitri-yatsenko Oct 20, 2017
860d04b
minor
dimitri-yatsenko Oct 20, 2017
2144b0f
changed how external storage is configured
dimitri-yatsenko Oct 20, 2017
cfc1e21
minor bug
dimitri-yatsenko Oct 20, 2017
0195cfc
minor formatting
dimitri-yatsenko Oct 20, 2017
d821bcf
removed the JobManager class -- it was never used
dimitri-yatsenko Oct 20, 2017
183b324
bugfix from previous commit
dimitri-yatsenko Oct 20, 2017
6164eb5
renamed the display_progress argument in populate()
dimitri-yatsenko Oct 20, 2017
96f0d20
Merge branch 'master' of https://github.com/dimitri-yatsenko/datajoin…
dimitri-yatsenko Oct 20, 2017
b37175b
rolled back unintended changes in delete
dimitri-yatsenko Oct 20, 2017
9688e5d
fixed typo JobsTable -> JobTable
dimitri-yatsenko Oct 20, 2017
bcc0048
fixed bugs introduced in recent commits
dimitri-yatsenko Oct 20, 2017
28208c2
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Oct 20, 2017
04b1829
fixed test_requirements
dimitri-yatsenko Oct 20, 2017
1c8e071
fixed indentation
dimitri-yatsenko Oct 20, 2017
bb11c1b
minor
dimitri-yatsenko Oct 20, 2017
9fc36b4
minor
dimitri-yatsenko Oct 20, 2017
9fca90f
minor code refactor in schema.py
dimitri-yatsenko Oct 22, 2017
7069dad
improved the error message in autopopulate
dimitri-yatsenko Oct 22, 2017
3bc28c5
correction to previous commit
dimitri-yatsenko Oct 22, 2017
a3d1a53
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Oct 24, 2017
d9cca7b
Merge branch 'master' of https://github.com/dimitri-yatsenko/datajoin…
dimitri-yatsenko Oct 24, 2017
1b37ee9
typo
dimitri-yatsenko Oct 24, 2017
cf3cf0c
made `make` and acceptable name for the populate callback (issue #387)
dimitri-yatsenko Oct 25, 2017
85b6587
small bugfix for rare cases with multiple inheritance
dimitri-yatsenko Oct 27, 2017
f936073
minor fix
dimitri-yatsenko Oct 27, 2017
2b622c1
Merge branch 'master' of https://github.com/dimitri-yatsenko/datajoin…
dimitri-yatsenko Oct 27, 2017
5270d80
minor fixes
dimitri-yatsenko Oct 29, 2017
85502b0
Merge branch 'master' of https://github.com/dimitri-yatsenko/datajoin…
dimitri-yatsenko Oct 30, 2017
bdba20d
undid an unintended change in delete
dimitri-yatsenko Oct 30, 2017
919efba
implemented declaration of external fields
dimitri-yatsenko Oct 30, 2017
e30dfb2
added tests for external storage
dimitri-yatsenko Oct 30, 2017
259950d
minor cleanup
dimitri-yatsenko Oct 30, 2017
3a7f416
minor cleanup
dimitri-yatsenko Oct 30, 2017
3594c67
added external storage tests
dimitri-yatsenko Nov 5, 2017
7eb114c
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko Nov 5, 2017
4d1af79
Completed basic implementation of external storage.
dimitri-yatsenko Nov 5, 2017
4a58a9a
ERD does not show dependencies on external storage
dimitri-yatsenko Nov 5, 2017
1ca0b09
again, the ERD no longer includes references to ~external
dimitri-yatsenko Nov 5, 2017
add950f
fixed #328: the jobs table now records the error stack
dimitri-yatsenko Nov 5, 2017
90c021e
fixes for #328
dimitri-yatsenko Nov 5, 2017
782a9a5
fixed #388 -- a more elegant way to skip duplicates in insert
dimitri-yatsenko Nov 5, 2017
383595d
followup to previous commit
dimitri-yatsenko Nov 5, 2017
794dc47
made insert from query more consistent with insert from variables
dimitri-yatsenko Nov 5, 2017
5ab3381
fixed issue #381 -- better error messages for syntax errors in declar…
dimitri-yatsenko Nov 5, 2017
4b2671e
typo from previous commit
dimitri-yatsenko Nov 6, 2017
9a0b902
set the strict mode at connection time
dimitri-yatsenko Nov 6, 2017
7302571
set sql_mode in connection
dimitri-yatsenko Nov 6, 2017
569881a
updated the sql_mode
dimitri-yatsenko Nov 6, 2017
86c2480
added tests for union and for external storage. Other minor fixes bas…
dimitri-yatsenko Nov 13, 2017
6f7c6bd
improved documentation and error messages for fetch and fetch1. Fixe…
dimitri-yatsenko Nov 14, 2017
8018a9d
added tests for external storage
dimitri-yatsenko Nov 15, 2017
7627569
changed the shape of the computed nodes in the ERD to elipse to avoid…
dimitri-yatsenko Nov 15, 2017
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
added tests for union and for external storage. Other minor fixes bas…
…ed PR commments.
  • Loading branch information
dimitri-yatsenko committed Nov 13, 2017
commit 86c2480dbb5a8505dcc89ac47aefed4b3316d6bd
4 changes: 2 additions & 2 deletions datajoint/declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def compile_attribute(line, in_key, foreign_key_sql):
raise DataJointError('External attributes cannot be primary in:\n%s' % line)
store_name = match['type'].split('-')
if store_name[0] != 'external':
raise DataJointError('External store types must be in format external-<name>')
raise DataJointError('External store types must be specified as "external" or "external-<name>"')
store_name = '-'.join(store_name[1:])
if not store_name.isidentifier():
if store_name != '' and not store_name.isidentifier():
raise DataJointError(
'The external store name `{type}` is invalid. Make like a python identifier.'.format(**match))
if len(store_name)>STORE_NAME_LENGTH:
Expand Down
1 change: 1 addition & 0 deletions datajoint/erd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def _get_tier(table_name):
except StopIteration:
return None


if not erd_active:
class ERD:
"""
Expand Down
24 changes: 12 additions & 12 deletions datajoint/relational_operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def make_condition(arg, _negate=False):
return arg, _negate
elif isinstance(arg, AndList):
return '(' + ' AND '.join([make_condition(element)[0] for element in arg]) + ')', _negate
elif arg is True or arg is False:
elif isinstance(arg, bool):
return 'FALSE' if _negate == arg else 'TRUE', False
# semijoin or antijoin
elif isinstance(arg, RelationalOperand):
Expand Down Expand Up @@ -308,7 +308,7 @@ def __sub__(self, restriction):
"""
return self & Not(restriction)

def restrict(self, arg):
def restrict(self, restriction):
"""
In-place restriction. Restricts the relation to a subset of its original tuples.
rel.restrict(restriction) is equivalent to rel = rel & restriction or rel &= restriction
Expand Down Expand Up @@ -354,19 +354,18 @@ def restrict(self, arg):

:param restriction: a sequence or an array (treated as OR list), another relation, an SQL condition string, or
an AndList.
:param as_or: if True than the applied restriction becomes or-listed with already existing conditions
"""
assert not self.heading.expressions or isinstance(self, GroupBy), \
"Cannot restrict in place a projection with renamed attributes."
if not restricts_to_same(arg):
self.restrictions.append(arg)
elif restricts_to_empty(arg):
assert not self.heading.expressions or isinstance(self, GroupBy), "Cannot restrict in place" \
" a projection with renamed attributes."
if not restricts_to_same(restriction):
self.restrictions.append(restriction)
elif restricts_to_empty(restriction):
self.restrictions.set(False)
return self

def allow(self, arg):
assert not self.heading.expressions or isinstance(self, GroupBy), \
"Cannot restrict in place a projection with renamed attributes."
assert not self.heading.expressions or isinstance(self, GroupBy), "Cannot restrict in place" \
" a projection with renamed attributes."
if self.restrictions:
if restricts_to_same(arg):
self.restrictions.clear()
Expand Down Expand Up @@ -637,8 +636,9 @@ def create(cls, arg1, arg2):
raise DataJointError("Cannot operate on relations from different connections.")
if set(arg1.heading.names) != set(arg2.heading.names):
raise DataJointError('Union requires the same attributes in both arguments')
if not all(v.in_key for v in arg1.heading.attributes.values()):
raise DataJointError('The left argument of union must not have any secondary attributes')
if any(not v.in_key for v in arg1.heading.attributes.values()) or \
all(not v.in_key for v in arg2.heading.attributes.values()):
raise DataJointError('Union arguments must not have any secondary attributes.')
obj._connection = arg1.connection
obj._heading = arg1.heading
obj._arg1 = arg1
Expand Down
21 changes: 0 additions & 21 deletions tests/schema_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,6 @@ def make_parent(pid, parent):
(9, 11), (9, 12), (10, 13), (10, 14), (11, 14), (11, 15), (12, 14), (12, 15)))


# @schema
# class Type(dj.Lookup):
# definition = """
# type : varchar(255)
# """
# contents = zip(('Type1', 'Type2', 'Type3'))
#
#
# @schema
# class TypeMaster(dj.Manual):
# definition= """
# master_id : int
# """
#
# class Type(dj.Part):
# definition = """
# -> TypeMaster
# -> Type
# """


@schema
class Subject(dj.Manual):
definition = """
Expand Down
4 changes: 3 additions & 1 deletion tests/schema_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ class Image(dj.Computed):
-> Dimension
----
img : external-raw # objects are stored as specified by dj.config['external-raw']
neg : external # objects are stored as specified by dj.congif['external']
"""

def make(self, key):
np.random.seed(key['seed'])
self.insert1(dict(key, img=np.random.rand(*(Dimension() & key).fetch1('dimensions'))))
img = np.random.rand(*(Dimension() & key).fetch1('dimensions'))
self.insert1(dict(key, img=img, neg=-img.astype(np.float32)))
26 changes: 26 additions & 0 deletions tests/test_declare.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ def test_describe():
s2 = declare(rel.full_table_name, rel.describe(), context)
assert_equal(s1, s2)

@staticmethod
def test_part():
# Lookup and part with the same name. See issue #365
local_schema = dj.schema(schema.schema.database, locals())

@local_schema
class Type(dj.Lookup):
definition = """
type : varchar(255)
"""
contents = zip(('Type1', 'Type2', 'Type3'))

locals() # this is to overcome the issue described in issue #368

@local_schema
class TypeMaster(dj.Manual):
definition = """
master_id : int
"""

class Type(dj.Part):
definition = """
-> TypeMaster
-> Type
"""

@staticmethod
def test_attributes():
# test autoincrement declaration
Expand Down
1 change: 0 additions & 1 deletion tests/test_foreign_keys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from nose.tools import assert_equal, assert_false, assert_true
from datajoint.declare import declare
from datajoint import AndList, OrList

from . import schema_advanced

Expand Down
13 changes: 10 additions & 3 deletions tests/test_relational_operand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
import string

import numpy as np
from nose.tools import assert_raises, assert_equal, \
assert_false, assert_true, assert_list_equal, \
assert_tuple_equal, assert_dict_equal, raises
from nose.tools import assert_equal, assert_false, assert_true, raises, assert_set_equal

import datajoint as dj
from .schema_simple import A, B, D, E, L, DataA, DataB, TestUpdate, IJ, JI
from .schema import Experiment
Expand Down Expand Up @@ -146,6 +145,14 @@ def test_project():
assert_equal(len((D() & cond).proj()), len((D() & cond)),
'projection failed: altered its argument''s cardinality')

@staticmethod
def test_union():
x = set(zip(*IJ().fetch('i','j')))
y = set(zip(*JI().fetch('i','j')))
assert_true(len(x) > 0 and len(y) > 0 and len(IJ() * JI()) < len(x)) # ensure the IJ and JI are non-trivial
z = set(zip(*(IJ() + JI()).fetch('i','j'))) # union
assert_set_equal(x.union(y), z)

@staticmethod
def test_preview():
with dj.config(display__limit=7):
Expand Down