Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Conversation

@seb5g
Copy link
Contributor

@seb5g seb5g commented Jul 15, 2025

Was creating a bug in the ordering of data plotted by bayesian and adaptive extensions

@seb5g seb5g requested a review from malik-irain July 15, 2025 14:29
@codecov
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.50%. Comparing base (fef44c6) to head (5230974).
Report is 3 commits behind head on 5.0.x_dev.

Files with missing lines Patch % Lines
src/pymodaq_data/data.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           5.0.x_dev      #46   +/-   ##
==========================================
  Coverage      76.49%   76.50%           
==========================================
  Files             17       17           
  Lines           3795     3796    +1     
==========================================
+ Hits            2903     2904    +1     
  Misses           892      892           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

seb5g added a commit to PyMoDAQ/PyMoDAQ that referenced this pull request Jul 15, 2025
Copy link
Contributor

@malik-irain malik-irain left a comment

Choose a reason for hiding this comment

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

Lots of comments to suggest renaming sort_name with sort_by_name

return dims

def get_data_from_source(self, source: DataSource, deepcopy=False) -> DataToExport:
def get_data_from_source(self, source: DataSource, deepcopy=False, sort_name=False) -> DataToExport:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have named the new parameter sort_by_name as it feels a more "boolean" name than sort_name that could seem to mean it needs a sort algorithm name

"""
source = enum_checker(DataSource, source)
return self.get_data_from_attribute('source', source, deepcopy=deepcopy)
return self.get_data_from_attribute('source', source, deepcopy=deepcopy, sort_name=sort_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

def get_data_from_attribute(self, attribute: str,
attribute_value: Any,
deepcopy=False,
sort_name=False) -> DataToExport:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

deepcopy: bool
If True, the returned data are deepcopied from the original
sort_name: bool
If True the returned data are sorted alphabetically using their name, default is False
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

selection = find_objects_in_list_from_attr_name_val(self.data, attribute, attribute_value,
return_first=False)
selection.sort(key=lambda elt: elt[0].name)
if sort_name:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

return DataToExport(name=self.name, data=data)

def get_data_from_dim(self, dim: DataDim, deepcopy=False) -> DataToExport:
def get_data_from_dim(self, dim: DataDim, deepcopy=False, sort_name=False) -> DataToExport:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

"""
dim = enum_checker(DataDim, dim)
return self.get_data_from_attribute('dim', dim, deepcopy=deepcopy)
return self.get_data_from_attribute('dim', dim, deepcopy=deepcopy, sort_name=sort_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

return self.get_data_from_attribute('dim', dim, deepcopy=deepcopy, sort_name=sort_name)

def get_data_from_dims(self, dims: List[DataDim], deepcopy=False) -> DataToExport:
def get_data_from_dims(self, dims: List[DataDim], deepcopy=False, sort_name=False) -> DataToExport:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

data = DataToExport(name=self.name)
for dim in dims:
data.append(self.get_data_from_dim(dim, deepcopy=deepcopy))
data.append(self.get_data_from_dim(dim, deepcopy=deepcopy, sort_name=sort_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

data.append(dat4)
assert data.get_data_from_dim(data_mod.DataDim['Data2D']).data == [dat1, dat4]
assert data.get_data_from_dim(data_mod.DataDim.Data2D).data == [dat1, dat4]
assert data.get_data_from_dim(data_mod.DataDim.Data2D, sort_name=True).data == [dat4, dat1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok will do!

@seb5g seb5g requested a review from malik-irain July 16, 2025 09:58
@seb5g seb5g merged commit 90483cd into 5.0.x_dev Jul 16, 2025
12 checks passed
@seb5g seb5g deleted the bugfix/sorted_filtered_data branch July 16, 2025 12:19
seb5g added a commit to PyMoDAQ/PyMoDAQ that referenced this pull request Jul 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants