Skip to content

Fix the commented frequency-distribution plot in experiment.presentation (#1066) - #1071

Open
ilayfalach wants to merge 1 commit into
masterfrom
ISSUE1066
Open

Fix the commented frequency-distribution plot in experiment.presentation (#1066)#1071
ilayfalach wants to merge 1 commit into
masterfrom
ISSUE1066

Conversation

@ilayfalach

Copy link
Copy Markdown
Collaborator

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:

plotFrequencyDistribution(deviceType, trialName, trialSetName=None, perDevice=False, ax=None)

perDevice=True averages each device first (fraction of devices), False uses the raw messages (fraction of messages). The old NDIR variant is now just plotFrequencyDistribution("NDIR", trialName, perDevice=True).

The six failures from the issue

# Was Now
1 plt undefined local import matplotlib.pyplot as plt, as in every other method in the class
2 self.datalayer.analysisLayer self.analysis
3 getDeviceTypeTransmissionFrequency getDeviceTypeTransmissionFrequencyOfTrial
4 self.presentation.saveFigures / savePath self.saveFigures / self.savePath
5 undefined NDIR constant the deviceType argument
6 long['frequency'] long['Frequency']

Two more that would have broken it anyway:

  • groupby("deviceName").mean() tried to average the timestamp column → now groupby("deviceName")["Frequency"].mean().
  • savefig into savePath/technical/ failed when that folder did not exist → os.makedirs(..., exist_ok=True) first.

Tests

TestPresentationFrequencyDistribution in hera/tests/test_experiment.py stubs 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 — grep shows zero callers. Say the word if you want them kept for compatibility.

🤖 Generated with Claude Code

…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>
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.

Fix code that needs to be uncommented in experiment.presentation

1 participant