Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Docformatter #34

Merged
merged 6 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
run: |
pip install black
black --check .
- name: Docformatter
run: |
pip install docformatter
docformatter --check -r blobmodel/

pytest:

Expand Down
4 changes: 1 addition & 3 deletions blobmodel/blobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@


class Blob:
"""
A single blob
"""
"""A single blob."""

def __init__(
self,
Expand Down
8 changes: 2 additions & 6 deletions blobmodel/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@


class Geometry:
"""
Define grid for Model
"""
"""Define grid for Model."""

def __init__(
self,
Expand Down Expand Up @@ -50,9 +48,7 @@ def __init__(
)

def __str__(self) -> str:
"""
string representation of Geometry
"""
"""string representation of Geometry."""
return (
f"Geometry parameters: Nx:{self.Nx}, Ny:{self.Ny}, Lx:{self.Lx}, Ly:{self.Ly}, "
+ f"dt:{self.dt}, T:{self.T}, y-periodicity:{self.periodic_y}"
Expand Down
17 changes: 7 additions & 10 deletions blobmodel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@


class Model:
"""
2D Model of propagating blobs
"""
"""2D Model of propagating blobs."""

def __init__(
self,
Expand Down Expand Up @@ -64,16 +62,13 @@ def __init__(
self.__blob_factory = blob_factory

def __str__(self) -> str:
"""
string representation of Model
"""
"""string representation of Model."""
return f"2d Blob Model with blob shape:{self.blob_shape}, num_blobs:{self.num_blobs} and t_drain:{self.t_drain}"

def make_realization(
self, file_name: str = None, speed_up: bool = False, error: float = 1e-10
) -> xr.Dataset:
"""
Integrate Model over time and write out data as xarray dataset
"""Integrate Model over time and write out data as xarray dataset.

Parameters
----------
Expand Down Expand Up @@ -164,7 +159,9 @@ def make_realization(
return ds

def get_blobs(self) -> list[Blob]:
"""
Returns blobs list. Note that if Model.sample_blobs has not been called, the list will be empty
"""Returns blobs list.

Note that if Model.sample_blobs has not been called, the list
will be empty
"""
return self.__blobs
3 changes: 1 addition & 2 deletions blobmodel/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ def show_model(
gif_name: str = "2d_blobs.gif",
fps: int = 10,
) -> None:
"""
Show animation of Model output
"""Show animation of Model output.

Parameters
----------
Expand Down
35 changes: 16 additions & 19 deletions blobmodel/stochasticality.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@


class BlobFactory(ABC):
"""
Abstract class used by 2d propagating blob model to specify blob parameters.
"""
"""Abstract class used by 2d propagating blob model to specify blob
parameters."""

@abstractmethod
def sample_blobs(
self, Ly: float, T: float, num_blobs: int, blob_shape: str, t_drain: float
) -> list[Blob]:
"""
creates list of Blobs used in Model
"""
"""creates list of Blobs used in Model."""
raise NotImplementedError


class DefaultBlobFactory(BlobFactory):
"""
Default implementation of BlobFactory.
Generates blob parameters for different possible random distributions.
All random variables are independent from each other
"""Default implementation of BlobFactory.

Generates blob parameters for different possible random
distributions. All random variables are independent from each other
"""

def __init__(
Expand All @@ -38,15 +35,15 @@ def __init__(
vx_parameter: float = 1.0,
vy_parameter: float = 1.0,
) -> None:
"""
The following distributions are implemented:
exp: exponential distribution with mean 1
gamma: gamma distribution with `free_parameter` as shape parameter and mean 1
normal: normal distribution with zero mean and `free_parameter` as scale parameter
uniform: uniorm distribution with mean 1 and `free_parameter` as width
ray: rayleight distribution with mean 1
deg: array on ones
zeros: array of zeros
"""The following distributions are implemented:

exp: exponential distribution with mean 1
gamma: gamma distribution with `free_parameter` as shape parameter and mean 1
normal: normal distribution with zero mean and `free_parameter` as scale parameter
uniform: uniorm distribution with mean 1 and `free_parameter` as width
ray: rayleight distribution with mean 1
deg: array on ones
zeros: array of zeros
"""
self.A_dist = A_dist
self.W_dist = W_dist
Expand Down