Skip to content
This repository was archived by the owner on Jan 12, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions examples/example-score-component.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 24,
"id": "e3a61836-5798-4fe6-bd93-37ddb8c939a6",
"metadata": {},
"outputs": [],
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 25,
"id": "8e828cff-7b52-41a6-a527-90b22aacd050",
"metadata": {},
"outputs": [
Expand All @@ -47,7 +47,7 @@
" 'dashboardVer1Service': {'exists': True}}"
]
},
"execution_count": 2,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -66,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 26,
"id": "7c5eef1d-69e0-4256-bddc-3188f986d06d",
"metadata": {},
"outputs": [],
Expand All @@ -76,15 +76,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 27,
"id": "d17fbd38-b380-46d6-9cac-f6c967f60281",
"metadata": {},
"outputs": [],
"source": [
"query = CubeQuery(\n",
" 'hrm_survey_answers',\n",
" ['answer_count'],\n",
" ['gender'],\n",
" 'hrmTsb',\n",
" [\"sumOfWeight\"],\n",
")\n",
"score = ScoreComponent(\n",
" query,\n",
Expand All @@ -103,7 +102,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 28,
"id": "9753dd12-449a-46c3-8f94-e388fe7174ae",
"metadata": {},
"outputs": [
Expand All @@ -112,13 +111,11 @@
"output_type": "stream",
"text": [
"display:\n",
" column: $hrm_survey_answers.answer_count\n",
" value: $hrmTsb.sumOfWeight\n",
"id: example\n",
"queries:\n",
"- dimensions:\n",
" - hrm_survey_answers.gender\n",
" measures:\n",
" - hrm_survey_answers.answer_count\n",
"- measures:\n",
" - hrmTsb.sumOfWeight\n",
"type: score\n",
"\n"
]
Expand All @@ -138,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 29,
"id": "d0914f1b-22c4-4ec4-8ef3-c4ddb7cf877c",
"metadata": {},
"outputs": [
Expand All @@ -147,15 +144,15 @@
"text/html": [
"\n",
"<div>\n",
" <p>41907 no-unit (rounded to no-digits)</p>\n",
" <p>2790178.8 no-unit (rounded to no-digits)</p>\n",
" <p>no-text</p>\n",
"</div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 6,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -174,7 +171,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 30,
"id": "59e27eab-fbd6-4a96-a948-0b2a0d808cb2",
"metadata": {},
"outputs": [
Expand All @@ -183,15 +180,15 @@
"text/html": [
"\n",
"<div>\n",
" <p>41907 % (rounded to 3)</p>\n",
" <p>2790178.8 % (rounded to 3)</p>\n",
" <p>some info text</p>\n",
"</div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 7,
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
8 changes: 4 additions & 4 deletions pytrevl/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ScoreComponent(QueryingKwargsComponent):
type = 'score'
_default: dict = {}
_kw_paths: dict = {
'column': 'column',
'value': 'value',
'digits': 'digits',
'text': 'text',
'unit': 'unit',
Expand All @@ -20,14 +20,14 @@ class ScoreComponent(QueryingKwargsComponent):
def __init__(self,
query: 'BaseCubeQuery',
id: Optional[str]=None,
column: Optional[str]=None,
value: Optional[str]=None,
digits: Optional[int]=None,
text: Optional[str]=None,
unit: Optional[str]=None,
**kwargs,
):
if column is None:
column = query[query.measures[0]]
if value is None:
value = query[query.measures[0]]

super().__init__(
**self._filter_locals(locals()),
Expand Down