#!/usr/bin/env python
"""Generate fixtures."""

import os
import json
import numpy as np
from scipy.special import xlog1py

# Get the file path:
FILE = os.path.realpath(__file__)

# Extract the directory in which this file resides:
DIR = os.path.dirname(FILE)


def gen(x, y, name):
    """Generate fixture data and writes them to file.

    # Arguments

    * `x`: first parameter
    * `y`: second parameter
    * `name::str`: output filename

    # Examples

    ``` python
    python> x = random(500) * 5.0
    python> y = random(500) * 5.0
    python> gen(x, y, './data.json')
    ```
    """
    out = xlog1py(x,y)

    # Store data to be written to file as a dictionary:
    data = {
        "x": x.tolist(),
        "y": y.tolist(),
        "expected": out.tolist()
    }

    # Based on the script directory, create an output filepath:
    filepath = os.path.join(DIR, name)

    # Write the data to the output filepath as JSON:
    with open(filepath, "w") as outfile:
        json.dump(data, outfile)


def main():
    """Generate fixture data."""
    x = np.random.random(500) * 5.0
    y = np.random.random(500) * 5.0
    gen(x, y, "small_small.json")

    x = np.random.random(500) * 5.0
    y = np.random.random(500) * 100.0
    gen(x, y, "small_large.json")

    x = np.random.random(500) * 100.0
    y = np.random.random(500) * 5.0
    gen(x, y, "large_small.json")

    x = np.random.random(500) * 100.0
    y = np.random.random(500) * 100.0
    gen(x, y, "large_large.json")

if __name__ == "__main__":
    main()

#!/usr/bin/env python
"""Generate fixtures."""

import os
import json
import numpy as np
from scipy.special import xlog1py

# Get the file path:
FILE = os.path.realpath(__file__)

# Extract the directory in which this file resides:
DIR = os.path.dirname(FILE)


def gen(x, y, name):
    """Generate fixture data and writes them to file.

    # Arguments

    * `x`: first parameter
    * `y`: second parameter
    * `name::str`: output filename

    # Examples

    ``` python
    python> x = random(500) * 5.0
    python> y = random(500) * 5.0
    python> gen(x, y, './data.json')
    ```
    """
    out = xlog1py(x, y)

    # Store data to be written to file as a dictionary:
    data = {
        "x": x.tolist(),
        "y": y.tolist(),
        "expected": out.tolist()
    }

    # Based on the script directory, create an output filepath:
    filepath = os.path.join(DIR, name)

    # Write the data to the output filepath as JSON:
    with open(filepath, "w") as outfile:
        json.dump(data, outfile)


def main():
    """Generate fixture data."""
    x = np.random.random(500) * 5.0
    y = np.random.random(500) * 5.0
    gen(x, y, "small_small.json")

    x = np.random.random(500) * 5.0
    y = np.random.random(500) * 100.0
    gen(x, y, "small_large.json")

    x = np.random.random(500) * 100.0
    y = np.random.random(500) * 5.0
    gen(x, y, "large_small.json")

    x = np.random.random(500) * 100.0
    y = np.random.random(500) * 100.0
    gen(x, y, "large_large.json")


if __name__ == "__main__":
    main()

Fix lint errors