Skip to content

Commit 272c3ef

Browse files
c-blakeVindaar
andauthored
Supercedes Quiet infer by default #178 PR (#179)
* Both of these INFO: sections have the nature of debugging prints for type inference. Rather than default to this being noisy, default to quiet but allow users to `-d=ggPlotDebugTypeInfer` to be verbose. --------- Co-authored-by: Vindaar <basti90@gmail.com>
1 parent fcf3c11 commit 272c3ef

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/ggplotnim/collect_and_fill.nim

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import datamancer
1010
import ginger except Scale
1111

1212
const StartHue {.intdefine.} = 15
13+
const ggPlotDebugTypeInfer {.booldefine.} = false
1314

1415
proc addIdentityData(data: var Column, df: DataFrame, s: Scale) =
1516
case s.col.kind
@@ -55,18 +56,20 @@ proc isDiscreteData(col: Column, s: Scale, drawSamples: static bool = true,
5556
let elements = indices.mapIt(col[it, int]).toHashSet
5657
if elements.card > (indices.len.float * discreteThreshold).round.int:
5758
result = false
58-
echo "INFO: The integer column `", $s.col, "` has been automatically ",
59-
"determined to be continuous. To overwrite this behavior add a ",
60-
"`+ scale_x/y_discrete()` call to the plotting chain. Choose `x`",
61-
" or `y` depending on which axis this column refers to. Or apply a",
62-
" `factor` to the column name in the `aes` call, i.e.",
63-
" `aes(..., factor(\"" & $s.col & "\"), ...)`."
59+
when ggPlotDebugTypeInfer:
60+
echo "INFO: The integer column `", $s.col, "` has been automatically ",
61+
"determined to be continuous. To overwrite this behavior add a ",
62+
"`+ scale_x/y_discrete()` call to the plotting chain. Choose `x`",
63+
" or `y` depending on which axis this column refers to. Or apply a",
64+
" `factor` to the column name in the `aes` call, i.e.",
65+
" `aes(..., factor(\"" & $s.col & "\"), ...)`."
6466
else:
6567
result = true
66-
echo "INFO: The integer column `", $s.col, "` has been automatically ",
67-
"determined to be discrete. To overwrite this behavior add a ",
68-
"`+ scale_x/y_continuous()` call to the plotting chain. Choose `x`",
69-
" or `y` depending on which axis this column refers to."
68+
when ggPlotDebugTypeInfer:
69+
echo "INFO: The integer column `", $s.col, "` has been automatically ",
70+
"determined to be discrete. To overwrite this behavior add a ",
71+
"`+ scale_x/y_continuous()` call to the plotting chain. Choose `x`",
72+
" or `y` depending on which axis this column refers to."
7073
of colFloat:
7174
result = false
7275
of colString:
@@ -100,15 +103,17 @@ proc isDiscreteData(col: Column, s: Scale, drawSamples: static bool = true,
100103
discreteObjectCol = true
101104
if not discreteObjectCol:
102105
result = false
103-
echo "INFO: The object column `", $s.col, "` has been automatically ",
104-
"determined to be continuous. To overwrite this behavior use ",
105-
"`scale_x/y_discrete` or apply `factor` to the column name in the `aes` ",
106-
"call."
106+
when ggPlotDebugTypeInfer:
107+
echo "INFO: The object column `", $s.col, "` has been automatically ",
108+
"determined to be continuous. To overwrite this behavior use ",
109+
"`scale_x/y_discrete` or apply `factor` to the column name in the `aes` ",
110+
"call."
107111
else:
108112
result = true
109-
echo "INFO: The object column `", $s.col, "` has been automatically ",
110-
"determined to be discrete. To overwrite this behavior use ",
111-
"`scale_x/y_continuous`."
113+
when ggPlotDebugTypeInfer:
114+
echo "INFO: The object column `", $s.col, "` has been automatically ",
115+
"determined to be discrete. To overwrite this behavior use ",
116+
"`scale_x/y_continuous`."
112117
of colNone:
113118
raise newException(ValueError, "Input column " & $s.col & " is empty. Such a column " &
114119
"cannot be plotted.")

0 commit comments

Comments
 (0)