Minor (in?)consistency in terms naming with Treatment scheme
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 990
- Forks
- 106
- Avg merge
- 7d 34m
- Merged PRs (30d)
- 1
Description
We've recently ran into a pretty silly problem with terms naming when using the Treatment scheme, see below:
Imports and data prep.:
import numpy as np
from patsy import dmatrices, dmatrix, demo_data
data = demo_data("a", "b", "x1", "x2", "y", "z column")
- Single quotation marks snippet:
dmatrix("C(a, Treatment('a1')) + x1 + x2", data)
- Double quotation marks snippet:
dmatrix('C(a, Treatment("a1")) + x1 + x2', data)
Skipping the full printout, 1) gives the following terms' names:
Terms:
'Intercept' (column 0)
"C(a, Treatment('a1'))" (column 1)
'x1' (column 2)
'x2' (column 3)
while 2):
Terms:
'Intercept' (column 0)
'C(a, Treatment("a1"))' (column 1)
'x1' (column 2)
'x2' (column 3)
This inconsistency in quotation marks used in the output caused some troubles when post-processing/cleaning terms' names etc. I understand the output is consistent with the input, but it might be beneficial to standardise the output here (as in "C(a, Treatment('a1'))" -> 'C(a, Treatment("a1"))').
This seems loosely related to e.g. https://github.com/pydata/patsy/issues/40 with its long categorical names, and if the answer is similar, i.e. better not to fix things that aren't broken, maybe this can at least be mentioned in the docs? Happy to make w PR for that.
Edit:
patsy 0.5.1
Python 2.7.5 (I know...)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two dmatrix examples from the issue with patsy 0.5.1 and compare the resulting term names. Trace the term-naming entry point used by dmatrix; done means either consistent quotation normalization is implemented with regression coverage, or the behavior is documented as intentional.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100