Skip to content

Create malus_law.py #7710

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

Merged
merged 9 commits into from
Oct 27, 2022
Merged

Create malus_law.py #7710

merged 9 commits into from
Oct 27, 2022

Conversation

SparshRastogi
Copy link
Contributor

Finding the intensity of light transmitted through a polariser using Malus Law and by taking initial intensity and angle between polariser and axis as input

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Finding the intensity of light transmitted through a polariser using Malus Law and by taking initial intensity and angle between polariser and axis as input
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 27, 2022
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SparshRastogi fix the failing pre-commit (lines too long), commit my changes and then this pr will be ready for merge.
Great work!

)
# handling of values out of allowed range
final_intensity = initial_intensity * (math.cos(math.radians(angle)) ** 2)
return round(final_intensity, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why round the result?

Suggested change
return round(final_intensity, 2)
return final_intensity

You should keep the precision and round it in the tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes,thank you for the suggestion,made changes to round in the testcases instead of main code

@algorithms-keeper algorithms-keeper bot mentioned this pull request Oct 27, 2022
14 tasks
SparshRastogi and others added 2 commits October 27, 2022 15:14
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 27, 2022
SparshRastogi and others added 3 commits October 27, 2022 15:17
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
Made some changes in the error messages and the docstring testcases
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 27, 2022
SparshRastogi and others added 2 commits October 27, 2022 15:27
Made changes for the passing the precommit
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cclauss Can we get your review?
I wasn't completely sure if I should've enforced moving the imports below the docstring, so I left it. Should we enforce docstrings from line 1 and then code/imports after?

@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 27, 2022
@cclauss cclauss merged commit e906a51 into TheAlgorithms:master Oct 27, 2022
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.

3 participants