Skip to content

Commit a97b11d

Browse files
remove sampling
1 parent 3a24ef0 commit a97b11d

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

ggdsl-lets-plot/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/letsplot/translator/LayerWrapper.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
package org.jetbrains.kotlinx.ggdsl.letsplot.translator
66

77
import org.jetbrains.kotlinx.ggdsl.ir.Layer
8+
import org.jetbrains.kotlinx.ggdsl.letsplot.feature.Reversed
89
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.GROUP
910
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.MERGED_GROUPS
10-
import org.jetbrains.kotlinx.ggdsl.letsplot.feature.Reversed
1111
import org.jetbrains.kotlinx.ggdsl.letsplot.position.Position
1212
import org.jetbrains.kotlinx.ggdsl.letsplot.tooltips.feature.LayerTooltips
1313
import org.jetbrains.letsPlot.Stat
1414
import org.jetbrains.letsPlot.intern.Options
1515
import org.jetbrains.letsPlot.intern.layer.LayerBase
1616
import org.jetbrains.letsPlot.pos.positionIdentity
17+
import org.jetbrains.letsPlot.sampling.samplingNone
1718

1819
internal class LayerWrapper internal constructor(private val layer: Layer, addGroups: Boolean) :
1920
LayerBase(
@@ -28,7 +29,8 @@ internal class LayerWrapper internal constructor(private val layer: Layer, addGr
2829
tooltips = (layer.features[LayerTooltips.FEATURE_NAME] as? LayerTooltips)?.wrap(),
2930
position = (layer.features[Position.FEATURE_NAME] as? Position)?.wrap() ?: positionIdentity,
3031
showLegend = true,
31-
orientation = (layer.features[Reversed.FEATURE_NAME] as? Reversed)?.wrap()
32+
orientation = (layer.features[Reversed.FEATURE_NAME] as? Reversed)?.wrap(),
33+
sampling = samplingNone
3234
) {
3335
// TODO
3436
override fun seal() = Options(

ggdsl-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/ggdsl/letsplot/translator/LayerWrapperTest.kt

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package org.jetbrains.kotlinx.ggdsl.letsplot.translator
66

77
import org.jetbrains.kotlinx.ggdsl.dsl.NamedData
88
import org.jetbrains.kotlinx.ggdsl.dsl.column.columnPointer
9+
import org.jetbrains.kotlinx.ggdsl.dsl.internal.toTyped
910
import org.jetbrains.kotlinx.ggdsl.dsl.internal.typed
1011
import org.jetbrains.kotlinx.ggdsl.dsl.internal.typedList
1112
import org.jetbrains.kotlinx.ggdsl.dsl.scaled
@@ -14,9 +15,6 @@ import org.jetbrains.kotlinx.ggdsl.ir.bindings.*
1415
import org.jetbrains.kotlinx.ggdsl.ir.scale.NonPositionalCategoricalScale
1516
import org.jetbrains.kotlinx.ggdsl.ir.scale.PositionalContinuousUnspecifiedScale
1617
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.*
17-
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.COLOR
18-
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.FILL
19-
import org.jetbrains.kotlinx.ggdsl.letsplot.internal.WIDTH
2018
import org.jetbrains.kotlinx.ggdsl.letsplot.layers.BAR
2119
import org.jetbrains.kotlinx.ggdsl.letsplot.layers.POINT
2220
import org.jetbrains.kotlinx.ggdsl.letsplot.position.Position
@@ -55,6 +53,7 @@ internal class LayerWrapperTest {
5553
"mapping" to mapOf(
5654
"fill" to "F"
5755
),
56+
"sampling" to "none",
5857
"stat" to "identity",
5958
"data" to mapOf<String, Any>(),
6059
//"shape" to 21.0,
@@ -130,6 +129,7 @@ internal class LayerWrapperTest {
130129
"y" to "VAL_V",
131130
"fill" to "BAFGA",
132131
),
132+
"sampling" to "none",
133133
"stat" to "identity",
134134
"data" to mapOf<String, Any>(),
135135
"width" to 5.0,
@@ -179,6 +179,46 @@ internal class LayerWrapperTest {
179179
180180
*/
181181
}
182+
183+
@Test
184+
fun testBarNoSampling() {
185+
val data = mapOf(
186+
"v1" to List(100) {it},
187+
"v2" to List(100) {it}
188+
)
189+
val layer = Layer(
190+
NamedData(data.toTyped()),
191+
BAR,
192+
mapOf(
193+
X to ScaledUnspecifiedDefaultPositionalMapping(
194+
X, columnPointer<Int>("v1").scaled(), typeOf<Int>()
195+
),
196+
Y to ScaledUnspecifiedDefaultPositionalMapping(
197+
Y, columnPointer<Int>("v2").scaled(), typeOf<Int>()
198+
)
199+
),
200+
mapOf(),
201+
mapOf()
202+
)
203+
204+
val wrappedLayer = LayerWrapper(layer, false)
205+
assertEquals(
206+
mapOf(
207+
"mapping" to mapOf(
208+
"x" to "v1",
209+
"y" to "v2",
210+
),
211+
"stat" to "identity",
212+
"data" to data.map {
213+
it.key to it.value.map { it.toDouble() }
214+
}.toMap(),
215+
"position" to "identity",
216+
"geom" to "bar",
217+
"sampling" to "none",
218+
),
219+
wrappedLayer.toSpec()
220+
)
221+
}
182222
}
183223

184224

ggdsl-lets-plot/src/test/kotlin/org/jetbrains/kotlinx/ggdsl/letsplot/translator/ToLetsPlotTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ToLetsPlotTest {
6060
"x" to "origin",
6161
"y" to "mpg"
6262
),
63+
"sampling" to "none",
6364
"stat" to "identity",
6465
// "data" to mapOf<String, Any>(),
6566
"shape" to 21.0,
@@ -145,6 +146,7 @@ class ToLetsPlotTest {
145146
"y" to "svalue",
146147
"fill" to "clM"
147148
),
149+
"sampling" to "none",
148150
"stat" to "identity",
149151
// "data" to mapOf<String, Any>(),
150152
"alpha" to 0.8,
@@ -180,6 +182,7 @@ class ToLetsPlotTest {
180182
"x" to "time",
181183
"y" to "svalue",
182184
),
185+
"sampling" to "none",
183186
"stat" to "identity",
184187
// "data" to mapOf<String, Any>(),
185188
"size" to 2.2,

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
kotlin.code.style=official
22
kotlin.jupyter.add.scanner=true
3-
version = 0.3.0
3+
version = 0.3.1
44

55
# Koltin
66
systemProp.kotlin_version=1.8.0

0 commit comments

Comments
 (0)