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

used get function when accessing dictionaries. updated error message … #19

Merged
1 commit merged into from
Jul 2, 2024

Conversation

m-kovalsky
Copy link
Collaborator

…handling.

src/sempy_labs/_ai.py Show resolved Hide resolved
src/sempy_labs/_connections.py Show resolved Hide resolved
src/sempy_labs/_generate_semantic_model.py Show resolved Hide resolved
src/sempy_labs/_list_functions.py Show resolved Hide resolved
src/sempy_labs/_list_functions.py Show resolved Hide resolved
src/sempy_labs/_list_functions.py Show resolved Hide resolved
src/sempy_labs/_list_functions.py Show resolved Hide resolved
src/sempy_labs/_list_functions.py Show resolved Hide resolved
new_data = {
"Object Name": pName,
"Parent Object Name": tName,
"Object Name": tName,
Copy link
Contributor

Choose a reason for hiding this comment

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

since you're repeating the column names for all types, I'd suggest to move them in variables/constants.

"Annotation Name": caName,
"Annotation Value": caValue,
}
df = pd.concat(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest to use this structure to make it more compact and readable (don't do the nested ifs, just iterate over the objects again):

    rows = []
    rows.extend([[t.Parent.Name, t.Name, "Calculation Group"] for t in tom.model.Tables])

    rows.extend([
        [t.Name, ci.Name, str(ci.ObjectType)]
        for t in tom.model.Tables
        if t.CalculationGroup is not None
        for ci in t.CalculationGroup.CalculationItems
    ])

    df = pd.DataFrame(rows, columns=["Parent Name", "Object Name", "Object Type"])

@m-kovalsky m-kovalsky closed this pull request by merging all changes into main in fb55954 Jul 2, 2024
@m-kovalsky m-kovalsky deleted the m-kovalsky/apigetclause branch July 2, 2024 09:56
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.

2 participants