Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nulling-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smadani2
nulling-python
Commits
4bce6cce
Commit
4bce6cce
authored
4 years ago
by
Sepehr Madani
Browse files
Options
Downloads
Patches
Plain Diff
Refactor calculations in Visualizer
parent
3d397d94
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/visualizerUI.py
+6
-7
6 additions, 7 deletions
utils/visualizerUI.py
with
6 additions
and
7 deletions
utils/visualizerUI.py
+
6
−
7
View file @
4bce6cce
from
cmath
import
phase
from
math
import
log10
,
pi
,
sin
,
cos
from
math
import
log10
,
pi
,
sin
,
cos
,
degrees
,
radians
from
PySide2.QtCore
import
QSize
,
Qt
from
PySide2.QtWidgets
import
*
...
...
@@ -37,9 +37,10 @@ class NullingSlider(QSlider):
return
weight
def
update_value
(
self
,
weight
):
# ! This is duplicate code with Chromosome
bit_c
=
self
.
parent
.
options
.
bit_count
bit_res
=
self
.
parent
.
options
.
bit_resolution
angle
=
phase
(
weight
)
# (2*pi * value) - pi
angle
=
phase
(
weight
)
new_value
=
int
((
angle
*
2
**
bit_res
/
(
2
*
pi
))
+
0.5
*
(
2
**
bit_c
-
1
))
self
.
blockSignals
(
True
)
self
.
setValue
(
new_value
)
...
...
@@ -58,12 +59,12 @@ class NullingLineEdit(QLineEdit):
)
def
normal_value
(
self
):
angle
=
float
(
self
.
text
())
angle
=
radians
(
float
(
self
.
text
())
)
weight
=
complex
(
cos
(
angle
),
sin
(
angle
))
return
weight
def
update_value
(
self
,
value
):
self
.
setText
(
str
(
phase
(
value
)))
self
.
setText
(
str
(
degrees
(
phase
(
value
)))
)
self
.
home
(
False
)
...
...
@@ -82,8 +83,6 @@ class MainWindow(QMainWindow):
self
.
algorithm
=
algorithm
self
.
options
=
options
self
.
final_weights
=
self
.
algorithm
.
solve
()[
0
]
# self.theta_weights = [phase(x) for x in self.final_weights]
# self.normal_weights = [(angle + pi) / (2*pi) for angle in self.theta_weights]
self
.
centralWidget
=
QWidget
(
self
)
self
.
setCentralWidget
(
self
.
centralWidget
)
...
...
@@ -216,7 +215,7 @@ class MainWindow(QMainWindow):
except
ValueError
:
newValue
=
self
.
final_weights
[
ii
]
if
source
==
None
:
if
source
is
None
:
newValue
=
self
.
final_weights
[
ii
]
self
.
final_weights
[
ii
]
=
newValue
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment