Skip to content

Commit

Permalink
Remove unnecessary fstring (python-graphblas#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw authored Oct 25, 2022
1 parent 69add7d commit 97f6af4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
8 changes: 4 additions & 4 deletions graphblas/core/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def parse_index(self, index, typ, size):
if typ is Vector or typ is Matrix:
raise TypeError(
f"Invalid type for index: {typ.__name__}.\n"
f"If you want to apply a mask, perhaps do something like "
"If you want to apply a mask, perhaps do something like "
f"`x.dup(mask={index.name}.S)`.\n"
f"If you want to assign with a mask, perhaps do something like "
"If you want to assign with a mask, perhaps do something like "
f"`x(mask={index.name}.S) << value`."
)
elif typ is TransposedMatrix:
Expand All @@ -236,9 +236,9 @@ def parse_index(self, index, typ, size):
if isinstance(index, Mask):
raise TypeError(
f"Invalid type for index: {typ.__name__}.\n"
f"If you want to apply a mask, perhaps do something like "
"If you want to apply a mask, perhaps do something like "
f"`x.dup(mask={index.name})`.\n"
f"If you want to assign with a mask, perhaps do something like "
"If you want to assign with a mask, perhaps do something like "
f"`x(mask={index.name}) << value`."
) from None
raise TypeError(
Expand Down
6 changes: 3 additions & 3 deletions graphblas/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def _format_expression(expr, header):
f"<tt><b>gb.{type(expr).__name__}</b></tt>"
'&nbsp;<span class="expr-tooltip">'
'<span class="tooltip-circle">?</span>'
f'<span class="tooltip-text"><em>'
'<span class="tooltip-text"><em>'
"Do <code>expr.new()</code> or <code>other << expr</code> to calculate the expression."
"</em></span></span>"
)
Expand Down Expand Up @@ -699,7 +699,7 @@ def _format_infix_expression(expr, header, expr_name):
f"<tt><b>gb.{type(expr).__name__}</b></tt>"
'&nbsp;<span class="expr-tooltip">'
'<span class="tooltip-circle">?</span>'
f'<span class="tooltip-text"><em>'
'<span class="tooltip-text"><em>'
f"Do <code>op(expr)</code> to create a <tt>{expr.output_type.__name__}</tt>"
f" for <tt>{expr.method_name}</tt>."
f"<br>For example: <code>{expr._example_op}({expr_name})</code>"
Expand Down Expand Up @@ -868,7 +868,7 @@ def format_index_expression_html(expr):
f"<tt><b>gb.{type(expr).__name__}</b></tt>"
'&nbsp;<span class="expr-tooltip">'
'<span class="tooltip-circle">?</span>'
f'<span class="tooltip-text"><em>'
'<span class="tooltip-text"><em>'
f"This expression may be used to extract or assign a <tt>{expr.output_type.__name__}</tt>."
f"<br>Example extract: <code>{expr_repr}.new()</code>"
f"<br>Example assign: <code>{expr_repr} << {'M' if c == 'M' else c.lower()}</code>"
Expand Down
2 changes: 1 addition & 1 deletion graphblas/core/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def build(self, rows, columns, values, *, dup_op=None, clear=False, nrows=None,
n = values.shape[0]
if rows.size != n or columns.size != n:
raise ValueError(
f"`rows` and `columns` and `values` lengths must match: "
"`rows` and `columns` and `values` lengths must match: "
f"{rows.size}, {columns.size}, {values.size}"
)
if clear:
Expand Down
10 changes: 5 additions & 5 deletions graphblas/core/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ class ParameterizedMonoid(ParameterizedUdf):
is_commutative = True

def __init__(self, name, binaryop, identity, *, anonymous=False):
if not type(binaryop) is ParameterizedBinaryOp:
if type(binaryop) is not ParameterizedBinaryOp:
raise TypeError("binaryop must be parameterized")
self.binaryop = binaryop
self.__signature__ = binaryop.__signature__
Expand All @@ -673,10 +673,10 @@ def __init__(self, name, binaryop, identity, *, anonymous=False):
sig = inspect.signature(identity)
if sig != self.__signature__:
raise ValueError(
f"Signatures of binaryop and identity passed to "
"Signatures of binaryop and identity passed to "
f"{type(self).__name__} must be the same. Got:\n"
f" binaryop{self.__signature__}\n"
f" !=\n"
" !=\n"
f" identity{sig}"
)
self.identity = identity
Expand Down Expand Up @@ -721,10 +721,10 @@ def __init__(self, name, monoid, binaryop, *, anonymous=False):
self.__signature__ = binaryop.__signature__
if type(monoid) is ParameterizedMonoid and monoid.__signature__ != self.__signature__:
raise ValueError(
f"Signatures of monoid and binaryop passed to "
"Signatures of monoid and binaryop passed to "
f"{type(self).__name__} must be the same. Got:\n"
f" monoid{monoid.__signature__}\n"
f" !=\n"
" !=\n"
f" binaryop{self.__signature__}\n\n"
"Perhaps call monoid or binaryop with parameters before creating the semiring."
)
Expand Down
7 changes: 2 additions & 5 deletions graphblas/monoid/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,8 @@
)
_monoid_identities["minimum"].update(dict.fromkeys(_complex_dtypes, complex(_np.inf, _np.inf)))

if _config.get("mapnumpy") or not (
# To increase import speed, only call njit when `_config.get("mapnumpy")` is False
type(_numba.njit(lambda x, y: _np.fmax(x, y))(1, 2))
is float
):
# To increase import speed, only call njit when `_config.get("mapnumpy")` is False
if _config.get("mapnumpy") or type(_numba.njit(lambda x, y: _np.fmax(x, y))(1, 2)) is not float:
# See: https://github.com/numba/numba/issues/8478
_monoid_identities["fmax"].update(
{
Expand Down

0 comments on commit 97f6af4

Please sign in to comment.