Skip to content

Refactor 24 trend new - #216

Merged
krzywon merged 3 commits into
refactor_24from
refactor_24_trend_new
Sep 4, 2026
Merged

Refactor 24 trend new#216
krzywon merged 3 commits into
refactor_24from
refactor_24_trend_new

Conversation

@gonzalezma

Copy link
Copy Markdown

New trend branch created directly from refactor_24. It contains the changes done in March to the original Trend class to allow defining an arbitrary number of axes in the Trend (populated either from the metadata or by giving a list of numerical values) and new tests, as well as some improvements to address the review comments in the previous refactor_24_trend branch.

@gonzalezma
gonzalezma requested a review from krzywon June 11, 2026 15:18
@krzywon
krzywon changed the base branch from master to refactor_24 June 11, 2026 15:55
@krzywon
krzywon changed the base branch from refactor_24 to master June 11, 2026 15:55
@krzywon
krzywon changed the base branch from master to refactor_24 June 11, 2026 15:55
@krzywon

krzywon commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Yes, this is much easier to review. I'll close the other PR in favor of this one.

@krzywon krzywon mentioned this pull request Jun 11, 2026

@krzywon krzywon left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This looks like it takes into multi-dimensional trends properly. Look at the one comment I made to be sure that doesn't affect functionality before merging.

Comment thread sasdata/metadata.py
if type(self.contents) is str:
children = f"\n{header} {self.contents}"
else:
match self.contents:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This match isn't completely equivalent to the previous if/else block. If self.contents == "", the new check will give children == f"\n{header} {self.contents}", but gave an empty string before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've just restored the old behaviour by adding a check for an empty string in the case. I'm not exactly sure which is the best, but that might be a decision to make later down the line.

codescene-access[bot]

This comment was marked as outdated.

@jamescrake-merani jamescrake-merani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I added a few comments (forgot to submit the review so they didn't show up) but I think lets just get this merged in now, and we can deal with them later. They are very minor, and would probably require a bit of discussion.

Comment thread test/utest_trend.py
]

custom_test_directory = 'custom_test'
xml_file = path.join(path.dirname(__file__), "trend_test_data", "xml_test_files", "cansas1d_notitle.xml")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nowadays I prefer using importlib resources for this. Basically, it allows you to import the folder this test data folder as a regular Python module, and then read data from it.

See:
https://docs.python.org/3/library/importlib.resources.html#importlib.resources.path

But this is a very minor comment, as this implementation probably still works fine.

Comment thread sasdata/trend.py

for i, datum in enumerate(self.data):
if not isinstance(datum, SasData):
invalid_indices.append(i)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ty (a Python type checker) is complaining that this code is unreachable, probably because self.data is type hinted to be a list of SasData, so therefore datum would never not be SasData. However, I appreciate that because Python is not strictly typed, its of course not impossible that datum is not SasData. But I think that if we get into type checking variables to make sure they're the type they should be, this could expand to cover all of the fields of these classes, at which point there are already libraries (e.g. pydantic) that handle this.

Comment thread sasdata/metadata.py
if type(self.contents) is str:
children = f"\n{header} {self.contents}"
else:
match self.contents:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've just restored the old behaviour by adding a check for an empty string in the case. I'm not exactly sure which is the best, but that might be a decision to make later down the line.

codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No quality gates enabled for this code.

See analysis details in CodeScene

Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@jamescrake-merani

Copy link
Copy Markdown
Contributor

I've just rebased to resolve the merge conflict. I'll check at the technical meeting, but if there are no objections then I will merge this PR.

@krzywon
krzywon merged commit a56acd6 into refactor_24 Sep 4, 2026
17 checks passed
@krzywon
krzywon deleted the refactor_24_trend_new branch September 4, 2026 14:06
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.

3 participants