Skip to content

Commit

Permalink
Merge branch 'release-v2.0.0' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
markjonestx committed May 24, 2017
2 parents 8463082 + 490c475 commit bc6e88d
Show file tree
Hide file tree
Showing 22 changed files with 331 additions and 215 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,6 @@ virt3/

# PyCharm
.idea/

# MyPy
/.mypy_cache/
25 changes: 12 additions & 13 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
Brandon DeMello
- Initial Developer for the ISOBAR model
# Contributors to PyPWA (in Chronological Order)

Josh Pond
- Added batch farm submission
- made initial General Shell
## PyPWA Staff:
- Carlos Salgado <https://github.com/cwsalgado>
- Will Phelps <https://github.com/wphelps>
- Brandon DeMello <https://github.com/bdell>
- Stephanie Bramlett <https://github.com/skbramlett>
- Josh Pond <https://github.com/JTPond>
- Mark Jones <markjonestx@live.com> <https://github.com/Markjonestx>
- LaRay Hare <https://github.com/lmhare>

Stephanie Bramlett
- Wrote vector libraries

Mark Jones
- Added setup.py for package
- Added plugin loader
- Wrote PyFit and PySimulate
- Added logging
High School Interns:

- Ryan Wright <https://github.com/painballking>
- Ran Amplitude benchmarks on the XeonPhi
2 changes: 1 addition & 1 deletion PyPWA/builtin_plugins/minuit/minimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

class _ParserObject(internals.OptimizerOptionParser):

multiplier = -1
MULTIPLIER = -1

def __init__(self, parameters):
self._parameters = parameters
Expand Down
24 changes: 14 additions & 10 deletions PyPWA/builtin_plugins/nestle/_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
"""

import logging
from typing import Callable

import typing
import numpy

from PyPWA import AUTHOR, VERSION
from PyPWA.builtin_plugins.nestle import nested
from PyPWA.core.configurator import options
from PyPWA.core.configurator import option_tools
from PyPWA.core.configurator import options

__credits__ = ["Mark Jones"]
__author__ = AUTHOR
Expand All @@ -37,15 +38,16 @@

class NestleSetup(options.Setup):

__logger = logging.getLogger("NestleSetup." + __name__)
__loader = nested.LoadPrior()

__interface = None # type: nested.NestledSampling()
__options = None # type: option_tools.CommandOptions
__prior = None # type: typing.Any
__LOGGER = logging.getLogger(__name__ + ".NestleSetup")

def __init__(self, options_object):
# type: (option_tools.CommandOptions) -> None
self.__options = options_object
self.__loader = nested.LoadPrior()

self.__prior = None # type: Callable[[numpy.ndarray], numpy.ndarray]
self.__minimizer = None # type: nested.NestledSampling

self.__load_prior()
self.__set_minimizer()

Expand All @@ -56,7 +58,7 @@ def __load_prior(self):
self.__prior = self.__loader.prior

def __set_minimizer(self):
self.__interface = nested.NestledSampling(
self.__minimizer = nested.NestledSampling(
self.__prior, self.__options.ndim, self.__options.npoints,
self.__options.method, self.__options.update_interval,
self.__options.npdim, self.__options.maxiter,
Expand All @@ -65,14 +67,16 @@ def __set_minimizer(self):
)

def return_interface(self):
return self.__interface
# type: () -> nested.NestledSampling
return self.__minimizer


class NestlePriorFunction(options.FileBuilder):
imports = set()
functions = [
"""
def prior(x):
# type: Callable[[numpy.ndarray], numpy.ndarray]
# For information about how to use nestle's prior function, please read
# nestle's documentation at: http://kylebarbary.com/nestle/index.html
return x
Expand Down
10 changes: 5 additions & 5 deletions PyPWA/builtin_plugins/process/_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, index, kernel, communicator, level, file):
self.__logging_level = level
self.__logging_file = file
self._kernel = kernel
self._kernel.processor_id = index
self._kernel.PROCESS_ID = index
self._communicator = communicator

def run(self):
Expand All @@ -73,14 +73,14 @@ def run(self):
self.__setup_logger()
self.__set_logger()
self.__logger.debug(
"Starting logging in proc index %d" % self._kernel.processor_id
"Starting logging in proc index %d" % self._kernel.PROCESS_ID
)
self._kernel.setup()
while True:
value = self._communicator.receive()
if isinstance(value, str) and value == "DIE":
self.__logger.debug(
"Shutting down %d" % self._kernel.processor_id
"Shutting down %d" % self._kernel.PROCESS_ID
)
break
else:
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, index, single_kernel, communicator, level, file):
self.__logging_level = level
self.__logging_file = file
self._kernel = single_kernel
self._kernel.processor_id = index
self._kernel.PROCESS_ID = index
self._communicator = communicator

def run(self):
Expand All @@ -136,7 +136,7 @@ def run(self):
self.__set_logger()
self._kernel.setup()
self.__logger.debug(
"Starting logging in proc index %d" % self._kernel.processor_id
"Starting logging in proc index %d" % self._kernel.PROCESS_ID
)
self._communicator.send(self._kernel.process())
return 0
Expand Down
4 changes: 1 addition & 3 deletions PyPWA/builtin_plugins/process/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def __init__(self, interface_kernel, process_com, processes, duplex):
processing processes.
"""
self._logger = logging.getLogger(__name__)
self._logger.addHandler(logging.NullHandler())

self._com = process_com
self._interface_kernel = interface_kernel
Expand Down Expand Up @@ -157,7 +156,6 @@ def __init__(
self._interface_template = False

self._logger = logging.getLogger(__name__)
self._logger.addHandler(logging.NullHandler())

self._number_of_processes = number_of_processes

Expand Down Expand Up @@ -187,7 +185,7 @@ def main_options(self, data, process_template, interface_template):
process_template, process_data
)

self._duplex = interface_template.is_duplex
self._duplex = interface_template.IS_DUPLEX
self._interface_template = interface_template

self._interface = self._build()
Expand Down
21 changes: 18 additions & 3 deletions PyPWA/core/shared/interfaces/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
"""

import enum
from typing import Any, List
from typing import Optional as Opt

import numpy

from PyPWA import AUTHOR, VERSION
Expand All @@ -61,6 +64,7 @@
class Reader(object):

def next(self):
# type: () -> numpy.ndarray
"""
Called to get the next event from the reader.
Expand All @@ -82,6 +86,7 @@ def __exit__(self, *args):
self.close()

def close(self):
# type: () -> None
"""
Should close any open objects or streams.
"""
Expand All @@ -91,6 +96,7 @@ def close(self):
class Writer(object):

def write(self, data):
# type: (numpy.ndarray) -> None
"""
Should write the received event to the stream.
Expand All @@ -105,6 +111,7 @@ def __exit__(self, *args):
self.close()

def close(self):
# type: () -> None
"""
Should close the stream and any open streams or objects.
"""
Expand All @@ -114,6 +121,7 @@ def close(self):
class ProcessInterface(object):

def run(self, *args):
# type: (*Any) -> Any
"""
This function will start the processing of the processes, whatever was
passed through the kernel will be started with this method.
Expand All @@ -125,6 +133,7 @@ def run(self, *args):

@property
def previous_value(self):
# type: () -> Any
"""
The previous value received from the kernel interface.
Expand All @@ -133,6 +142,7 @@ def previous_value(self):
raise NotImplementedError

def stop(self, force=False):
# type: (Opt[bool]) -> None
"""
Should stop all process, threads, etc, that are being used to
calculate.
Expand All @@ -144,6 +154,7 @@ def stop(self, force=False):

@property
def is_alive(self):
# type: () -> bool
"""
Should return whether the children are still alive or have been
shutdown.
Expand All @@ -157,16 +168,18 @@ def is_alive(self):
class Kernel(object):

# process_id should be set by the Kernel Processing plugin.
processor_id = None # type: int
PROCESS_ID = None # type: int

def setup(self):
# type: () -> None
"""
Anything that should be setup in the thread or process should be
put here, this will be called only once before any calculation begins.
"""
raise NotImplementedError()

def process(self, data=False):
# type: (Opt[Any]) -> Any
"""
The actual calculation or function of the program, can optionally
support values from the main thread / process.
Expand All @@ -186,9 +199,10 @@ class KernelInterface(object):
# its first run; however, if this is true then the kernel will stay
# running and waiting for a value from the interface indefinitely until
# they are shutdown manually.
is_duplex = False
IS_DUPLEX = False

def run(self, communicator, args):
# type: (List[Any], Any) -> Any
"""
The method that will be called to begin the calculation. This is
the interface between the kernels and the calling object.
Expand All @@ -205,9 +219,10 @@ class OptimizerOptionParser(object):

# A simple multiplier that will be multiplied to the final result of
# every run call.
multiplier = 1
MULTIPLIER = 1

def convert(self, passed_value):
# type: (Any) -> Any
"""
This should take any value sent by optimizer and clean up the value
to something easier for the user to interact with if possible.
Expand Down

0 comments on commit bc6e88d

Please sign in to comment.