-
Notifications
You must be signed in to change notification settings - Fork 50
Б12-514 Беляев Кирилл #171
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
Open
qwerty-0s
wants to merge
9
commits into
EvgrafovMichail:main
Choose a base branch
from
qwerty-0s:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
44bb89a
HW1
qwerty-0s ce7e3bb
Merge branch 'EvgrafovMichail:main' into main
qwerty-0s 1d6daa4
HW2
qwerty-0s b4f749b
Merge branch 'EvgrafovMichail:main' into main
qwerty-0s 38977ea
HW3
qwerty-0s 70a0be0
Merge branch 'EvgrafovMichail:main' into main
qwerty-0s 345fb82
HW4
qwerty-0s bbbc252
Merge branch 'EvgrafovMichail:main' into main
qwerty-0s d2e8c00
HW5
qwerty-0s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,11 +9,32 @@ def convert_from_sphere( | |
| distances: np.ndarray, | ||
| azimuth: np.ndarray, | ||
| inclination: np.ndarray, | ||
| ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ... | ||
| ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не проходит ruff format |
||
| if not distances.shape == azimuth.shape == inclination.shape: | ||
| raise ShapeMismatchError | ||
|
|
||
| x = distances * np.sin(inclination) * np.cos(azimuth) | ||
| y = distances * np.sin(inclination) * np.sin(azimuth) | ||
| z = distances * np.cos(inclination) | ||
| return x, y, z | ||
|
|
||
|
|
||
|
|
||
| def convert_to_sphere( | ||
| abscissa: np.ndarray, | ||
| ordinates: np.ndarray, | ||
| applicates: np.ndarray, | ||
| ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ... | ||
| ) -> tuple[np.ndarray, np.ndarray, np.ndarray]: | ||
|
|
||
| if not abscissa.shape == ordinates.shape == applicates.shape: | ||
| raise ShapeMismatchError | ||
|
|
||
| distances = np.sqrt(abscissa**2 + ordinates**2 + applicates**2) | ||
| azimuth = np.arctan2(ordinates, abscissa) | ||
| inclinatian = np.zeros(distances.shape) | ||
|
|
||
| not_zero = distances > 0 | ||
| devide = applicates[not_zero] / distances[not_zero] | ||
| inclinatian[not_zero] = np.arccos(devide) | ||
|
|
||
| return distances, azimuth, inclinatian | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,4 +3,18 @@ | |
|
|
||
| def get_extremum_indices( | ||
| ordinates: np.ndarray, | ||
| ) -> tuple[np.ndarray, np.ndarray]: ... | ||
| ) -> tuple[np.ndarray, np.ndarray]: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не проходит ruff format |
||
| n = len(ordinates) | ||
| if n < 3: | ||
| raise ValueError | ||
|
|
||
| ordinates_safe = ordinates[1:-1] | ||
|
|
||
| max_mask = (ordinates_safe > ordinates[:-2]) & (ordinates_safe > ordinates[2:]) | ||
| min_mask = (ordinates_safe < ordinates[:-2]) & (ordinates_safe < ordinates[2:]) | ||
| indexes = np.arange(1,n-1) | ||
|
|
||
| ans = (indexes[min_mask], indexes[max_mask]) | ||
|
|
||
| return ans | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| matplotlib==3.8.0 | ||
| numpy==1.26.1 | ||
| numpy | ||
| opencv-python-headless==4.9.0.80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,48 @@ | ||
| # ваш код (используйте функции или классы для решения данной задачи) | ||
| import json | ||
|
|
||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
|
|
||
|
|
||
| def get_data_for_plot(file_path: str) -> tuple[np.ndarray, np.ndarray]: | ||
| with open(file_path, "r") as f: | ||
| data = json.load(f) | ||
| before = np.array(data["before"]) | ||
| after = np.array(data["after"]) | ||
| return before, after | ||
|
|
||
|
|
||
| def sum_classes(before: np.ndarray, after: np.ndarray, classes=["I", "II", "III", "IV"]): | ||
| before_sum = {} | ||
| after_sum = {} | ||
| for cl in classes: | ||
| mask = before == cl | ||
| before_sum[cl] = np.sum(mask) | ||
| mask = after == cl | ||
| after_sum[cl] = np.sum(mask) | ||
| return before_sum, after_sum | ||
|
|
||
|
|
||
| classes = ["I", "II", "III", "IV"] | ||
| before, after = get_data_for_plot("data/medic_data.json") | ||
| before_sum, after_sum = sum_classes(before, after) | ||
|
|
||
| fig, ax = plt.subplots(figsize=(9, 6)) | ||
| x = np.arange(len(classes)) | ||
| ax.tick_params(labelsize=16) | ||
|
|
||
| width = 0.35 | ||
| bars1 = ax.bar(x - width / 2, before_sum.values(), width, label="before", color="cornflowerblue") | ||
| bars2 = ax.bar(x + width / 2, after_sum.values(), width, label="after", color="sandybrown") | ||
|
|
||
| ax.set_xlabel("Mitral disease stage", fontsize=16) | ||
| ax.set_ylabel("Amount of people", fontsize=16) | ||
| ax.set_title("Mitral disease stages", fontsize=16) | ||
| ax.grid(axis="y", color="#cacaca", linewidth=0.8) | ||
| ax.set_axisbelow(True) | ||
| ax.set_xticks(x) | ||
| ax.set_xticklabels(classes) | ||
| ax.legend(fontsize=16) | ||
|
|
||
| plt.savefig("class_distribution.png") | ||
| plt.show() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не проходит ruff format