Skip to content

Commit 91ac0e8

Browse files
Run pre-commit
1 parent 78a9233 commit 91ac0e8

File tree

7 files changed

+52
-56
lines changed

7 files changed

+52
-56
lines changed

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def select_constraint(default, nightly=None, git_master=None):
8888
"pyarrow>=10,<11",
8989
],
9090
extras_require={
91-
'lint': [
92-
'pre-commit',
91+
"lint": [
92+
"pre-commit",
9393
]
9494
},
9595
# Add in any packaged data.

struct2tensor/calculate.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,7 @@ def __str__(self) -> str:
260260
def _create_value_error(self) -> ValueError:
261261
"""Creates a ValueError, assuming there should be one for this node."""
262262
return ValueError(
263-
"Expression {} returned the wrong type: expected: {} actual: {}.".format(
264-
self.expression,
265-
_fancy_type_str(self.expression.is_repeated, self.expression.type),
266-
_node_type_str(self.value),
267-
)
263+
f"Expression {self.expression} returned the wrong type: expected: {_fancy_type_str(self.expression.is_repeated, self.expression.type)} actual: {_node_type_str(self.value)}."
268264
)
269265

270266
def calculate(

struct2tensor/expression_impl/broadcast.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,17 @@ def calculation_equal(self, expr: expression.Expression) -> bool:
139139
class _RecalculateExpression(expression.Expression):
140140
r"""Expression for recalculating a broadcasted subtree's parent indices.
141141
142-
This is needed because when a subtree is broadcasted, the nested fields
143-
could be duplicated. Their parent indices need to be updated.
142+
This is needed because when a subtree is broadcasted, the nested fields
143+
could be duplicated. Their parent indices need to be updated.
144144
145-
For example, given the expression tree:
145+
For example, given the expression tree:
146146
_DirectExpression(root)
147147
/ \
148148
_DirectExpression(parent) _DirectExpression(sibling)
149149
/
150-
_DirectExpression(submessage)
150+
_DirectExpression(submessage)
151151
152-
If we broadcast (parent) into (sibling), then we get:
152+
If we broadcast (parent) into (sibling), then we get:
153153
_DirectExpression(root)
154154
/ \
155155
_DirectExpression(parent) _DirectExpression(sibling)
@@ -158,19 +158,19 @@ class _RecalculateExpression(expression.Expression):
158158
\
159159
_RecalculateExpression(new_submessage)
160160
161-
This tree represents a field `parent` broadcasted into `sibling`. In this case
162-
the `origin` of `_RecalculateExpression(new_submessage)` would be
163-
`_DirectExpression(submessage)` and the `parent` of
164-
`_RecalculateExpression(new_submessage)` would be
165-
`_BroadcastChildExpression(new_parent)`
161+
This tree represents a field `parent` broadcasted into `sibling`. In this case
162+
the `origin` of `_RecalculateExpression(new_submessage)` would be
163+
`_DirectExpression(submessage)` and the `parent` of
164+
`_RecalculateExpression(new_submessage)` would be
165+
`_BroadcastChildExpression(new_parent)`
166166
167-
Attributes:
167+
Attributes:
168168
origin: The origin expression should be a _DirectExpression that represents
169169
the original subtree's field. It can represent a Child or Leaf NodeTensor.
170170
parent: The parent expression should be a _BroadcastChildExpression or
171171
_RecalculateExpression that represents the 'broadcasted' parent's
172172
ChildNodeTensor.
173-
"""
173+
"""
174174

175175
def __init__(self, origin: expression.Expression, parent: expression.Expression):
176176
super().__init__(

struct2tensor/expression_impl/filter_expression_test.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
def _create_slice_and_project_example():
3434
r"""Creates an example for test_slice_and_project.
3535
36-
Returns:
36+
Returns:
3737
------*-----------------
3838
/ \
3939
---session0---- session1
@@ -44,8 +44,8 @@ def _create_slice_and_project_example():
4444
| | | | | | | | |
4545
a b c e f g h i j
4646
47-
This also adds an action_mask that is false for the zeroeth action.
48-
"""
47+
This also adds an action_mask that is false for the zeroeth action.
48+
"""
4949
return proto_test_util.text_to_expression(
5050
[
5151
"""
@@ -107,17 +107,17 @@ def _create_nested_prensor():
107107
root0 root1----------------------- root2 (empty)
108108
/ \ / \ \ \
109109
| keep_my_sib0:False | keep_my_sib1:True | keep_my_sib2:False
110-
doc0----- doc1--------------- doc2--------
111-
| \ \ \ \ \
110+
doc0----- doc1--------------- doc2--------
111+
| \ \ \ \ \
112112
bar:"a" keep_me:False bar:"b" bar:"c" keep_me:True bar:"d"
113113
114-
Returns:
114+
Returns:
115115
a prensor expression representing:
116116
{doc:[{bar:["a"], keep_me:False}], keep_my_sib:False}
117117
{doc:[{bar:["b","c"], keeo}, {bar:["d"]}],
118118
keep_me:True}
119119
{}
120-
"""
120+
"""
121121
return prensor.create_prensor_from_descendant_nodes(
122122
{
123123
path.Path([]): prensor_test_util.create_root_node(3),
@@ -138,24 +138,24 @@ def _create_nested_prensor():
138138
def _create_nested_prensor_2():
139139
r"""Creates a prensor representing a list of nested protocol buffers.
140140
141-
keep_me no longer has a value in doc0.
141+
keep_me no longer has a value in doc0.
142142
143143
-----*----------------------------------------------------
144144
/ \ \
145145
root0 root1----------------------- root2 (empty)
146146
/ \ / \ \ \
147147
| keep_my_sib0:False | keep_my_sib1:True | keep_my_sib2:False
148-
doc0 doc1--------------- doc2--------
149-
| \ \ \ \
148+
doc0 doc1--------------- doc2--------
149+
| \ \ \ \
150150
bar:"a" bar:"b" bar:"c" keep_me:True bar:"d"
151151
152-
Returns:
152+
Returns:
153153
a prensor expression representing:
154154
{doc:[{bar:["a"], keep_me:False}], keep_my_sib:False}
155155
{doc:[{bar:["b","c"], keeo}, {bar:["d"]}],
156156
keep_me:True}
157157
{}
158-
"""
158+
"""
159159
return prensor.create_prensor_from_descendant_nodes(
160160
{
161161
path.Path([]): prensor_test_util.create_root_node(3),
@@ -290,19 +290,19 @@ def test_filter_by_child_create_nested_prensor_2(self):
290290
def test_filter_by_sibling(self):
291291
r"""Tests filter_by_sibling.
292292
293-
Beginning with the struct:
293+
Beginning with the struct:
294294
-----*----------------------------------------------------
295295
/ \ \
296296
root0 root1----------------------- root2 (empty)
297-
/ \ / \ \ \
297+
/ \ / \ \ \
298298
| keep_my_sib0:False | keep_my_sib1:True | keep_my_sib2:False
299-
doc0----- doc1--------------- doc2--------
300-
| \ \ \ \ \
299+
doc0----- doc1--------------- doc2--------
300+
| \ \ \ \ \
301301
bar:"a" keep_me:False bar:"b" bar:"c" keep_me:True bar:"d"
302302
303-
Filter doc with keep_my_sib:
303+
Filter doc with keep_my_sib:
304304
305-
End with the struct (suppressing original doc):
305+
End with the struct (suppressing original doc):
306306
-----*----------------------------------------------------
307307
/ \ \
308308
root0 root1------------------ root2 (empty)
@@ -312,7 +312,7 @@ def test_filter_by_sibling(self):
312312
\ \ \
313313
bar:"b" bar:"c" keep_me:True
314314
315-
"""
315+
"""
316316
root = create_expression.create_expression_from_prensor(
317317
_create_nested_prensor()
318318
)

struct2tensor/expression_impl/map_prensor_to_prensor.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,50 +208,50 @@ def map_prensor_to_prensor(
208208
) -> expression.Expression:
209209
r"""Maps an expression to a prensor, and merges that prensor.
210210
211-
For example, suppose you have an op my_op, that takes a prensor of the form:
211+
For example, suppose you have an op my_op, that takes a prensor of the form:
212212
213213
event
214214
/ \
215215
foo bar
216216
217-
and produces a prensor of the form my_result_schema:
217+
and produces a prensor of the form my_result_schema:
218218
219219
event
220220
/ \
221221
foo2 bar2
222222
223-
If you give it an expression original with the schema:
223+
If you give it an expression original with the schema:
224224
225-
session
225+
session
226226
|
227227
event
228228
/ \
229229
foo bar
230230
231-
result = map_prensor_to_prensor(
231+
result = map_prensor_to_prensor(
232232
original,
233233
path.Path(["session","event"]),
234234
my_op,
235235
my_output_schema)
236236
237-
Result will have the schema:
237+
Result will have the schema:
238238
239-
session
239+
session
240240
|
241241
event--------
242242
/ \ \ \
243243
foo bar foo2 bar2
244244
245-
Args:
245+
Args:
246246
root_expr: the root expression
247247
source: the path where the prensor op is applied.
248248
paths_needed: the paths needed for the op.
249249
prensor_op: the prensor op
250250
output_schema: the output schema of the op.
251251
252-
Returns:
252+
Returns:
253253
A new expression where the prensor is merged.
254-
"""
254+
"""
255255
original_child = root_expr.get_descendant_or_error(source).project(paths_needed)
256256
prensor_child = _PrensorOpExpression(original_child, prensor_op, output_schema)
257257
paths_map = {

struct2tensor/expression_impl/proto_test_util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def text_to_expression(text_list, example_proto_clz):
3636
def _get_expression_from_session_empty_user_info():
3737
r"""Run create_root_prensor on a very deep tree.
3838
39-
In addition, the user_info is empty.
39+
In addition, the user_info is empty.
4040
41-
```
41+
```
4242
------*-----------------
4343
/ \
4444
---session0---- session1
@@ -49,11 +49,11 @@ def _get_expression_from_session_empty_user_info():
4949
| | | | | | | | |
5050
a b c e f g h i j
5151
52-
```
52+
```
5353
54-
Returns:
54+
Returns:
5555
A RootPrensor with the above structure.
56-
"""
56+
"""
5757
return text_to_expression(
5858
[
5959
"""

struct2tensor/ops/struct2tensor_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ def parse_message_level(
173173
for field_descriptor in field_descriptors
174174
]
175175
if tf.is_tensor(backing_str_tensor):
176-
assert message_format == "binary", (
177-
"message_format must be 'binary' if a backing_str_tensor is provided"
178-
)
176+
assert (
177+
message_format == "binary"
178+
), "message_format must be 'binary' if a backing_str_tensor is provided"
179179
backing_str_tensor = [backing_str_tensor]
180180
else:
181181
backing_str_tensor = []

0 commit comments

Comments
 (0)