Skip to content

Commit 8c51bde

Browse files
committed
Doc API site
1 parent 56ced5d commit 8c51bde

26 files changed

+462
-22
lines changed

datajoint/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def set_password(
2828
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
2929
"""
3030
view and kill database connections.
31+
3132
:param restriction: restriction to be applied to processlist
3233
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
3334
:param order_by: order by a single attribute or the list of attributes. defaults to 'id'.
@@ -86,6 +87,7 @@ def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
8687
def kill_quick(restriction=None, connection=None):
8788
"""
8889
Kill database connections without prompting. Returns number of terminated connections.
90+
8991
:param restriction: restriction to be applied to processlist
9092
:param connection: a datajoint.Connection object. Default calls datajoint.conn()
9193

datajoint/attribute_adapter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ def attribute_type(self):
1818
def get(self, value):
1919
"""
2020
convert value retrieved from the the attribute in a table into the adapted type
21+
2122
:param value: value from the database
23+
2224
:return: object of the adapted type
2325
"""
2426
raise NotImplementedError("Undefined attribute adapter")
2527

2628
def put(self, obj):
2729
"""
2830
convert an object of the adapted type into a value that DataJoint can store in a table attribute
31+
2932
:param obj: an object of the adapted type
3033
:return: value to store in the database
3134
"""

datajoint/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def connect_host_hook(connection_obj):
5252
def translate_query_error(client_error, query):
5353
"""
5454
Take client error and original query and return the corresponding DataJoint exception.
55+
5556
:param client_error: the exception raised by the client interface
5657
:param query: sql query with placeholders
5758
:return: an instance of the corresponding subclass of datajoint.errors.DataJointError
@@ -247,6 +248,7 @@ def set_query_cache(self, query_cache=None):
247248
1. Only SELECT queries are allowed.
248249
2. The results of queries are cached under the path indicated by dj.config['query_cache']
249250
3. query_cache is a string that differentiates different cache states.
251+
250252
:param query_cache: a string to initialize the hash for query results
251253
"""
252254
self._query_cache = query_cache
@@ -298,6 +300,7 @@ def query(
298300
):
299301
"""
300302
Execute the specified query and return the tuple generator (cursor).
303+
301304
:param query: SQL query
302305
:param args: additional arguments for the client.cursor
303306
:param as_dict: If as_dict is set to True, the returned cursor objects returns

datajoint/declare.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def build_index_parser():
153153

154154
def is_foreign_key(line):
155155
"""
156+
156157
:param line: a line from the table definition
157158
:return: true if the line appears to be a foreign key definition
158159
"""
@@ -366,6 +367,7 @@ def prepare_declare(definition, context):
366367
def declare(full_table_name, definition, context):
367368
"""
368369
Parse declaration and generate the SQL CREATE TABLE code
370+
369371
:param full_table_name: full name of the table
370372
:param definition: DataJoint table definition
371373
:param context: dictionary of objects that might be referred to in the table
@@ -566,6 +568,7 @@ def substitute_special_type(match, category, foreign_key_sql, context):
566568
def compile_attribute(line, in_key, foreign_key_sql, context):
567569
"""
568570
Convert attribute definition from DataJoint format to SQL
571+
569572
:param line: attribution line
570573
:param in_key: set to True if attribute is in primary key set
571574
:param foreign_key_sql: the list of foreign key declarations to add to

datajoint/diagram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def __init__(self, source, context=None):
146146
def from_sequence(cls, sequence):
147147
"""
148148
The join Diagram for all objects in sequence
149+
149150
:param sequence: a sequence (e.g. list, tuple)
150151
:return: Diagram(arg1) + ... + Diagram(argn)
151152
"""

datajoint/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(self, *args):
3434
def suggest(self, *args):
3535
"""
3636
regenerate the exception with additional arguments
37+
3738
:param args: addition arguments
3839
:return: a new exception of the same type with the additional arguments
3940
"""

datajoint/expression.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def where_clause(self):
121121
def make_sql(self, fields=None):
122122
"""
123123
Make the SQL SELECT statement.
124+
124125
:param fields: used to explicitly set the select attributes
125126
"""
126127
return "SELECT {distinct}{fields} FROM {from_}{where}".format(
@@ -323,6 +324,7 @@ def __add__(self, other):
323324
def proj(self, *attributes, **named_attributes):
324325
"""
325326
Projection operator.
327+
326328
:param attributes: attributes to be included in the result. (The primary key is already included).
327329
:param named_attributes: new attributes computed or renamed from existing attributes.
328330
:return: the projected expression.
@@ -481,6 +483,7 @@ def aggr(self, group, *attributes, keep_all_rows=False, **named_attributes):
481483
"""
482484
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
483485
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
486+
484487
:param group: The query expression to be aggregated.
485488
:param keep_all_rows: True=keep all the rows from self. False=keep only rows that match entries in group.
486489
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
@@ -510,6 +513,7 @@ def head(self, limit=25, **fetch_kwargs):
510513
"""
511514
shortcut to fetch the first few entries from query expression.
512515
Equivalent to fetch(order_by="KEY", limit=25)
516+
513517
:param limit: number of entries
514518
:param fetch_kwargs: kwargs for fetch
515519
:return: query result
@@ -520,6 +524,7 @@ def tail(self, limit=25, **fetch_kwargs):
520524
"""
521525
shortcut to fetch the last few entries from query expression.
522526
Equivalent to fetch(order_by="KEY DESC", limit=25)[::-1]
527+
523528
:param limit: number of entries
524529
:param fetch_kwargs: kwargs for fetch
525530
:return: query result
@@ -561,6 +566,7 @@ def __contains__(self, item):
561566
"""
562567
returns True if the restriction in item matches any entries in self
563568
e.g. ``restriction in q1``.
569+
564570
:param item: any restriction
565571
(item in query_expression) is equivalent to bool(query_expression & item) but may be
566572
executed more efficiently.
@@ -907,6 +913,7 @@ def aggr(self, group, **named_attributes):
907913
"""
908914
Aggregation of the type U('attr1','attr2').aggr(group, computation="QueryExpression")
909915
has the primary key ('attr1','attr2') and performs aggregation computations for all matching elements of `group`.
916+
910917
:param group: The query expression to be aggregated.
911918
:param named_attributes: computations of the form new_attribute="sql expression on attributes of group"
912919
:return: The derived query expression

datajoint/external.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ def upload_filepath(self, local_filepath):
300300
def download_filepath(self, filepath_hash):
301301
"""
302302
sync a file from external store to the local stage
303+
303304
:param filepath_hash: The hash (UUID) of the relative_path
304305
:return: hash (UUID) of the contents of the downloaded file or Nones
305306
"""
@@ -351,6 +352,7 @@ def fetch_external_paths(self, **fetch_kwargs):
351352
"""
352353
generate complete external filepaths from the query.
353354
Each element is a tuple: (uuid, path)
355+
354356
:param fetch_kwargs: keyword arguments to pass to fetch
355357
"""
356358
fetch_kwargs.update(as_dict=True)
@@ -371,6 +373,7 @@ def fetch_external_paths(self, **fetch_kwargs):
371373
def unused(self):
372374
"""
373375
query expression for unused hashes
376+
374377
:return: self restricted to elements that are not in use by any tables in the schema
375378
"""
376379
return self - [
@@ -383,6 +386,7 @@ def unused(self):
383386
def used(self):
384387
"""
385388
query expression for used hashes
389+
386390
:return: self restricted to elements that in use by tables in the schema
387391
"""
388392
return self & [
@@ -401,9 +405,9 @@ def delete(
401405
errors_as_string=True
402406
):
403407
"""
404-
:param delete_external_files: True or False. If False, only the tracking info is removed from the
405-
external store table but the external files remain intact. If True, then the external files
406-
themselves are deleted too.
408+
409+
:param delete_external_files: True or False. If False, only the tracking info is removed from the external store table but the external files remain intact. If True, then the external files themselves are deleted too.
410+
407411
:param errors_as_string: If True any errors returned when deleting from external files will be strings
408412
:param limit: (integer) limit the number of items to delete
409413
:param display_progress: if True, display progress as files are cleaned up
@@ -470,6 +474,7 @@ def __getitem__(self, store):
470474
"""
471475
Triggers the creation of an external table.
472476
Should only be used when ready to save or read from external storage.
477+
473478
:param store: the name of the store
474479
:return: the ExternalTable object for the store
475480
"""

datajoint/fetch.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def _flatten_attribute_list(primary_key, attrs):
133133
class Fetch:
134134
"""
135135
A fetch object that handles retrieving elements from the table expression.
136+
136137
:param expression: the QueryExpression object to fetch from.
137138
"""
138139

@@ -153,20 +154,13 @@ def __call__(
153154
"""
154155
Fetches the expression results from the database into an np.array or list of dictionaries and
155156
unpacks blob attributes.
156-
:param attrs: zero or more attributes to fetch. If not provided, the call will return
157-
all attributes of this relation. If provided, returns tuples with an entry for each attribute.
157+
158+
:param attrs: zero or more attributes to fetch. If not provided, the call will return all attributes of this relation. If provided, returns tuples with an entry for each attribute.
158159
:param offset: the number of tuples to skip in the returned result
159160
:param limit: the maximum number of tuples to return
160-
:param order_by: a single attribute or the list of attributes to order the results.
161-
No ordering should be assumed if order_by=None.
162-
To reverse the order, add DESC to the attribute name or names: e.g. ("age DESC", "frequency")
163-
To order by primary key, use "KEY" or "KEY DESC"
164-
:param format: Effective when as_dict=None and when attrs is empty
165-
None: default from config['fetch_format'] or 'array' if not configured
166-
"array": use numpy.key_array
167-
"frame": output pandas.DataFrame. .
168-
:param as_dict: returns a list of dictionaries instead of a record array.
169-
Defaults to False for .fetch() and to True for .fetch('KEY')
161+
:param order_by: a single attribute or the list of attributes to order the results. No ordering should be assumed if order_by=None. To reverse the order, add DESC to the attribute name or names: e.g. ("age DESC", "frequency") To order by primary key, use "KEY" or "KEY DESC"
162+
:param format: Effective when as_dict=None and when attrs is empty None: default from config['fetch_format'] or 'array' if not configured "array": use numpy.key_array "frame": output pandas.DataFrame. .
163+
:param as_dict: returns a list of dictionaries instead of a record array. Defaults to False for .fetch() and to True for .fetch('KEY')
170164
:param squeeze: if True, remove extra dimensions from arrays
171165
:param download_path: for fetches that download data, e.g. attachments
172166
:return: the contents of the relation in the form of a structured numpy.array or a dict list
@@ -294,6 +288,7 @@ def __call__(
294288
class Fetch1:
295289
"""
296290
Fetch object for fetching the result of a query yielding one row.
291+
297292
:param expression: a query expression to fetch from.
298293
"""
299294

datajoint/heading.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def sql(self):
6767
Convert primary key attribute tuple into its SQL CREATE TABLE clause.
6868
Default values are not reflected.
6969
This is used for declaring foreign keys in referencing tables
70+
7071
:return: SQL code for attribute declaration
7172
"""
7273
return '`{name}` {type} NOT NULL COMMENT "{comment}"'.format(
@@ -90,6 +91,7 @@ class Heading:
9091

9192
def __init__(self, attribute_specs=None, table_info=None):
9293
"""
94+
9395
:param attribute_specs: a list of dicts with the same keys as Attribute
9496
:param table_info: a dict with information to load the heading from the database
9597
"""
@@ -434,6 +436,7 @@ def select(self, select_list, rename_map=None, compute_map=None):
434436
"""
435437
derive a new heading by selecting, renaming, or computing attributes.
436438
In relational algebra these operators are known as project, rename, and extend.
439+
437440
:param select_list: the full list of existing attributes to include
438441
:param rename_map: dictionary of renamed attributes: keys=new names, values=old names
439442
:param compute_map: a direction of computed attributes

0 commit comments

Comments
 (0)