cosmoHammer.util package
Submodules
cosmoHammer.util.FlatPositionGenerator module
-
class
cosmoHammer.util.FlatPositionGenerator.
FlatPositionGenerator
[source]
Bases: object
Generates samples in a flat random space using
center + (random values * 2 -1) * width
-
generate
()[source]
generates the positions
-
setup
(sampler)[source]
setup the generator
cosmoHammer.util.IPythonUtil module
cosmoHammer.util.InMemoryStorageUtil module
-
class
cosmoHammer.util.InMemoryStorageUtil.
InMemoryStorageUtil
(master=True)[source]
Bases: object
Stores the data in memory
-
importFromFile
(filePath)[source]
-
importRandomState
(filePath)[source]
-
persistBurninValues
(pos, prob, data)[source]
-
persistSamplingValues
(pos, prob, data)[source]
-
storeRandomState
(filePath, randomState)[source]
cosmoHammer.util.IterationStopCriteriaStrategy module
-
class
cosmoHammer.util.IterationStopCriteriaStrategy.
IterationStopCriteriaStrategy
[source]
Bases: object
A very simple implementation of a stop criteria strategy which does not stop the sampling until the max iteration is reached.
-
hasFinished
()[source]
always returns false
-
setup
(sampler)[source]
setup the strategy
cosmoHammer.util.MpiUtil module
-
class
cosmoHammer.util.MpiUtil.
MpiPool
(mapFunction)[source]
Bases: object
Implementation of a mpi based pool. Currently it supports only the map function.
Parameters: | mapFunction – the map function to apply on the mpi nodes |
-
isMaster
()[source]
Returns true if the rank is 0
-
map
(function, sequence)[source]
Emulates a pool map function using Mpi.
Retrieves the number of mpi processes and splits the sequence of walker position
in order to allow each process its block
Parameters: |
- function – the function to apply on the items of the sequence
- sequence – a sequence of items
|
Returns sequence: |
| sequence of results
|
-
cosmoHammer.util.MpiUtil.
mergeList
(lists)[source]
Merges the lists into one single list
Parameters: | lists – a list of lists |
Returns list: | the merged list |
-
cosmoHammer.util.MpiUtil.
mpiBCast
(value)[source]
Mpi bcasts the value and Returns the value from the master (rank = 0).
-
cosmoHammer.util.MpiUtil.
splitList
(list, n)[source]
Splits the list into block of equal sizes (listlength/n)
Parameters: |
- list – a sequence of items
- n – the number of blocks to create
|
Returns sequence: |
| a list of blocks
|
cosmoHammer.util.Params module
Created on Aug 5, 2015
author: jakeret
-
class
cosmoHammer.util.Params.
Params
(*args)[source]
Bases: object
A key-value parameter store preserving the order of the params passed to the intializer.
Examples:
$ params = Params(("key1", [1,2,3]),
("key2", [1,2,3]))
$ print(params.keys)
> ['key1', 'key2']
$ print(params.key1)
> [1, 2, 3]
$ params[:,0] = 0
$ print(params.values)
> [[0 2 3]
[0 2 3]]
$ print(params[:,1])
> [2 2]
-
copy
()[source]
-
get
(key)[source]
-
keys
-
values
cosmoHammer.util.SampleBallPositionGenerator module
-
class
cosmoHammer.util.SampleBallPositionGenerator.
SampleBallPositionGenerator
[source]
Bases: object
Generates samples in a very thight n-dimensional ball
-
generate
()[source]
generates the positions
-
setup
(sampler)[source]
setup the generator
cosmoHammer.util.SampleFileUtil module
-
class
cosmoHammer.util.SampleFileUtil.
SampleFileUtil
(filePrefix, master=True, reuseBurnin=False)[source]
Bases: object
Util for handling sample files
Parameters: |
- filePrefix – the prefix to use
- master – True if the sampler instance is the master
- reuseBurnin – True if the burn in data from a previous run should be used
|
-
close
()[source]
-
finalize
()[source]
-
importFromFile
(filePath)[source]
-
importRandomState
(filePath)[source]
-
persistBurninValues
(pos, prob, data)[source]
-
persistSamplingValues
(pos, prob, data)[source]
-
persistValues
(posFile, probFile, pos, prob, data)[source]
Writes the walker positions and the likelihood to the disk
-
storeRandomState
(filePath, randomState)[source]
Module contents