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 · 1 comment
Open

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

JoschD opened this issue Sep 23, 2022 · 1 comment
Labels
Enhancement New feature or request Feature Request

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 Enhancement New feature or request 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant