Skip to content

Commit

Permalink
Replaced isnan Jinja filter with more versatile isnull filter (#138)
Browse files Browse the repository at this point in the history
* Make isnan jinja filter more potent by switching to pandas function (now also works on timedelta objects, for example)

* Rename jinja filter

Co-authored-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x and Flix6x committed May 27, 2021
1 parent b5d5bb4 commit 908f8bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions flexmeasures/ui/__init__.py
Expand Up @@ -4,7 +4,7 @@
from flask.blueprints import BlueprintSetupState
from flask import send_from_directory
from flask_security import login_required, roles_accepted
import numpy as np
import pandas as pd
import rq_dashboard
from humanize import naturaldelta

Expand Down Expand Up @@ -124,7 +124,7 @@ def add_jinja_filters(app):
app.jinja_env.filters["naturalized_timedelta"] = naturaldelta
app.jinja_env.filters["capitalize"] = capitalize
app.jinja_env.filters["parameterize"] = parameterize
app.jinja_env.filters["isnan"] = np.isnan
app.jinja_env.filters["isnull"] = pd.isnull
app.jinja_env.filters["hide_nan_if_desired"] = (
lambda x: ""
if x in ("nan", "nan%", "NAN")
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/views/portfolio.html
Expand Up @@ -147,7 +147,7 @@ <h3>Market status</h3>
<td>{{ market.display_name }}</td>
<td>{{ market.unit[:3] }}</td>
<td>
{% if not average_prices[market.name] | isnan %}
{% if not average_prices[market.name] | isnull %}
{{ "{:,.2f}".format( average_prices[market.name] ) }} {{ market.unit }}
{% else %}
Unknown for the requested period
Expand Down

0 comments on commit 908f8bb

Please sign in to comment.