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

[Feature Request]: Check for madx-compatibility #104

Open
JoschD opened this issue Sep 23, 2022 · 2 comments · May be fixed by #135
Open

[Feature Request]: Check for madx-compatibility #104

JoschD opened this issue Sep 23, 2022 · 2 comments · May be fixed by #135
Assignees
Labels
Estimate: Complicated Might need some major overhaul of the code. Priority: High Work on this! Status: In Progress Currently being worked on. Type: Feature A (suggetion for a) new feature or enhancement in functionality. Type: Release Issue preparing for a release.

Comments

@JoschD
Copy link
Member

JoschD commented Sep 23, 2022

Feature Description

Option to check for madx-compatibility on writing

Possible Implementation

into the writer add a flag: madx_compatibility with the options None (default), warn or error.
If not none it should be checked that:

a) the header contains TYPE
b) header-names do not contain spaces

... maybe more?

@JoschD JoschD added Type: Feature A (suggetion for a) new feature or enhancement in functionality. Feature Request labels Sep 23, 2022
@JoschD
Copy link
Member Author

JoschD commented Sep 23, 2022

    @pytest.mark.parametrize("file_fixture", ["_tfs_file_wise"], ids=["wise"])
    def test_madx_can_read_it(self, file_fixture, request):
        """ Use this test to assert that madx can read all our example files"""
        file_path = request.getfixturevalue(file_fixture)
        dframe = tfs.read(file_path)

        with Madx() as madx:
            madx.command.readtable(file=str(file_path), table="test_table")
            assert madx.table.test_table is not None  # check table has loaded

            # for the wise test, the header is all scrambled:
            # headers = {k.upper(): v for k, v in madx.table.test_table.summary.items()}

            # Check validity of the loaded table, here we use pandas.Series and assert_series_equal instead
            # of numpy.array_equal to allow for (very) small relative numerical differences on loading
            for column in dframe.columns:
                assert column in madx.table.test_table
                try:
                    series = dframe[column].str.lower()  # MADX converts ALL strings to lowercase
                except AttributeError:
                    series = dframe[column]

                assert_series_equal(
                    pandas.Series(madx.table.test_table[column]), series, check_names=False
                )

possible test implementation

@fsoubelet
Copy link
Member

fsoubelet commented Sep 3, 2024

Will happen at the same time as checking for MAD-NG validity, WIP in https://github.com/pylhc/tfs/tree/madng

will link PR when open

@fsoubelet fsoubelet self-assigned this Sep 9, 2024
@fsoubelet fsoubelet added this to the MAD-NG Compatibility milestone Sep 9, 2024
@fsoubelet fsoubelet added Status: In Progress Currently being worked on. Type: Release Issue preparing for a release. Estimate: Complicated Might need some major overhaul of the code. Priority: High Work on this! labels Sep 11, 2024
@fsoubelet fsoubelet linked a pull request Oct 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Estimate: Complicated Might need some major overhaul of the code. Priority: High Work on this! Status: In Progress Currently being worked on. Type: Feature A (suggetion for a) new feature or enhancement in functionality. Type: Release Issue preparing for a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants