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

Using reference comparison with literal values #226

Closed
Abelarm opened this issue Oct 5, 2022 · 2 comments
Closed

Using reference comparison with literal values #226

Abelarm opened this issue Oct 5, 2022 · 2 comments
Labels

Comments

@Abelarm
Copy link
Contributor

Abelarm commented Oct 5, 2022

While I was running the test on the PR #223 I noticed that in the case of test on mac-os some warning where generated where the reference comparison is/is not are used for literal values:

/home/runner/work/solcore5/solcore5/solcore/absorption_calculator/absorption_QW.py:148: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if line_shape is "Gauss":
/home/runner/work/solcore5/solcore5/solcore/absorption_calculator/absorption_QW.py:200: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if line_shape is "Gauss":
/home/runner/work/solcore5/solcore5/solcore/analytic_solar_cells/QE.py:137: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if layer.role is not 'emitter':
/home/runner/work/solcore5/solcore5/solcore/analytic_solar_cells/QE.py:152: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if junc[idx + 1].role is 'intrinsic':
/home/runner/work/solcore5/solcore5/solcore/analytic_solar_cells/QE.py:155: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if junc[idx + 2].role is 'base':
/home/runner/work/solcore5/solcore5/solcore/analytic_solar_cells/QE.py:165: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif junc[idx + 1].role is 'base':
/home/runner/work/solcore5/solcore5/solcore/poisson_drift_diffusion/QWunit.py:296: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if self.labels[index] is "well":
/home/runner/work/solcore5/solcore5/solcore/poisson_drift_diffusion/QWunit.py:305: SyntaxWarning: "is" with a literal. Did you mean "=="?
  elif self.labels[index] is "interlayer":
/home/runner/work/solcore5/solcore5/solcore/quantum_mechanics/high_level_kp_QW.py:79: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if "potentials" is graphtype:
/home/runner/work/solcore5/solcore5/solcore/quantum_mechanics/high_level_kp_QW.py:83: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if "potentialsLDOS" is graphtype:
/home/runner/work/solcore5/solcore5/solcore/quantum_mechanics/kp_QW.py:139: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if block is "U":
/home/runner/work/solcore5/solcore5/solcore/units_system/units_system.py:367: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  "%s: %s" % (dim, ", ".join([k for k in self.dimensions[dim].keys() if k is not None and k is not ""])))

To Reproduce
Go on mac-os check here

Expected behavior
Use == in case of literal values

@dalonsoa if you think is worth to fix I can work on it ( really easy one)

@Abelarm Abelarm added the bug label Oct 5, 2022
@dalonsoa
Copy link
Collaborator

dalonsoa commented Oct 7, 2022

Yes, please, go ahead with it. Solcore has a lot of legacy code that could do with some refactoring - this is one of the low hanging fruits, so pick it, for sure!

phoebe-p added a commit that referenced this issue Oct 13, 2022
[FIX] #226 Using reference comparison with literal values
@phoebe-p
Copy link
Member

Fixed by #230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants