{# Default way of showing errors #} {% macro render_error(message) -%}
Error

{{ message }}

{%- endmacro %} {# Default macro for showing/wrapping the fetch results #} {% macro render_fetch_results(content, error) -%} {% if error %} {{ render_error(error) }} {% else %} {% if content is undefined %} {{ render_error("Some content expected but none was found.") }} {% else %} {{ caller() }} {% endif %} {% endif %} {%- endmacro %} {# draw a generic pandas table#} {% macro render_pandas_table(df, caption, column_labels={}) -%} {% if (df is defined) and (df is not none) %} {% for column in df.columns %} {% if column in column_labels %} {% else %} {% endif %} {% endfor %} {% for idx, row in df.iterrows() %} {% for colname in df.columns %} {# handle decimal format: float, float64, float32 #} {% if 'float' in (df.dtypes[colname] | string) %} {% else %} {% endif %} {% endfor %} {% endfor %}
{{ column_labels[column] }}{{ column }}
{{ row[colname] | round(precision=2) }}{{ row[colname]|e }}
{{ caption }}
{% else %} {{ render_error("How did you get here? did you forget to use 'render_fetch_results' macro?") }} {% endif %} {%- endmacro %} {% macro render_class_fingerprint(content, class_uri, graph_uri, namespaces) -%} {# fingerprint resultset signature #} {% set labels = { "subject_class" : "Subject class", "subject_count": "Subjects using property", "object_count": "Distinct values used", "property": "Property URI", "property_types": "Property kind", "object_types": "Value type", "min": "Min", "max": "Max", "avg": "Avg",} %} {# {% set substituted_content = replace_strings_in_tabular(content,#} {# target_columns=['property','property_types','object_types','subject_class'],#} {# value_mapping_dict=namespaces,#} {# mark_touched_rows=False ) %}#} {% set compress_uris = simplify_uri_columns_in_tabular(data_frame=content,namespace_inventory=namespaces,error_fail=False) %} {% set table_title = "The shape of " + class_uri|safe + " class instances" %} {{ render_pandas_table(compress_uris[["property","subject_count","min", "max", "avg", "property_types", "object_count","object_types"]], table_title, column_labels=labels) }} {%- endmacro %} {% macro render_namespaces(namesapces_dist) %} {% for prefix, uri in namesapces_dist|dictsort %} {% endfor %}
Namespace URI
{{ prefix }} {{ uri }}
Prefixes
{% endmacro %}