-
Notifications
You must be signed in to change notification settings - Fork 96
Minor adjustments for release #889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dimitri-yatsenko
merged 24 commits into
datajoint:release013
from
guzman-raphael:adjustments
Mar 24, 2021
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f23cfe5
03-Fetch_lang1.rst: explain DataFrame index as matching pkey
5b95862
Merge pull request #875 from ixcat/master
dimitri-yatsenko dd05f3c
fix #876 in 0.12
dimitri-yatsenko 6fd8810
Merge branch 'master' of https://github.com/datajoint/datajoint-python
dimitri-yatsenko d5dbd5b
update change log for 0.12.9
dimitri-yatsenko dff22f3
minor change in changelog
dimitri-yatsenko 3df05c0
Merge pull request #880 from dimitri-yatsenko/master
guzman-raphael 2b7e1ad
Merge pull request #887 from dimitri-yatsenko/cascade-delete
guzman-raphael 1541234
Debug id.
guzman-raphael b69c2d9
Update GID.
guzman-raphael a17017f
Show missing lines in coverage.
guzman-raphael cd24a34
Debug single test with diff coverage.
guzman-raphael 2a2914b
Remove debug statements, bump version, fix None in DJErrors, add docs…
guzman-raphael 99b0535
Fix merge conflicts.
guzman-raphael 9ebd091
Import warnings in table submodule.
guzman-raphael 57b6bac
Update docs version reference.
guzman-raphael fad8f70
Add update doc.
guzman-raphael 9161f8a
Update lang-specific docs.
guzman-raphael 8a1b5cb
Update transpiler doc headers.
guzman-raphael c5ac58e
Revert heading structure.
guzman-raphael a943ad6
Add purge utility for query caching and add test.
guzman-raphael 1a35ad0
Fix connection access issue.
guzman-raphael a75b6b4
Add basic tests for permissive join and restriction.
guzman-raphael 51f55ab
Fix styling and update changelog.
guzman-raphael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ branch = False | |
| source = datajoint | ||
|
|
||
| [report] | ||
| show_missing = True | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,15 +193,15 @@ def restrict_in_place(self, restriction): | |
|
|
||
| def __and__(self, restriction): | ||
| """ | ||
| Restriction operator | ||
| Restriction operator e.g. q1 & q2. | ||
| :return: a restricted copy of the input argument | ||
| See QueryExpression.restrict for more detail. | ||
| """ | ||
| return self.restrict(restriction) | ||
|
|
||
| def __xor__(self, restriction): | ||
| """ | ||
| Restriction operator ignoring compatibility check. | ||
| Permissive restriction operator ignoring compatibility check e.g. q1 ^ q2. | ||
| """ | ||
| if inspect.isclass(restriction) and issubclass(restriction, QueryExpression): | ||
| restriction = restriction() | ||
|
|
@@ -211,22 +211,33 @@ def __xor__(self, restriction): | |
|
|
||
| def __sub__(self, restriction): | ||
| """ | ||
| Inverted restriction | ||
| Inverted restriction e.g. q1 - q2. | ||
| :return: a restricted copy of the input argument | ||
| See QueryExpression.restrict for more detail. | ||
| """ | ||
| return self.restrict(Not(restriction)) | ||
|
|
||
| def __neg__(self): | ||
| """ | ||
| Convert between restriction and inverted restriction e.g. -q1. | ||
| :return: target restriction | ||
| See QueryExpression.restrict for more detail. | ||
| """ | ||
| if isinstance(self, Not): | ||
| return self.restriction | ||
| return Not(self) | ||
|
|
||
| def __mul__(self, other): | ||
| """ join of query expressions `self` and `other` """ | ||
| """ | ||
| join of query expressions `self` and `other` e.g. q1 * q2. | ||
| """ | ||
| return self.join(other) | ||
|
|
||
| def __matmul__(self, other): | ||
| """ | ||
| Permissive join of query expressions `self` and `other` ignoring compatibility check | ||
| e.g. q1 @ q2. | ||
| """ | ||
| if inspect.isclass(other) and issubclass(other, QueryExpression): | ||
| other = other() # instantiate | ||
| return self.join(other, semantic_check=False) | ||
|
|
@@ -271,7 +282,7 @@ def join(self, other, semantic_check=True, left=False): | |
| return result | ||
|
|
||
| def __add__(self, other): | ||
| """union""" | ||
| """union e.g. q1 + q2.""" | ||
| return Union.create(self, other) | ||
|
|
||
| def proj(self, *attributes, **named_attributes): | ||
|
|
@@ -424,7 +435,7 @@ def tail(self, limit=25, **fetch_kwargs): | |
| return self.fetch(order_by="KEY DESC", limit=limit, **fetch_kwargs)[::-1] | ||
|
|
||
| def __len__(self): | ||
| """ :return: number of elements in the result set """ | ||
| """:return: number of elements in the result set e.g. len(q1).""" | ||
| return self.connection.query( | ||
| 'SELECT count(DISTINCT {fields}) FROM {from_}{where}'.format( | ||
| fields=self.heading.as_sql(self.primary_key, include_aliases=False), | ||
|
|
@@ -433,7 +444,8 @@ def __len__(self): | |
|
|
||
| def __bool__(self): | ||
| """ | ||
| :return: True if the result is not empty. Equivalent to len(self) > 0 but often faster. | ||
| :return: True if the result is not empty. Equivalent to len(self) > 0 but often | ||
| faster e.g. bool(q1). | ||
| """ | ||
| return bool(self.connection.query( | ||
| 'SELECT EXISTS(SELECT 1 FROM {from_}{where})'.format( | ||
|
|
@@ -442,19 +454,30 @@ def __bool__(self): | |
|
|
||
| def __contains__(self, item): | ||
| """ | ||
| returns True if item is found in the . | ||
| returns True if a restriction results with any records e.g. restriction in q1. | ||
| :param item: any restriction | ||
| (item in query_expression) is equivalent to bool(query_expression & item) but may be | ||
| executed more efficiently. | ||
| """ | ||
| return bool(self & item) # May be optimized e.g. using an EXISTS query | ||
|
|
||
| def __iter__(self): | ||
| """ | ||
| returns an iterator-compatible QueryExpression object e.g. iter(q1). | ||
|
|
||
| :param self: iterator-compatible QueryExpression object | ||
| """ | ||
| self._iter_only_key = all(v.in_key for v in self.heading.attributes.values()) | ||
| self._iter_keys = self.fetch('KEY') | ||
| return self | ||
|
|
||
| def __next__(self): | ||
| """ | ||
| returns the next record on an iterator-compatible QueryExpression object | ||
| e.g. next(q1). | ||
|
|
||
| :param self: fetch1 record | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here self is a QueryExpression that has been primed with |
||
| """ | ||
| try: | ||
| key = self._iter_keys.pop(0) | ||
| except AttributeError: | ||
|
|
@@ -490,6 +513,11 @@ def cursor(self, offset=0, limit=None, order_by=None, as_dict=False): | |
| return self.connection.query(sql, as_dict=as_dict) | ||
|
|
||
| def __repr__(self): | ||
| """ | ||
| returns the string representation of a QueryExpression object e.g. str(q1). | ||
|
|
||
| :param self: String version of query result | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here |
||
| """ | ||
| return super().__repr__() if config['loglevel'].lower() == 'debug' else self.preview() | ||
|
|
||
| def preview(self, limit=None, width=None): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| __version__ = "0.13.dev7" | ||
| __version__ = "0.13.0" | ||
|
|
||
| assert len(__version__) <= 10 # The log table limits version to the 10 characters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # with record as a dict specifying the primary and | ||
| # secondary attribute values | ||
| table.update1(record) | ||
|
|
||
| # update value in record with id as primary key | ||
| table.update1({'id': 1, 'value': 3}) | ||
|
|
||
| # reset value to default with id as primary key | ||
| table.update1({'id': 1, 'value': None}) | ||
| ## OR | ||
| table.update1({'id': 1}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # set the query cache path | ||
| dj.config['query_cache'] = os.path.expanduser('~/dj_query_cache') | ||
|
|
||
| # access the active connection object for the tables | ||
| conn = dj.conn() # if queries co-located with tables | ||
| conn = module.schema.connection # if schema co-located with tables | ||
| conn = module.table.connection # most flexible | ||
|
|
||
| # activate query caching for a namespace called 'main' | ||
| conn.set_query_cache(query_cache='main') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # deactivate query caching | ||
| conn.set_query_cache(query_cache=None) | ||
| ## OR | ||
| conn.set_query_cache() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # purged the cached queries | ||
| conn.purge_query_cache() | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| { | ||
| "comm_version": "v0.1" | ||
| "comm_version": "v0.2" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.