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

Added sample more feature #133

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

YangQi007
Copy link
Contributor

No description provided.

@YangQi007 YangQi007 self-assigned this Nov 26, 2024
data_broker.js Outdated
}

async _updateStats() {
async updateStats(useSampleMore = false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a pretty confusing interface. A dev would have to look at the code or documentation to understand what calling this method would do.

Rather than making this method public, lets follow the same pattern as the BED file and have a property that triggers an update when set:

Then each broker will have its owner sampling multiple that it keeps track of:

get samplingMultiplier() {
  return this._samplingMultiplier;
}
set samplingMultiplier(_) {
  this._samplingMultiplier = _;
  this._updateStats();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it works, I wasn’t convinced this morning either. I had a feeling you wouldn’t be happy with this solution. Your suggestion makes sense. I'll adjust it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes it's better to take a crack at something and see how it goes, so I don't think it was wasted effort.

data_broker.js Outdated
@@ -254,7 +254,12 @@ class DataBroker extends EventTarget {
allRegions = filterRegions(this._bedTextData.regions, validRegions);
}

const regions = sample(allRegions);
console.log("allRegions", allRegions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merge

data_broker.js Outdated
// Call either sample or sampleMore based on the parameter
const regions = useSampleMore ? sampleMore(allRegions) : sample(allRegions);

console.log("sampledRegions", regions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before merge

sampling.js Outdated
function sampleMore (inRegions) {
if (sampleMultiplier < sampleMultiplierLimit) {
sampleMultiplier += 1;
TARGET_BIN_SIZE = TARGET_BIN_SIZE + (TARGET_BIN_SIZE / 4) * sampleMultiplier;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TARGET_BIN_SIZE is uppercase because it's a constant. That's a naming convention. If we're going to modify it, it should be targetBinSize. However, we don't want to modify global variables like this. There could be another piece of code in an application that expects the sampling to use the default values, but they will be overwritten if this code is called. Instead of sharing a global, let's keep using the old function and update it to take a multiplier parameter:

function sample(inRegions, multiplier) {
  ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the code review, I want a clarification from you, if we pass the samplingMultiplier into sample() to update the TARGET_BIN_SIZE and NUM_SAMPLES. How about the expandRegion(region), because these two variables are not only used in sample().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry running behind again. Yeah I think we want to updated the other functions so that we pass down the sampling multiplier

Copy link
Member

@anderspitman anderspitman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YangQi007 this doesn't seem to be triggering more sampling for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants