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

Add a check in cdf_to_xarray to ensure DEPEND_X types are string #297

Open
bryan-harter opened this issue Jan 28, 2025 · 0 comments
Open

Comments

@bryan-harter
Copy link
Member

In:

def _discover_depend_variables(vardata: Dict[str, npt.NDArray], varatts: Dict[str, Any], varprops: Dict[str, VDRInfo]) -> List[str]:
    # This loops through the variable attributes to discover which variables are the coordinates of other variables,
    # Unfortunately, there is no easy way to tell this by looking at the variable ITSELF,
    # you need to look at all variables and see if one points to it.

    depend_regex = re.compile("depend_[0-9]+$")

    list_of_depend_vars = []

    for v in varatts:
        depend_keys = [x for x in list(varatts[v].keys()) if depend_regex.match(x.lower())]
        for d in depend_keys:
            if varatts[v][d] in vardata:

It'll error out if the Depend_X attribute is anything other than a string. So first we should add a check that "d" is a string, and give an error if not.

Then we should write a unit test, and ensure it fails

@bryan-harter bryan-harter moved this from To triage to Backlog in cdflib development Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant