@@ -1415,53 +1415,38 @@ def __bool__(self):
14151415
14161416class U :
14171417 """
1418- dj.U objects are the universal sets representing all possible values of their attributes.
1419- dj.U objects cannot be queried on their own but are useful for forming some queries.
1420- dj.U('attr1', ..., 'attrn') represents the universal set with the primary key attributes attr1 ... attrn.
1421- The universal set is the set of all possible combinations of values of the attributes.
1422- Without any attributes, dj.U() represents the set with one element that has no attributes.
1418+ Universal set representing all possible values of specified attributes.
14231419
1424- Restriction:
1420+ ``dj.U`` objects cannot be queried on their own but are useful for forming
1421+ certain queries. ``dj.U('attr1', ..., 'attrn')`` represents the universal set
1422+ with primary key attributes ``attr1 ... attrn``. Without any attributes,
1423+ ``dj.U()`` represents a set with one element that has no attributes.
14251424
1426- dj.U can be used to enumerate unique combinations of values of attributes from other expressions.
1427-
1428- The following expression yields all unique combinations of contrast and brightness found in the `stimulus` set:
1425+ **Restriction** - Enumerate unique combinations of attribute values:
14291426
14301427 >>> dj.U('contrast', 'brightness') & stimulus
14311428
1432- Aggregation:
1433-
1434- In aggregation, dj.U is used for summary calculation over an entire set:
1435-
1436- The following expression yields one element with one attribute `s` containing the total number of elements in
1437- query expression `expr`:
1438-
1439- >>> dj.U().aggr(expr, n='count(*)')
1429+ This yields all unique combinations of contrast and brightness in ``stimulus``.
14401430
1441- The following expressions both yield one element containing the number `n` of distinct values of attribute `attr` in
1442- query expression `expr`.
1431+ **Aggregation** - Summary calculations over an entire set:
14431432
1444- >>> dj.U().aggr(expr, n='count(distinct attr)')
1445- >>> dj.U().aggr(dj.U('attr').aggr(expr), 'n=count(*)')
1433+ >>> dj.U().aggr(expr, n='count(*)') # Total count
14461434
1447- The following expression yields one element and one attribute `s` containing the sum of values of attribute `attr`
1448- over entire result set of expression `expr`:
1435+ >>> dj.U().aggr(expr, n='count(distinct attr)') # Distinct values
14491436
1450- >>> dj.U().aggr(expr, s='sum(attr)')
1437+ >>> dj.U().aggr(expr, s='sum(attr)') # Sum of attribute
14511438
1452- The following expression yields the set of all unique combinations of attributes `attr1`, `attr2` and the number of
1453- their occurrences in the result set of query expression `expr`.
1439+ >>> dj.U('attr1', 'attr2').aggr(expr, n='count(*)') # Count per group
14541440
1455- >>> dj.U(attr1,attr2).aggr(expr, n='count(*)')
1441+ **Joins** - Promote attributes to primary key:
14561442
1457- Joins:
1443+ If ``expr`` has attributes ``attr1`` and ``attr2``, then
1444+ ``expr * dj.U('attr1', 'attr2')`` yields the same result as ``expr``
1445+ but with ``attr1`` and ``attr2`` promoted to the primary key.
14581446
1459- If expression `expr` has attributes 'attr1' and 'attr2', then expr * dj.U('attr1','attr2') yields the same result
1460- as `expr` but `attr1` and `attr2` are promoted to the the primary key. This is useful for producing a join on
1461- non-primary key attributes.
1462- For example, if `attr` is in both expr1 and expr2 but not in their primary keys, then expr1 * expr2 will throw
1463- an error because in most cases, it does not make sense to join on non-primary key attributes and users must first
1464- rename `attr` in one of the operands. The expression dj.U('attr') * rel1 * rel2 overrides this constraint.
1447+ .. note::
1448+ The ``*`` operator with ``dj.U`` has been removed in DataJoint 2.0.
1449+ This pattern is no longer necessary with the new semantic matching system.
14651450 """
14661451
14671452 def __init__ (self , * primary_key ):
0 commit comments