Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fixes #765

Merged
merged 4 commits into from
Apr 19, 2023
Merged
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
2 changes: 2 additions & 0 deletions future_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

### Changed

- [BREAKING] `geom_dotplot()` and `geom_ydotplot()` no longer supports parameter `stat`. Only default stats make sense for these geometries.

### Fixed

- livemap: memory leak caused by a document event handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ object GeomMeta {
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.SIZE,
Aes.STROKE
)

Expand Down Expand Up @@ -166,7 +165,6 @@ object GeomMeta {
Aes.COLOR,
Aes.FILL,
Aes.LINETYPE,
Aes.SHAPE,
Aes.SIZE
)

Expand Down Expand Up @@ -282,7 +280,6 @@ object GeomMeta {
Aes.COLOR,
Aes.FILL,
Aes.ALPHA,
Aes.SIZE,
Aes.STROKE
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,7 @@ open class DotplotGeom : GeomBase(), WithWidth {
}

enum class Stackdir {
UP, DOWN, CENTER, CENTERWHOLE;

companion object {

private val ENUM_INFO = EnumInfoFactory.createEnumInfo<Stackdir>()

fun safeValueOf(v: String): Stackdir {
return ENUM_INFO.safeValueOf(v) ?: throw IllegalArgumentException(
"Unsupported stackdir: '$v'\n" +
"Use one of: up, down, center, centerwhole."
)
}
}
UP, DOWN, CENTER, CENTERWHOLE
}

override fun widthSpan(p: DataPointAesthetics, coordAes: Aes<Double>, resolution: Double, isDiscrete: Boolean): DoubleSpan? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,7 @@ class YDotplotGeom : DotplotGeom(), WithHeight {
}

enum class YStackdir {
LEFT, RIGHT, CENTER, CENTERWHOLE;

companion object {

private val ENUM_INFO = EnumInfoFactory.createEnumInfo<YStackdir>()

fun safeValueOf(v: String): YStackdir {
return ENUM_INFO.safeValueOf(v) ?: throw IllegalArgumentException(
"Unsupported stackdir: '$v'\n" +
"Use one of: left, right, center, centerwhole."
)
}
}
LEFT, RIGHT, CENTER, CENTERWHOLE
}

override fun heightSpan(p: DataPointAesthetics, coordAes: Aes<Double>, resolution: Double, isDiscrete: Boolean): DoubleSpan? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,18 @@ class GeomProtoClientSide(geomKind: GeomKind) : GeomProto(geomKind) {
geom.stackGroups = opts.getBoolean(Dotplot.STACKGROUPS)
}
if (opts.hasOwn(Dotplot.STACKDIR)) {
geom.stackDir = DotplotGeom.Stackdir.safeValueOf(opts.getString(Dotplot.STACKDIR)!!)
geom.stackDir = opts.getString(Dotplot.STACKDIR)!!.let {
when (it.lowercase()) {
"up" -> DotplotGeom.Stackdir.UP
"down" -> DotplotGeom.Stackdir.DOWN
"center" -> DotplotGeom.Stackdir.CENTER
"centerwhole" -> DotplotGeom.Stackdir.CENTERWHOLE
else -> throw IllegalArgumentException(
"Unsupported ${Dotplot.STACKDIR}: '$it'. " +
"Use one of: up, down, center, centerwhole."
)
}
}
}
if (opts.hasOwn(Dotplot.METHOD)) {
geom.method = DotplotStat.Method.safeValueOf(opts.getString(Dotplot.METHOD)!!)
Expand Down Expand Up @@ -167,7 +178,18 @@ class GeomProtoClientSide(geomKind: GeomKind) : GeomProto(geomKind) {
geom.stackGroups = opts.getBoolean(YDotplot.STACKGROUPS)
}
if (opts.hasOwn(YDotplot.STACKDIR)) {
geom.yStackDir = YDotplotGeom.YStackdir.safeValueOf(opts.getString(YDotplot.STACKDIR)!!)
geom.yStackDir = opts.getString(YDotplot.STACKDIR)!!.let {
when (it.lowercase()) {
"left" -> YDotplotGeom.YStackdir.LEFT
"right" -> YDotplotGeom.YStackdir.RIGHT
"center" -> YDotplotGeom.YStackdir.CENTER
"centerwhole" -> YDotplotGeom.YStackdir.CENTERWHOLE
else -> throw IllegalArgumentException(
"Unsupported ${YDotplot.STACKDIR}: '$it'. " +
"Use one of: left, right, center, centerwhole."
)
}
}
}
if (opts.hasOwn(YDotplot.METHOD)) {
geom.method = DotplotStat.Method.safeValueOf(opts.getString(YDotplot.METHOD)!!)
Expand Down
16 changes: 4 additions & 12 deletions python-package/lets_plot/plot/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ def geom_histogram(mapping=None, *, data=None, stat=None, position=None, show_le
**other_args)


def geom_dotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampling=None, tooltips=None,
def geom_dotplot(mapping=None, *, data=None, show_legend=None, sampling=None, tooltips=None,
binwidth=None,
bins=None,
method=None,
Expand All @@ -973,10 +973,6 @@ def geom_dotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampli
data : dict or `DataFrame` or `polars.DataFrame`
The data to be displayed in this layer. If None, the default, the data
is inherited from the plot data as specified in the call to ggplot.
stat : str, default='dotplot'
The statistical transformation to use on the data for this layer, as a string.
Supported transformations: 'identity' (leaves the data unchanged),
'dotplot' (depends on `method` parameter).
show_legend : bool, default=True
False - do not show legend for this layer.
sampling : `FeatureSpec`
Expand Down Expand Up @@ -1087,7 +1083,7 @@ def geom_dotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampli
return _geom('dotplot',
mapping=mapping,
data=data,
stat=stat,
stat=None,
position=None,
show_legend=show_legend,
sampling=sampling,
Expand Down Expand Up @@ -3433,7 +3429,7 @@ def geom_violin(mapping=None, *, data=None, stat=None, position=None, show_legen
**other_args)


def geom_ydotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampling=None, tooltips=None,
def geom_ydotplot(mapping=None, *, data=None, show_legend=None, sampling=None, tooltips=None,
binwidth=None,
bins=None,
method=None,
Expand All @@ -3459,10 +3455,6 @@ def geom_ydotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampl
data : dict or `DataFrame` or `polars.DataFrame`
The data to be displayed in this layer. If None, the default, the data
is inherited from the plot data as specified in the call to ggplot.
stat : str, default='ydotplot'
The statistical transformation to use on the data for this layer, as a string.
Supported transformations: 'identity' (leaves the data unchanged),
'ydotplot' (depends on `method` parameter).
show_legend : bool, default=True
False - do not show legend for this layer.
sampling : `FeatureSpec`
Expand Down Expand Up @@ -3587,7 +3579,7 @@ def geom_ydotplot(mapping=None, *, data=None, stat=None, show_legend=None, sampl
return _geom('ydotplot',
mapping=mapping,
data=data,
stat=stat,
stat=None,
position=None,
show_legend=show_legend,
sampling=sampling,
Expand Down