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

Add components module #59

Merged
merged 27 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b23889e
Added phasorpy_dev virtual environment to gitignore
bruno-pannunzio Jan 16, 2024
f70575b
Merge remote-tracking branch 'upstream/main'
bruno-pannunzio Feb 2, 2024
eb49467
Merge branch 'main' of https://github.com/bruno-pannunzio/phasorpy
bruno-pannunzio Feb 26, 2024
a89411c
Merge branch 'main' of https://github.com/bruno-pannunzio/phasorpy
bruno-pannunzio Feb 26, 2024
ace367c
Merge branch 'main' of https://github.com/bruno-pannunzio/phasorpy
bruno-pannunzio Mar 27, 2024
8f86c20
First version of projection to line between components
bruno-pannunzio Apr 3, 2024
1259734
Divided functions into modules.`project_phasor_to_line` implemented i…
bruno-pannunzio Apr 3, 2024
f7f7326
Update on linear fraction functions
bruno-pannunzio Apr 8, 2024
634b22f
Update fractions function
bruno-pannunzio Apr 16, 2024
d1beda5
update fractional intensities function
bruno-pannunzio Apr 16, 2024
24f161c
update fraction function
bruno-pannunzio Apr 18, 2024
635b69c
Update tutorial
bruno-pannunzio Apr 22, 2024
61c6fc3
Merge branch 'phasorpy:main' into main
bruno-pannunzio Apr 22, 2024
d7d8868
Merge branch 'main' of https://github.com/bruno-pannunzio/phasorpy in…
bruno-pannunzio Apr 22, 2024
6153e99
Update to `project_phasor_to_line` and add tests for `project_phasor_…
bruno-pannunzio Apr 22, 2024
4f472d1
Discard `plot` changes
bruno-pannunzio Apr 22, 2024
2e4be72
Discard test files
bruno-pannunzio Apr 22, 2024
917bdcf
Revert "Discard `plot` changes"
bruno-pannunzio Apr 22, 2024
788f43e
Discard `plot` changes
bruno-pannunzio Apr 22, 2024
8e6e6fe
Update `components` module description
bruno-pannunzio Apr 22, 2024
342cd3c
Apply code standards
bruno-pannunzio Apr 22, 2024
a2a46cf
Minor fixes mainly to documentation of tutorial and components functions
bruno-pannunzio Apr 23, 2024
4eaa807
Minor fixes to `phasorpy_components` tutorial
bruno-pannunzio Apr 23, 2024
c115a41
Modified check for equal components in `two_fractions_from_phasor`. A…
bruno-pannunzio Apr 25, 2024
0d08625
Applied code standards.
bruno-pannunzio Apr 25, 2024
6cd8c54
Replace `math.sqrt` with `numpy.hypot` in `two_fractions_from_phasor`…
bruno-pannunzio Apr 25, 2024
c5c3a6c
Update `numpy.hypot` with `math.hypot`
bruno-pannunzio Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace math.sqrt with numpy.hypot in two_fractions_from_phasor
… and `project_phasor_to_line`
  • Loading branch information
bruno-pannunzio committed Apr 25, 2024
commit 6cd8c54873e07884874ce0db8a5b9f4af4276147
6 changes: 3 additions & 3 deletions src/phasorpy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ def project_phasor_to_line(
second_component_phasor = numpy.array(
[real_components[1], imag_components[1]]
)
total_distance_between_components = math.sqrt(
(second_component_phasor[0] - first_component_phasor[0]) ** 2
+ (second_component_phasor[1] - first_component_phasor[1]) ** 2
total_distance_between_components = numpy.hypot(
(second_component_phasor[0] - first_component_phasor[0]),
(second_component_phasor[1] - first_component_phasor[1]),
)
if math.isclose(total_distance_between_components, 0, abs_tol=1e-6):
raise ValueError('components must have different coordinates')
Expand Down
12 changes: 6 additions & 6 deletions src/phasorpy/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ def two_fractions_from_phasor(
second_component_phasor = numpy.array(
[real_components[1], imag_components[1]]
)
total_distance_between_components = math.sqrt(
(second_component_phasor[0] - first_component_phasor[0]) ** 2
+ (second_component_phasor[1] - first_component_phasor[1]) ** 2
total_distance_between_components = numpy.hypot(
(second_component_phasor[0] - first_component_phasor[0]),
(second_component_phasor[1] - first_component_phasor[1]),
)
if math.isclose(total_distance_between_components, 0, abs_tol=1e-6):
raise ValueError('components must have different coordinates')
projected_real, projected_imag = project_phasor_to_line(
real, imag, real_components, imag_components
)
distances_to_first_component = numpy.sqrt(
(numpy.array(projected_real) - first_component_phasor[0]) ** 2
+ (numpy.array(projected_imag) - first_component_phasor[1]) ** 2
distances_to_first_component = numpy.hypot(
(numpy.array(projected_real) - first_component_phasor[0]),
(numpy.array(projected_imag) - first_component_phasor[1]),
)
fraction_of_second_component = (
distances_to_first_component / total_distance_between_components
Expand Down
Loading