Creates and returns a new randomly generated map
18793
def map(self, width, height):
        
        template = ti.load(os.path.join(script_dir, 'assets', 'template.tmx'))['map0']
        #template.set_view(0, 0, template.px_width, template.px_height)
        template.set_view(0, 0, width*template.tw, height*template.th)

        # TODO: Save the generated map.
        #epoch = int(time.time())
        #filename = 'map_' + str(epoch) + '.tmx'

        # Draw borders
        border_x = template.cells[width]
        for y in xrange(0,height+1):
            border_x[y].tile = template.cells[0][0].tile

        for x in xrange(0,width):
            template.cells[x][height].tile = template.cells[0][0].tile

        # Start within borders
        #self.recursive_division(template.cells, 3, (template.px_width/template.tw)-1, (template.px_height/template.th)-1, 0, 0)
        self.recursive_division(template.cells, 3, width, height, 0, 0)

        return template
1210905
@SafeVarargs
    public static <T> Map<T, T> createMap(T... _args) {
        Map<T, T> map = new HashMap<>();
        if (_args != null) {
            if (_args.length % 2 != 0) {
                throw new IllegalArgumentException("Even number of parameters required to create map: " + Arrays.toString(_args));
            }
            for (int i = 0; i < _args.length;) {
                map.put(_args[i], _args[i + 1]);
                i += 2;
            }
        }
        return map;
    }
902492
def generate_random_table(self):
        
        table = list(range(0, self.n))
        random.shuffle(table)
        return table
1050076
def RandomUniformInt(shape, minval, maxval, seed):
    
    if seed:
        np.random.seed(seed)
    return np.random.randint(minval, maxval, size=shape),
158652
public static MapProxy create(Map<?, ?> map) {
		return (map instanceof MapProxy) ? (MapProxy) map : new MapProxy(map);
	}
53287
def generate_random_id(method)
      data = File.open("/dev/urandom", "rb") do |f|
        f.read(64)
      end
      case method
      when :base64
        data = base64(data)
        data.gsub!("+", '')
        data.gsub!("/", '')
        data.gsub!(/==$/, '')
        return data
      when :hex
        return data.unpack('H*')[0]
      else
        raise ArgumentError, "Invalid method #{method.inspect}"
      end
    end
123128
public static Polygon newRandom(final int length, final Random random) {
		require.positive(length);
		final Polygon p = new Polygon(length);

		p._data[0] = random.nextFloat(); // r
		p._data[1] = random.nextFloat(); // g
		p._data[2] = random.nextFloat(); // b
		p._data[3] = max(0.2F, random.nextFloat()*random.nextFloat()); // a

		float px = 0.5F;
		float py = 0.5F;
		for (int k = 0; k < length; k++) {
			p._data[4 + 2*k] = px = clamp(px + random.nextFloat() - 0.5F);
			p._data[5 + 2*k] = py = clamp(py + random.nextFloat() - 0.5F);
		}
		return p;
	}
843868
public static MutableDoubleTuple createRandom(int size, Random random)
    {
       MutableDoubleTuple t = create(size);
       randomize(t, random);
       return t;
    }
970214
def _new_from_cdata(cls, cdata: Any) -> "Random":
        """"""
        self = object.__new__(cls)  # type: "Random"
        self.random_c = cdata
        return self
1263228
int[] generateUniformBitmap(int N, int Max) {
                if (N > Max)
                        throw new RuntimeException("not possible");
                int[] ans = new int[N];
                BitSet bs = new BitSet(Max);
                int cardinality = 0;
                while (cardinality < N) {
                        int v = rand.nextInt(Max);
                        if (!bs.get(v)) {
                                bs.set(v);
                                cardinality++;
                        }
                }
                int pos = 0;
                for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
                        ans[pos++] = i;
                }
                return ans;
        }
1197288
function createCacheMap() {

	if (typeof Map === 'function') {
		return new Map();
	}

	var keys = [];
	var values = [];

	function getIndex(key) {
		return keys.indexOf(key);
	}

	function get(key) {
		return values[getIndex(key)];
	}

	function has(key) {
		return getIndex(key) !== -1;
	}

	function set(key, value) {
		var index = getIndex(key);
		if (index === -1) {
			index = keys.push(key) - 1;
		}
		values[index] = value;
	}

	function deleteFunc(key) {
		var index = getIndex(key);
		if (index === -1) {
			return false;
		}
		delete keys[index];
		delete values[index];
		return true;
	}

	function forEach(callback) {
		keys.forEach(function(key, index) {
			if (key !== undefined) {
				callback(values[index], key);
			}
		});
	}

	return {
		set: set,
		get: get,
		has: has,
		delete: deleteFunc,
		forEach: forEach,
	};
}
1019058
public void generateRandom( int nbPoints, float minX, float maxX, float minY, float maxY )
	{
		xs = new ArrayList<Float>();
		ys = new ArrayList<Float>();

		for( int i = 0; i < nbPoints; i++ )
		{
			float r = (float) Math.random();
			r = (float) (((int) (r * 100)) / 100.0);
			xs.add( minX + (i * (maxX - minX) / (nbPoints - 1)) );
			ys.add( minY + r * (maxY - minY) );
		}
	}
460894
function createAndAddSlot(slotNext, indexMapForSlot) {
                    var slotNew = (indexMapForSlot === indexMap ? createPrimarySlot() : createSlot());

                    insertSlot(slotNew, slotNext);

                    return slotNew;
                }
719580
def createRandomObjects(self,
                          numObjects,
                          numPoints,
                          numLocations=None,
                          numFeatures=None):
    
    if numObjects > 0:
      if numLocations is None:
        numLocations = numPoints
      if numFeatures is None:
        numFeatures = numPoints

      assert(numPoints <= numLocations), ("Number of points in object cannot be "
            "greater than number of locations")

      locationArray = numpy.array(range(numLocations))
      numpy.random.seed(self.seed)
      for _ in xrange(numObjects):
        # Permute the number of locations and select points from it
        locationArray = numpy.random.permutation(locationArray)
        self.addObject(
          [(locationArray[p],
            numpy.random.randint(0, numFeatures)) for p in xrange(numPoints)],
        )
730547
def create(self):
        """"""
        # get json content from POST request
        content = request.environ['wsgi.input'].read(int(request.environ['CONTENT_LENGTH']))
        #content = content.decode('utf8')   mapfile interface don't like unicode strings... bad...

        # load mapfile
        mapfile = Mapfile()
        dict = simplejson.loads(content)
        mapfile.from_dict(dict)

        # create mapfile
        mapname = mapfile.get_name()
        map_pathname = h.gen_mapname()
        mapfile.to_file(os.path.join(config['mapfiles_dir'], map_pathname))

        # create map in db
        map = self._new_map_from_user(c.user, mapname, map_pathname)

        response.status = 201

        href = h.url_for(controller="mapfiles", action="show", id=map.id)
        wmsproxyurl = h.url_for(controller='mapfiles', action='wms_proxy', id=map.id)
        wmsurl = "%s?%s" %(config['mapserver_url'], urlencode({'map':os.path.join(config['mapfiles_dir'], map.filepath)}))
        return {'name': map.name, 'id': map.id, 'href': href, 'wmsurl': wmsurl, 'wmsproxyurl': wmsproxyurl}
994930
def random_init_mapping(candidate_mapping):
    
    # if needed, a fixed seed could be passed here to generate same random (to help debugging)
    random.seed()
    matched_dict = {}
    result = []
    for c in candidate_mapping:
        candidates = list(c)
        if not candidates:
            # -1 indicates no possible mapping
            result.append(-1)
            continue
        found = False
        while candidates:
            # randomly generate an index in [0, length of candidates)
            rid = random.randint(0, len(candidates) - 1)
            candidate = candidates[rid]
            # check if it has already been matched
            if candidate in matched_dict:
                candidates.pop(rid)
            else:
                matched_dict[candidate] = 1
                result.append(candidate)
                found = True
                break
        if not found:
            result.append(-1)
    return result
996357
def _sample(probability_vec):
    """"""
    return map(int,
               numpy.random.random(probability_vec.size) <= probability_vec)