Conversation
kafanovd
requested changes
Nov 2, 2023
|
|
||
| import numpy as np | ||
| from scipy.sparse import diags | ||
| from sklearn.linear_model import ElasticNet |
| from sklearn.linear_model import ElasticNet | ||
|
|
||
| # set up grid points (# = Nz) | ||
| h = np.log(bound[1]/bound[0])/(Nz - 1) # equally spaced on logscale |
|
|
||
| # construct C matrix from [1] | ||
| s_mesh, t_mesh = np.meshgrid(s, t) | ||
| C = np.exp(-t_mesh*s_mesh) |
| C *= h | ||
|
|
||
| alpha = alpha1 + alpha2 | ||
| l1_ratio = alpha1/alpha |
|
|
||
| # set up grid points (# = Nz) | ||
| h = np.log(bound[1]/bound[0])/(Nz - 1) # equally spaced on logscale | ||
| s = bound[0]*np.exp(np.arange(Nz)*h) # z (Nz by 1) |
Collaborator
There was a problem hiding this comment.
можно переменные обозвать терминами, чтобы более читабельно было
| Solution of argmin_x || Ax - b ||_2 | ||
| """ | ||
|
|
||
| from scipy.optimize import nnls |
| C = np.exp(-t_mesh*z_mesh) | ||
| C[:, 0] /= 2. | ||
| C[:, -1] /= 2. | ||
| C *= h |
Collaborator
There was a problem hiding this comment.
```
h = np.log(bound[1]/bound[0])/(Nz - 1) # equally spaced on logscale
z = bound[0]*np.exp(np.arange(Nz)*h) # z (Nz by 1)
z_mesh, t_mesh = np.meshgrid(z, t)
C = np.exp(-t_mesh*z_mesh)
C[:, 0] /= 2.
C[:, -1] /= 2.
C *= h```
У тебя этот кусок используется много раз. Можно написать метод отдельный для него, чтобы не дублировать код
| from hp import hp | ||
| from read_file import read_file | ||
| from regopt import regopt | ||
| from interface import interface |
|
|
||
| Bounds = 10.0**np.asarray(Bounds) | ||
|
|
||
| t, C, T = read_file(interface.path, dt, proc = True)# time, transients, temperatures |
Collaborator
There was a problem hiding this comment.
коммент и пробелы убрать для proc
| self.path = os.getcwd() | ||
| self._update_files() | ||
|
|
||
| def _update_files(self): |
Collaborator
There was a problem hiding this comment.
здесь тоже для всех методов типы и анотации
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.