Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
- Draw geometry only once if layer has no aes mapping specified [#73]
- map: calif.housing [#140]
  • Loading branch information
alshan committed Apr 27, 2021
1 parent ba37da5 commit 1f7a9f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,13 @@ internal object SamplingUtil {
return (0 until size).map { groupMapper(it) }.distinct().toMutableList()
}

//static DataFrame randomSample(int sampleSize, DataFrame population, Random rand) {
// int popSize = population.rowCount();
// boolean pickIndices = sampleSize <= popSize / 2;
// int indexCount = pickIndices ? sampleSize : (popSize - sampleSize);
//
// Set<Integer> s = randomIndices(popSize, indexCount, rand);
// if (pickIndices) {
// return population.selectIndices(s);
// }
// return population.dropIndices(s);
//}

//private static Set<Integer> randomIndices(int indexedCollectionSize, int count, Random rand) {
// Set<Integer> indices = new HashSet<>();
// while (indices.size() < count) {
// indices.add(rand.nextInt(indexedCollectionSize));
// }
// return indices;
//}

fun xVar(data: DataFrame): Variable {
if (data.has(Stats.X)) {
return Stats.X
} else if (data.has(TransformVar.X)) {
return TransformVar.X
}
throw IllegalStateException("Can't apply sampling: couldn't deduce the (X) variable")
throw IllegalStateException("Can't apply sampling: couldn't deduce the (X) variable.")
}

fun yVar(data: DataFrame): Variable {
Expand All @@ -63,7 +43,7 @@ internal object SamplingUtil {
} else if (data.has(TransformVar.Y)) {
return TransformVar.Y
}
throw IllegalStateException("Can't apply sampling: couldn't deduce the (Y) variable")
throw IllegalStateException("Can't apply sampling: couldn't deduce the (Y) variable.")
}

fun splitRings(population: DataFrame): List<List<DoubleVector>> {
Expand All @@ -73,6 +53,7 @@ internal object SamplingUtil {

@Suppress("UNCHECKED_CAST")
val xValues = population[xVar(population)] as List<Any>

@Suppress("UNCHECKED_CAST")
val yValues = population[yVar(population)] as List<Any>
val points = DoubleVectorComponentsList(xValues, yValues)
Expand Down Expand Up @@ -109,7 +90,8 @@ internal object SamplingUtil {
)
}.reversed())
.map { p ->
var limit = min((p.second / (totalArea - areaProceed.get()) * (totalPointsLimit - pointsProceed.get())).roundToInt(),
var limit = min(
(p.second / (totalArea - areaProceed.get()) * (totalPointsLimit - pointsProceed.get())).roundToInt(),
rings[getRingIndex(p)].size
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ class LayerConfig(
val combinedMappings = plotMappings + layerMappings

var combinedData =
if (!(sharedData.isEmpty || layerData.isEmpty) && sharedData.rowCount() == layerData.rowCount()) {
if (combinedMappings.isEmpty()) {
// If layer has no mapping then no data needed.
DataFrame.Builder.emptyFrame()
} else if (!(sharedData.isEmpty || layerData.isEmpty) && sharedData.rowCount() == layerData.rowCount()) {
DataFrameUtil.appendReplace(sharedData, layerData)
} else if (!layerData.isEmpty) {
layerData
Expand Down

0 comments on commit 1f7a9f5

Please sign in to comment.