Fix the commented frequency-distribution plot in experiment.presentation (#1066) - #1071
Open
ilayfalach wants to merge 1 commit into
Open
Fix the commented frequency-distribution plot in experiment.presentation (#1066)#1071ilayfalach wants to merge 1 commit into
ilayfalach wants to merge 1 commit into
Conversation
…presentation The two commented-out methods (plotNDIRFrequencyDistribution, plotMessageFrequencyDistribution) were identical except for the device type and the aggregation, so they are restored as a single working method plotFrequencyDistribution(deviceType, trialName, trialSetName, perDevice, ax). Fixes the six reasons they could not run (#1066): - plt was undefined -> local import matplotlib.pyplot, as in every other method - self.datalayer.analysisLayer -> self.analysis - getDeviceTypeTransmissionFrequency -> getDeviceTypeTransmissionFrequencyOfTrial - self.presentation.saveFigures/savePath -> self.saveFigures/self.savePath - undefined NDIR constant -> deviceType argument - long['frequency'] -> long['Frequency'] Also groupby("deviceName")["Frequency"].mean() instead of averaging the timestamp column, and makedirs on the technical/ save folder before savefig. Tests: TestPresentationFrequencyDistribution stubs the analysis layer, so it covers both aggregations and the save path without MongoDB. Closes #1066 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1066.
The two commented-out methods (
plotNDIRFrequencyDistribution,plotMessageFrequencyDistribution) were identical except for the device type and the aggregation, so they come back as one working method:perDevice=Trueaverages each device first (fraction of devices),Falseuses the raw messages (fraction of messages). The old NDIR variant is now justplotFrequencyDistribution("NDIR", trialName, perDevice=True).The six failures from the issue
pltundefinedimport matplotlib.pyplot as plt, as in every other method in the classself.datalayer.analysisLayerself.analysisgetDeviceTypeTransmissionFrequencygetDeviceTypeTransmissionFrequencyOfTrialself.presentation.saveFigures/savePathself.saveFigures/self.savePathNDIRconstantdeviceTypeargumentlong['frequency']long['Frequency']Two more that would have broken it anyway:
groupby("deviceName").mean()tried to average the timestamp column → nowgroupby("deviceName")["Frequency"].mean().savefigintosavePath/technical/failed when that folder did not exist →os.makedirs(..., exist_ok=True)first.Tests
TestPresentationFrequencyDistributioninhera/tests/test_experiment.pystubs the analysis layer, so both aggregations and the save path are covered with no MongoDB and no experiment data.hera/tests/test_experiment.py: 12 passed, 26 skipped (the skips are the DB-backed ones).Note: the old two names are gone rather than kept as wrappers —
grepshows zero callers. Say the word if you want them kept for compatibility.🤖 Generated with Claude Code