PolicyEngine / PolicyEngine/policyengine-uk

Replace + and * with | and & for logical operations

Open
#136 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code-health
Dominant language
Python
Stars
50
Forks
33
Avg merge
20h 58m
Merged PRs (30d)
14

Description

e.g.:

https://github.com/PSLmodels/openfisca-uk/blob/a22170e16bd85a7cfedc1bc1f50144b6a0138ea3/openfisca_uk/variables/finance/benefit/benefit.py#L133

This works because np.array(True) + np.array(True) = np.array(True), but outside of numpy, True + True = 2. pd.Series(True) + pd.Series(True) = pd.Series(True), but this throws a warning and asks to use | instead.

Replacing bool + bool with bool | bool and bool * bool with bool & bool throughout will clarify the code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with openfisca_uk/variables/finance/benefit/benefit.py at line 133, then search the repository for similar uses of + and * in boolean expressions. Replace boolean addition and multiplication with the corresponding logical operators throughout, and confirm the existing project checks still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, pandas, python
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.