Git Product home page Git Product logo

Comments (4)

bashtage avatar bashtage commented on July 19, 2024 1

Great. I should finish initial testing this week and be able to have it available as an option in linearmodels.

from formulaic.

bashtage avatar bashtage commented on July 19, 2024

Also strange with "y ~ 1 + -x"

from formulaic.

matthewwardrop avatar matthewwardrop commented on July 19, 2024

This is actually intended behaviour in formulaic, modulo the unhelpful error message which will be improved soon.

When parsing formulas, formulaic currently ignores whitespace, and allows people to customise the operator handling however they wish (including adding a ++ or +- operator for cases like these, or other operators of their choosing like %in%).

I personally would find formulas written like this confusing, but it looks like R coalesces ++ and +- into + and - respectively, and otherwise treats + and - as unary operators when adjacent to another operator. Patsy also coalesces ++ to +, but throws an error on +- or similar combinations.

Given that I'd like to maximise compatibility with R, I think there's a legitimate use-case here to support these kinds of operators. A naive way would be to literally add handling for operators like ++, +-, *+, *-, etc; but the number of operators you would need to be complete is a bit annoying. I think I'll add an extra step to the infix-to-ast processor that allows operators to be "greedy", effectively splitting tokenised operators into two or more operators if the beginning of the operator matches a greedy operator type. This would allow formulaic to support these use-cases without having to manually add all the possible combinations.

Any thoughts on this approach?

from formulaic.

matthewwardrop avatar matthewwardrop commented on July 19, 2024

image

from formulaic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.