Skip to content

Commit da9b466

Browse files
committed
code tidy
1 parent 0033d17 commit da9b466

File tree

6 files changed

+23
-18
lines changed

6 files changed

+23
-18
lines changed

countess/gui/main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,20 @@
3333

3434
preview_row_limit: Optional[int] = 10000000
3535

36-
usage = """usage: countess_gui [--log LEVEL] [INIFILE]
36+
usage = (
37+
"""usage: countess_gui [--log LEVEL] [INIFILE]
3738
3839
Start the CountESS GUI.
3940
4041
options:
4142
--help show this message & exit.
4243
--version show version
43-
--preview LIMIT set preview mode row limit (default: %d)
44+
--preview LIMIT set preview mode row limit (default: %s)
4445
--log LEVEL set log level to LEVEL
4546
INIFILE load configuration file
46-
""" % preview_row_limit
47+
"""
48+
% preview_row_limit or "NONE"
49+
)
4750

4851

4952
# import faulthandler
@@ -237,13 +240,13 @@ def notes_modified_callback(self, *_):
237240

238241
def config_change_callback(self, *_):
239242
"""Called immediately if a change to config has occurred."""
240-
logger.debug("config_change_callback")
243+
# logger.debug("config_change_callback")
241244
self.node.mark_dirty()
242245

243246
# Leave it a bit (2500ms) to see if the user is still typing, if so cancel
244247
# the previous task and make a new task for another 2.5 seconds away ...
245248
if self.config_change_task:
246-
logger.debug("config_change_callback: cancelling task")
249+
# logger.debug("config_change_callback: cancelling task")
247250
self.frame.after_cancel(self.config_change_task)
248251
self.config_change_task = self.frame.after(2500, self.config_change_task_callback)
249252

@@ -674,7 +677,6 @@ def main() -> None:
674677
logging.getLogger().addHandler(logging.handlers.QueueHandler(logging_queue))
675678
# logging.getLogger().addHandler(logging.StreamHandler())
676679

677-
678680
root = make_root()
679681
SplashScreen(root)
680682
MainWindow(root, args[0] if args else None)

countess/plugins/expression.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@
4646
"upper",
4747
}
4848
CASTOPS = {
49-
"int": "integer",
50-
"float": "float",
51-
"str": "string",
52-
"bool": "boolean",
49+
"int": "integer",
50+
"float": "float",
51+
"str": "string",
52+
"bool": "boolean",
5353
}
5454
LISTOPS = {
5555
"sum": "list_sum",

countess/plugins/pivot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def execute(
3333
pivot_cols = [p.label for p in self.columns if p.value == "Pivot" and p.label in source.columns]
3434
expand_cols = [p.label for p in self.columns if p.value == "Expand" and p.label in source.columns]
3535

36+
logger.debug("PivotPlugin.execute columns %s", source.columns)
3637
logger.debug("PivotPlugin.execute index_cols %s", index_cols)
3738
logger.debug("PivotPlugin.execute pivot_cols %s", pivot_cols)
3839
logger.debug("PivotPlugin.execute expand_cols %s", expand_cols)
@@ -66,6 +67,7 @@ def execute(
6667
query_str = f"{query_str} GROUP BY {group_str}"
6768

6869
logger.debug("PivotPlugin.execute query_str %s", query_str)
70+
rel = ddbc.sql(query_str)
6971

7072
project_str = f"COLUMNS('(.*)_{pivot_char}(.*)')"
7173
if self.default_0:
@@ -80,5 +82,6 @@ def execute(
8082
project_str = (", ".join([duckdb_escape_identifier(ic) for ic in index_cols])) + ", " + project_str
8183

8284
logger.debug("PivotPlugin.execute project_str %s", project_str)
85+
logger.debug("PivotPlugin.execute project columns %s", rel.columns)
8386

84-
return ddbc.sql(query_str).project(project_str)
87+
return rel.project(project_str)

countess/plugins/score_scale.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def __init__(self, *a, **k):
5555
super().__init__(*a, **k)
5656

5757
# override classifiers labels
58-
self.classifiers[0].label = 'Scale to 0.0'
59-
self.classifiers[1].label = 'Scale to 1.0'
58+
self.classifiers[0].label = "Scale to 0.0"
59+
self.classifiers[1].label = "Scale to 1.0"
6060

6161
def execute(
6262
self, ddbc: DuckDBPyConnection, source: DuckDBPyRelation, row_limit: Optional[int] = None

countess/plugins/vampseq.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from duckdb import DuckDBPyConnection, DuckDBPyRelation
55

66
from countess import VERSION
7-
from countess.core.parameters import FloatParam, PerNumericColumnArrayParam, TabularMultiParam, ColumnOrNoneChoiceParam
7+
from countess.core.parameters import ColumnOrNoneChoiceParam, FloatParam, PerNumericColumnArrayParam, TabularMultiParam
88
from countess.core.plugins import DuckdbSimplePlugin
99
from countess.utils.duckdb import duckdb_escape_identifier, duckdb_escape_literal
1010

@@ -23,14 +23,14 @@ class VampSeqScorePlugin(DuckdbSimplePlugin):
2323
columns = PerNumericColumnArrayParam("Columns", CountColumnParam("Column"))
2424
group_col = ColumnOrNoneChoiceParam("Group By")
2525

26-
def prepare(self, ddbc: DuckDBPyConnection, source: DuckDBPyRelation) -> None:
26+
def prepare(self, ddbc: DuckDBPyConnection, source: Optional[DuckDBPyRelation]) -> None:
2727
super().prepare(ddbc, source)
2828

2929
# set default values for weights on "count" columns
3030
if all(c.weight.value is None for c in self.columns):
31-
count_cols = [ c for c in self.columns if c.label.startswith('count') ]
31+
count_cols = [c for c in self.columns if c.label.startswith("count")]
3232
for n, c in enumerate(count_cols):
33-
c.weight.value = (n+1)/len(count_cols)
33+
c.weight.value = (n + 1) / len(count_cols)
3434

3535
def execute(
3636
self, ddbc: DuckDBPyConnection, source: DuckDBPyRelation, row_limit: Optional[int] = None

countess/plugins/variant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
StringParam,
1919
)
2020
from countess.core.plugins import DuckdbParallelTransformPlugin, DuckdbSimplePlugin
21-
from countess.utils.variant import TooManyVariationsException, find_variant_string
2221
from countess.utils.duckdb import duckdb_escape_identifier
22+
from countess.utils.variant import TooManyVariationsException, find_variant_string
2323

2424
logger = logging.getLogger(__name__)
2525

0 commit comments

Comments
 (0)