Skip to content

backends

Reed Essick requested to merge backends into master

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 to prob in all EventGenerator and SamplingDistribution objects
  • modifed update to accept **kwargs instead of separate lists of parameters and names in SamplingDistribution
    • I also added a parameters property to EventGenerator, so that gwpopulation's calls to Model.parameters.update(thing) are correctly resolved within EventGenerator. This is managed through a helper class (Parameters), which manages shared references between itself and the EventGenerator it belongs to. It acts like a regular dict in most ways.
    • EventGenerators 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 a dict but SamplingDistribution expect **kwargs).
  • added __getitem__ and __setitem__ methods to Event. This should allow us to access data from an Event 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 like event[x] instead of just getattr(event, x).
    • this change has been implemented throughout the library, so there should be no more calls like getattr(event, x) or setattr(event, x, y) anywhere in the code (when event is an instance of Event).

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

Merge request reports