<commit_before># -*- coding: utf-8 -*-

import numpy 

from collections import OrderedDict

from fuel import config
from fuel.datasets import IndexableDataset
from fuel.utils import do_not_pickle_attributes


class Spiral(IndexableDataset):
    u"""Simple toy dataset containing datapoints from a spiral on a 2d plane.

    .. plot::

        from fuel.datasets.toy import Spiral

        ds = Spiral(classes=3)
        features, position, label = ds.get_data(None, slice(0, 500))

        plt.title("Datapoints drawn from Spiral(classes=3)")
        plt.scatter(features[:,0], features[:,1], c=position)
        plt.xlim(-1.2, 1.2)
        plt.ylim(-1.2, 1.2)
        plt.show()

    Parameters
    ----------
    n_datapoints : int
        Number of datapoints to create
    cycles : float
    sd : float
    """
    def __init__(self, n_datapoints=1000, classes=1, cycles=1., sd=0.0, **kwargs):
        # Create dataset
        pos = numpy.random.uniform(size=(n_datapoints,), low=0, high=cycles)
        label = numpy.random.randint(size=(n_datapoints,), low=0, high=classes)

        radius = (2*pos+1) / 3.
        phase_offset = label * (2*numpy.pi) / classes
        
        features = numpy.zeros(shape=(n_datapoints, 2), dtype='float32')

        features[:,0] = radius * numpy.sin(2*numpy.pi*pos + phase_offset)
        features[:,1] = radius * numpy.cos(2*numpy.pi*pos + phase_offset)

        data = OrderedDict([
            ('features', features),
            ('position', pos),
            ('label', label),
        ])

        super(Spiral, self).__init__(data, **kwargs)<commit_msg>PEP8 & cleanup<commit_after># -*- coding: utf-8 -*-

import numpy

from collections import OrderedDict

from fuel.datasets import IndexableDataset


class Spiral(IndexableDataset):
    u"""Simple toy dataset containing datapoints from a spiral on a 2d plane.

    .. plot::

        from fuel.datasets.toy import Spiral

        ds = Spiral(classes=3)
        features, position, label = ds.get_data(None, slice(0, 500))

        plt.title("Datapoints drawn from Spiral(classes=3)")
        plt.scatter(features[:,0], features[:,1], c=position)
        plt.xlim(-1.2, 1.2)
        plt.ylim(-1.2, 1.2)
        plt.show()

    Parameters
    ----------
    n_datapoints : int
        Number of datapoints to create
    cycles : float
    sd : float
    """
    def __init__(self, n_datapoints=1000, classes=1, cycles=1., sd=0.0,
                 **kwargs):
        # Create dataset
        pos = numpy.random.uniform(size=n_datapoints, low=0, high=cycles)
        label = numpy.random.randint(size=n_datapoints, low=0, high=classes)

        radius = (2*pos+1) / 3.
        phase_offset = label * (2*numpy.pi) / classes

        features = numpy.zeros(shape=(n_datapoints, 2), dtype='float32')

        features[:, 0] = radius * numpy.sin(2*numpy.pi*pos + phase_offset)
        features[:, 1] = radius * numpy.cos(2*numpy.pi*pos + phase_offset)

        data = OrderedDict([
            ('features', features),
            ('position', pos),
            ('label', label),
        ])

        super(Spiral, self).__init__(data, **kwargs)
{'fraction_non_alphanumeric': 0.14035087719298245, 'fraction_numerical': 0.025199362041467305, 'mean_word_length': 2.4613686534216335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7516801', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1016, 'n_words': 232}