# Path: spriteworld/factor_distributions.py
# _MAX_TRIES = int(1e5)
# class AbstractDistribution(object):
# class Continuous(AbstractDistribution):
# class Discrete(AbstractDistribution):
# class Mixture(AbstractDistribution):
# class Intersection(AbstractDistribution):
# class Product(AbstractDistribution):
# class SetMinus(AbstractDistribution):
# class Selection(AbstractDistribution):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def __str__(self):
#   def _get_rng(self, rng=None):
#   def keys(self):
#   def __init__(self, key, minval, maxval, dtype='float32'):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, key, candidates, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, index_for_sampling=0):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, hold_out):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, filtering):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
# 
# Path: spriteworld/sprite.py
# FACTOR_NAMES = (
#     'x',  # x-position of sprite center-of-mass (float)
#     'y',  # y-position of sprite center-of-mass (float)
#     'shape',  # shape (string)
#     'angle',  # angle in degrees (scalar)
#     'scale',  # size of sprite (float)
#     'c0',  # first color component (scalar)
#     'c1',  # second color component (scalar)
#     'c2',  # third color component (scalar)
#     'x_vel',  # x-component of velocity (float)
#     'y_vel',  # y-component of velocity (float)
# )
# _MAX_TRIES = int(1e6)
# class Sprite(object):
#   def __init__(self,
#                x=0.5,
#                y=0.5,
#                shape='square',
#                angle=0,
#                scale=0.1,
#                c0=0,
#                c1=0,
#                c2=0,
#                x_vel=0.0,
#                y_vel=0.0):
#   def _reset_centered_path(self):
#   def move(self, motion, keep_in_frame=False):
#   def update_position(self, keep_in_frame=False):
#   def contains_point(self, point):
#   def sample_contained_position(self):
#   def vertices(self):
#   def out_of_frame(self):
#   def x(self):
#   def y(self):
#   def shape(self):
#   def shape(self, s):
#   def angle(self):
#   def angle(self, a):
#   def scale(self):
#   def scale(self, s):
#   def c0(self):
#   def c1(self):
#   def c2(self):
#   def x_vel(self):
#   def y_vel(self):
#   def color(self):
#   def position(self):
#   def velocity(self):
#   def factors(self):
# 
# Path: spriteworld/sprite_generators.py
# def generate_sprites(factor_dist, num_sprites=1):
#   def _generate():
# def chain_generators(*sprite_generators):
#   def _generate():
# def sample_generator(sprite_generators, p=None):
#   def _generate():
# def shuffle(sprite_generator):
#   def _generate():


from absl.testing import absltest
from absl.testing import parameterized
from spriteworld import factor_distributions as distribs
from spriteworld import sprite
from spriteworld import sprite_generators
import numpy as np
    distribs.Discrete('shape', ['square', 'triangle']),
    distribs.Discrete('c0', [255]),
    distribs.Discrete('c1', [255]),
    distribs.Discrete('c2', [255]),
])

_distrib_1 = distribs.Product([
    distribs.Discrete('x', [0.5]),
    distribs.Discrete('y', [0.5]),
    distribs.Discrete('shape', ['hexagon', 'circle', 'star_5']),
    distribs.Discrete('c0', [255]),
    distribs.Discrete('c1', [255]),
    distribs.Discrete('c2', [255]),
])


class SpriteGeneratorTest(parameterized.TestCase):

  @parameterized.parameters(1, 2, 5)
  def testGenerateSpritesLengthType(self, num_sprites):
    g = sprite_generators.generate_sprites(_distrib_0, num_sprites=num_sprites)
    sprite_list = g()
    self.assertIsInstance(sprite_list, list)
    self.assertLen(sprite_list, num_sprites)
    self.assertIsInstance(sprite_list[0], sprite.Sprite)

  def testGenerateSpritesCallableNum(self):
    minval = 3
    maxval = 6
    num_sprites = np.random.randint(minval, maxval)

# Path: spriteworld/factor_distributions.py
# _MAX_TRIES = int(1e5)
# class AbstractDistribution(object):
# class Continuous(AbstractDistribution):
# class Discrete(AbstractDistribution):
# class Mixture(AbstractDistribution):
# class Intersection(AbstractDistribution):
# class Product(AbstractDistribution):
# class SetMinus(AbstractDistribution):
# class Selection(AbstractDistribution):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def __str__(self):
#   def _get_rng(self, rng=None):
#   def keys(self):
#   def __init__(self, key, minval, maxval, dtype='float32'):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, key, candidates, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, probs=None):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components, index_for_sampling=0):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, components):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, hold_out):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
#   def __init__(self, base, filtering):
#   def sample(self, rng=None):
#   def contains(self, spec):
#   def to_str(self, indent):
#   def keys(self):
# 
# Path: spriteworld/sprite.py
# FACTOR_NAMES = (
#     'x',  # x-position of sprite center-of-mass (float)
#     'y',  # y-position of sprite center-of-mass (float)
#     'shape',  # shape (string)
#     'angle',  # angle in degrees (scalar)
#     'scale',  # size of sprite (float)
#     'c0',  # first color component (scalar)
#     'c1',  # second color component (scalar)
#     'c2',  # third color component (scalar)
#     'x_vel',  # x-component of velocity (float)
#     'y_vel',  # y-component of velocity (float)
# )
# _MAX_TRIES = int(1e6)
# class Sprite(object):
#   def __init__(self,
#                x=0.5,
#                y=0.5,
#                shape='square',
#                angle=0,
#                scale=0.1,
#                c0=0,
#                c1=0,
#                c2=0,
#                x_vel=0.0,
#                y_vel=0.0):
#   def _reset_centered_path(self):
#   def move(self, motion, keep_in_frame=False):
#   def update_position(self, keep_in_frame=False):
#   def contains_point(self, point):
#   def sample_contained_position(self):
#   def vertices(self):
#   def out_of_frame(self):
#   def x(self):
#   def y(self):
#   def shape(self):
#   def shape(self, s):
#   def angle(self):
#   def angle(self, a):
#   def scale(self):
#   def scale(self, s):
#   def c0(self):
#   def c1(self):
#   def c2(self):
#   def x_vel(self):
#   def y_vel(self):
#   def color(self):
#   def position(self):
#   def velocity(self):
#   def factors(self):
# 
# Path: spriteworld/sprite_generators.py
# def generate_sprites(factor_dist, num_sprites=1):
#   def _generate():
# def chain_generators(*sprite_generators):
#   def _generate():
# def sample_generator(sprite_generators, p=None):
#   def _generate():
# def shuffle(sprite_generator):
#   def _generate():


# Path: tests/sprite_generators_test.py
from absl.testing import absltest
from absl.testing import parameterized
from spriteworld import factor_distributions as distribs
from spriteworld import sprite
from spriteworld import sprite_generators
import numpy as np

    distribs.Discrete('shape', ['square', 'triangle']),
    distribs.Discrete('c0', [255]),
    distribs.Discrete('c1', [255]),
    distribs.Discrete('c2', [255]),
])

_distrib_1 = distribs.Product([
    distribs.Discrete('x', [0.5]),
    distribs.Discrete('y', [0.5]),
    distribs.Discrete('shape', ['hexagon', 'circle', 'star_5']),
    distribs.Discrete('c0', [255]),
    distribs.Discrete('c1', [255]),
    distribs.Discrete('c2', [255]),
])


class SpriteGeneratorTest(parameterized.TestCase):

  @parameterized.parameters(1, 2, 5)
  def testGenerateSpritesLengthType(self, num_sprites):
    g = sprite_generators.generate_sprites(_distrib_0, num_sprites=num_sprites)
    sprite_list = g()
    self.assertIsInstance(sprite_list, list)
    self.assertLen(sprite_list, num_sprites)
    self.assertIsInstance(sprite_list[0], sprite.Sprite)

  def testGenerateSpritesCallableNum(self):
    minval = 3
    maxval = 6
    num_sprites = np.random.randint(minval, maxval)

    g = sprite_generators.generate_sprites(_distrib_0, num_sprites=num_sprites)