Skip to content

Fix nested ordering in Formula instances, and reduce redundant operations in Structured preparation.#200

Merged
matthewwardrop merged 1 commit intomainfrom
fix_nested_ordering
Nov 16, 2024
Merged

Fix nested ordering in Formula instances, and reduce redundant operations in Structured preparation.#200
matthewwardrop merged 1 commit intomainfrom
fix_nested_ordering

Conversation

@matthewwardrop
Copy link
Copy Markdown
Owner

@matthewwardrop matthewwardrop commented Nov 16, 2024

from formulaic import Formula

{
"degree": Formula("z + z:a + z:b:a + g"),
"none": Formula("z + z:a + z:b:a + g", _ordering="none"),
"sort": Formula("z + z:a + z:b:a + g", _ordering="sort"),
}

{
"degree": Formula("c ~ z + z:a + z:b:a + g").rhs,
"none": Formula("c ~ z + z:a + z:b:a + g", _ordering="none").rhs,
"sort": Formula("c ~ z + z:a + z:b:a + g", _ordering="sort").rhs,
}

Both now output:

{
"degree": Formula("c ~ z + z:a + z:b:a + g").rhs,
"none": Formula("c ~ z + z:a + z:b:a + g", _ordering="none").rhs,
"sort": Formula("c ~ z + z:a + z:b:a + g", _ordering="sort").rhs,
}

Formerly, the terms would always be sorted at least by degree in the latter case.

closes: #191

@matthewwardrop matthewwardrop merged commit 2804b5b into main Nov 16, 2024
@matthewwardrop matthewwardrop deleted the fix_nested_ordering branch November 16, 2024 06:41
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.

_ordering="none" is ignored when a dependent variable is included

1 participant