Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SineTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Thomas Bruns
SineTools
Commits
2fff5f97
Commit
2fff5f97
authored
3 years ago
by
Thomas Bruns
Browse files
Options
Downloads
Patches
Plain Diff
.
parent
c5dbf7f1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
FindPrimesBokeh.py
+76
-68
76 additions, 68 deletions
FindPrimesBokeh.py
with
76 additions
and
68 deletions
FindPrimesBokeh.py
+
76
−
68
View file @
2fff5f97
#!/usr/bin/env python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
"""
Created on Tue Dec 22 17:15:45 2020
Created on Tue Dec 22 17:15:45 2020
@author: bruns01
@author: bruns01
"""
"""
import
numpy
as
np
import
numpy
as
np
from
bokeh.io
import
curdoc
from
bokeh.io
import
curdoc
from
bokeh.layouts
import
column
,
row
from
bokeh.layouts
import
column
,
row
from
bokeh.models
import
ColumnDataSource
,
Slider
,
TextInput
from
bokeh.models
import
ColumnDataSource
,
Slider
,
TextInput
,
Div
from
bokeh.plotting
import
figure
from
bokeh.plotting
import
figure
from
primes
import
primes
from
primes
import
primes
# Set up callbacks
# Set up callbacks
def
update_data
(
attrname
,
old
,
new
):
def
update_data
(
attrname
,
old
,
new
):
f_std
=
np
.
array
([
1.0
,
1.25
,
1.6
,
2.0
,
2.5
,
3.2
,
4.0
,
5.0
,
6.3
,
8.0
])
f_std
=
np
.
array
([
1.0
,
1.25
,
1.6
,
2.0
,
2.5
,
3.2
,
4.0
,
5.0
,
6.3
,
8.0
])
p0
=
primes
[
new
]
p0
=
primes
[
new
]
# pri = primes[(primes<=10*p0) & (primes>p0)]
# pri = primes[(primes<=10*p0) & (primes>p0)]
pri
=
primes
[(
primes
<=
10
*
p0
)]
pri
=
primes
[(
primes
<=
10
*
p0
)]
d
=
[]
d
=
[]
for
fs
in
f_std
:
p
=
[]
try
:
for
fs
in
f_std
:
f1
=
(
pri
[
pri
/
p0
<=
fs
])[
-
1
]
/
p0
# lower limit
try
:
r1
=
(
f1
-
fs
)
/
fs
pr1
=
(
pri
[
pri
/
p0
<=
fs
])[
-
1
]
# lower limit prime
except
:
f1
=
pr1
/
p0
# lower limit frequency
r1
=
0.5
r1
=
(
f1
-
fs
)
/
fs
f2
=
(
pri
[
pri
/
p0
>
fs
])[
0
]
/
p0
# upper limit
except
:
r2
=
(
f2
-
fs
)
/
fs
r1
=
0.5
pr2
=
(
pri
[
pri
/
p0
>
fs
])[
0
]
# upper limit prime
r
=
r1
if
(
np
.
abs
(
r1
)
<
np
.
abs
(
r2
))
else
r2
f2
=
pr2
/
p0
# upper limit frequency
d
.
append
(
r
)
r2
=
(
f2
-
fs
)
/
fs
print
(
f1
if
(
np
.
abs
(
r1
)
<
np
.
abs
(
r2
))
else
f2
)
r
=
r1
if
(
np
.
abs
(
r1
)
<
np
.
abs
(
r2
))
else
r2
source
.
data
=
dict
(
x
=
f_std
,
y
=
np
.
array
(
d
))
d
.
append
(
r
)
base
.
value
=
"""
Base = %d
"""
%
p0
p
.
append
((
pr1
if
(
np
.
abs
(
r1
)
<
np
.
abs
(
r2
))
else
pr2
))
#print( f1 if (np.abs(r1)<np.abs(r2)) else f2)
#print( ("%d/%d" % (pr1,p0)) if (np.abs(r1)<np.abs(r2)) else ("%d/%d" % (pr2,p0)))
f_std
=
np
.
array
([
1.0
,
1.25
,
1.6
,
2.0
,
2.5
,
3.2
,
4.0
,
5.0
,
6.3
,
8.0
])
source
.
data
=
dict
(
x
=
f_std
,
y
=
np
.
array
(
d
))
p0
=
7
base
.
value
=
"""
Base = %d
"""
%
p0
deviation
.
text
=
str
(
np
.
amax
(
np
.
abs
(
d
)))
# display maximum deviation
base
=
TextInput
(
value
=
"""
Base = xx
"""
)
dd
=
100
*
np
.
amax
(
np
.
abs
(
np
.
array
(
d
)))
print
(
"
%2.2f %%
"
%
dd
)
# Set up plot
print
(
p
)
source
=
ColumnDataSource
(
data
=
dict
(
x
=
[],
y
=
[]))
f_std
=
np
.
array
([
1.0
,
1.25
,
1.6
,
2.0
,
2.5
,
3.2
,
4.0
,
5.0
,
6.3
,
8.0
])
update_data
(
"
offset
"
,
0
,
5
)
p0
=
7
plot
=
figure
(
plot_height
=
400
,
plot_width
=
800
,
title
=
"
prime ratio frequencies
"
,
base
=
TextInput
(
value
=
"""
Base = xx
"""
)
tools
=
"
crosshair,pan,reset,save,wheel_zoom
"
,
deviation
=
Div
(
text
=
"
max
"
)
x_range
=
[
1.0
,
10.0
],
y_range
=
[
-
0.1
,
0.2
])
# Set up plot
plot
.
circle
(
'
x
'
,
'
y
'
,
source
=
source
,
radius
=
.
05
)
source
=
ColumnDataSource
(
data
=
dict
(
x
=
[],
y
=
[]))
update_data
(
"
offset
"
,
0
,
5
)
# Set up widgets
offset
=
Slider
(
title
=
"
offset
"
,
value
=
5
,
start
=
0
,
end
=
50
,
step
=
1
)
plot
=
figure
(
plot_height
=
400
,
plot_width
=
800
,
title
=
"
prime ratio frequencies
"
,
tools
=
"
crosshair,pan,reset,save,wheel_zoom
"
,
offset
.
on_change
(
'
value
'
,
update_data
)
x_range
=
[
1.0
,
10.0
],
y_range
=
[
-
0.1
,
0.2
])
plot
.
circle
(
'
x
'
,
'
y
'
,
source
=
source
,
radius
=
.
05
)
# Set up layouts and add to document
inputs
=
row
(
offset
,
base
)
# Set up widgets
curdoc
().
add_root
(
column
(
inputs
,
plot
,
width
=
800
))
offset
=
Slider
(
title
=
"
offset
"
,
value
=
5
,
start
=
0
,
end
=
50
,
step
=
1
)
curdoc
().
title
=
"
Sliders
"
\ No newline at end of file
offset
.
on_change
(
'
value
'
,
update_data
)
# Set up layouts and add to document
inputs
=
row
(
offset
,
base
,
deviation
)
curdoc
().
add_root
(
column
(
inputs
,
plot
,
width
=
800
))
curdoc
().
title
=
"
Sliders
"
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