Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kwant
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
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
Michael Wimmer
kwant
Commits
4a295644
Commit
4a295644
authored
12 years ago
by
Christoph Groth
Browse files
Options
Downloads
Patches
Plain Diff
remove kwant.run module
parent
e1006005
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/source/reference/index.rst
+0
-1
0 additions, 1 deletion
doc/source/reference/index.rst
doc/source/reference/kwant.run.rst
+0
-10
0 additions, 10 deletions
doc/source/reference/kwant.run.rst
kwant/__init__.py
+1
-1
1 addition, 1 deletion
kwant/__init__.py
kwant/run.py
+0
-74
0 additions, 74 deletions
kwant/run.py
with
1 addition
and
86 deletions
doc/source/reference/index.rst
+
0
−
1
View file @
4a295644
...
...
@@ -12,7 +12,6 @@ relevance.
kwant.lattice
kwant.plotter
kwant.solvers
kwant.run
kwant.system
kwant.graph
kwant.physics
...
...
This diff is collapsed.
Click to expand it.
doc/source/reference/kwant.run.rst
deleted
100644 → 0
+
0
−
10
View file @
e1006005
:mod:`kwant.run` -- Support for running scripts from the system shell
=====================================================================
.. module:: kwant.run
.. autosummary::
:toctree: generated/
exec_argv
randomize
This diff is collapsed.
Click to expand it.
kwant/__init__.py
+
1
−
1
View file @
4a295644
__all__
=
[
'
system
'
,
'
version
'
,
'
builder
'
,
'
lattice
'
,
'
run
'
]
__all__
=
[
'
system
'
,
'
version
'
,
'
builder
'
,
'
lattice
'
]
for
module
in
__all__
:
exec
'
from . import {0}
'
.
format
(
module
)
...
...
This diff is collapsed.
Click to expand it.
kwant/run.py
deleted
100644 → 0
+
0
−
74
View file @
e1006005
"""
Support for running functions from the command line
"""
from
__future__
import
division
import
os
import
struct
import
sys
import
numpy
import
scipy
from
.version
import
version
__all__
=
[
'
randomize
'
,
'
exec_argv
'
]
numpy_version
=
numpy
.
version
.
version
if
not
numpy
.
version
.
release
:
numpy_version
+=
'
-non-release
'
scipy_version
=
scipy
.
version
.
version
if
not
scipy
.
version
.
release
:
scipy_version
+=
'
-non-release
'
def
randomize
():
"""
Seed numpy
'
s random generator according to RNG_SEED environment
variable.
If RNG_SEED is undefined or has the value
"
random
"
, the seed is read from
/dev/urandom. Otherwise, the value of RNG_SEED (which may be the decimal
representation of an 8-byte signed integer) is used as seed.
"""
try
:
seed
=
os
.
environ
[
'
RNG_SEED
'
]
except
KeyError
:
seed
=
'
random
'
if
seed
==
'
random
'
:
f
=
open
(
'
/dev/urandom
'
)
seed
=
struct
.
unpack
(
'
Q
'
,
f
.
read
(
8
))[
0
]
f
.
close
()
else
:
seed
=
int
(
seed
)
# numpy.random.seed only uses the lower 32 bits of the seed argument, so we
# split our 64 bit seed into two 32 bit numbers.
assert
seed
>=
0
and
seed
<
1
<<
64
seed_lo
=
int
((
seed
&
0xffffffff
)
-
(
1
<<
31
))
seed_hi
=
int
((
seed
>>
32
)
-
(
1
<<
31
))
numpy
.
random
.
seed
((
seed_lo
,
seed_hi
))
return
seed
def
exec_argv
(
vars
):
"""
Execute command line arguments as python statements.
First, the versions of kwant, scipy and numpy are reported on stdout.
numpy
'
s random number generator is initialized by `run.randomize()` and the
seed reported.
Then each command line argument is executed as a python statement within
the environment specified by `vars`. Most of the time `vars` should be set
to the return value of `globals()`.
"""
if
len
(
sys
.
argv
)
==
1
:
help
(
'
__main__
'
)
return
seed
=
randomize
()
print
'
#### kwant %s, scipy %s, numpy %s
'
%
\
(
version
,
scipy_version
,
numpy_version
)
print
"
#### numpy random seed: %d
"
%
seed
for
statement
in
sys
.
argv
[
1
:]:
print
"
## %s
"
%
statement
exec
statement
in
vars
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