backends
Implemented a framework to support multiple different backends. In particular, this should let the user "dynamically" switch between the following backend libraries for array manipulation
- numpy
- cupy
- theano.tensor
In particular, all modules will call gwdistributions.backends
to access numeric routines. In this way, we can make sure we route all the appropriate functionality through a single location and enforce shared references to "global" variables throughout the library.
This patch also implements a few changes that should make this library compatible with gwpopulations
- renamed
pdf
toprob
in allEventGenerator
andSamplingDistribution
objects - modifed
update
to accept**kwargs
instead of separate lists of parameters and names inSamplingDistribution
- I also added a
parameters
property toEventGenerator
, so that gwpopulation's calls toModel.parameters.update(thing)
are correctly resolved withinEventGenerator
. This is managed through a helper class (Parameters
), which manages shared references between itself and theEventGenerator
it belongs to. It acts like a regulardict
in most ways. -
EventGenerator
s also have__getitem__
and__setitem__
methods now, which allow immediate access to the hyperparameters. - Note, however, that such calls will not be correctly resolved if gwpopulation tries to update
SamplingDistribution
objects directly (gwpop passes adict
butSamplingDistribution
expect**kwargs
).
- I also added a
- added
__getitem__
and__setitem__
methods toEvent
. This should allow us to access data from anEvent
in the same way we would from a numpy structured array or pandas dataframe (I think). Specifically,Event
objects can now access their data with syntax likeevent[x]
instead of justgetattr(event, x)
.- this change has been implemented throughout the library, so there should be no more calls like
getattr(event, x)
orsetattr(event, x, y)
anywhere in the code (whenevent
is an instance ofEvent
).
- this change has been implemented throughout the library, so there should be no more calls like
TO DO
need to enforce the new backends framework in the following modules
gwdistributions/
- transforms/
-
base.py -
detection.py -
init.py -
location.py -
mass.py -
spin.py
-
- distributions/
-
base.py -
eccentricity.py -
external.py -
init.py -
location.py - mass/
-
individual.py -
init.py -
joint.py -
pairing.py
-
-
orientation.py -
spin.py -
time.py
-
Edited by Reed Essick