Ejemplo n.º 1
0
    def clone_on_move(self, robot: constants.Robot, robot_position: tuple):
        new_robots_pos = dict(self.robot_positions)
        prev_robot_position = new_robots_pos[robot]
        new_robots_pos[robot] = robot_position

        new_board = Board(new_robots_pos, self.goal_positions,
                          self.board.copy())

        new_board.board[prev_robot_position[0]] = new_board.board[
            prev_robot_position[0]].copy()
        prev_case = new_board.board[prev_robot_position[0]][
            prev_robot_position[1]]
        new_board.board[prev_robot_position[0]][prev_robot_position[1]] = Case(
            prev_case.i,
            prev_case.j,
            prev_case.goal,
            prev_case.laser,
            prev_case.walls,
            None,
        )

        if robot_position[0] != prev_robot_position[0]:
            new_board.board[robot_position[0]] = new_board.board[
                robot_position[0]].copy()

        new_case = new_board.board[robot_position[0]][robot_position[1]]
        new_board.board[robot_position[0]][robot_position[1]] = Case(
            new_case.i, new_case.j, new_case.goal, new_case.laser,
            new_case.walls, robot)
        return new_board
Ejemplo n.º 2
0
 def __init__(self, direction, length):
     self.tete = Case(random.randint(length, 24 - length),
                      random.randint(length, 24 - length))
     self.queue = []
     for i in range(length - 1):
         self.queue.append(
             Case(self.tete.x - (i + 1) * direction[0],
                  self.tete.y - (i + 1) * direction[1]))
Ejemplo n.º 3
0
def initialize_grid(width, height, nb):
    #Building the window frame
    width_pixel = 24 * width
    height_pixel = 24 * height
    window = pygame.display.set_mode((width_pixel, height_pixel))
    mines = []
    score_to_reach = width * height - nb

    #Building the grid object and placing the mines
    grid = []
    if nb == 0:
        for i in range(height):
            line = []
            for j in range(width):
                line.append(Case(i, j, window, "Empty"))
            grid.append(line)
    elif nb > width * height:
        for i in range(height):
            line = []
            for j in range(width):
                line.append(Case(i, j, window, "RevealedMine"))
            grid.append(line)
    else:
        if width * height > 2 * nb:
            for i in range(height):
                line = []
                for j in range(width):
                    line.append(Case(i, j, window, "Empty"))
                grid.append(line)
            mines_posed = 0
            while mines_posed < nb:
                i = randint(0, height - 1)
                j = randint(0, width - 1)
                if grid[i][j].value == "Empty":
                    grid[i][j].set_value("RevealedMine")
                    mines.append({"i": i, "j": j})
                    mines_posed += 1
        else:
            for i in range(height):
                line = []
                for j in range(width):
                    line.append(Case(i, j, window, "RevealedMine"))
                grid.append(line)
                empty_posed = 0
            while empty_posed < width * height - nb:
                i = randint(0, height - 1)
                j = randint(0, width - 1)
                if grid[i][j].value == "RevealedMine":
                    grid[i][j].set_value("Empty")
                    empty_posed += 1

    #Setting the cases values when next to a mine
    for line in grid:
        for case in line:
            if case.value == "RevealedMine":
                voisins = neighbors(case.i, case.j, grid)
                for voisin in voisins:
                    voisin.increment_value()
Ejemplo n.º 4
0
def case(selector, sources, schedulerOrDefaultSource=None):
  assert callable(selector)
  assert isinstance(sources, dict)

  if schedulerOrDefaultSource == None:
    return Case(selector, sources, Observable.empty())
  elif isinstance(schedulerOrDefaultSource, Scheduler):
    return Case(selector, sources, Observable.empty(schedulerOrDefaultSource))
  else:
    assert isinstance(schedulerOrDefaultSource, Observable)

    return Case(selector, sources, schedulerOrDefaultSource)
Ejemplo n.º 5
0
def creer_labyrinthe_depuis_chaine(chaine):
    position_du_robot = (0, 0)
    lab = Labyrinthe()
    lignes = chaine.split("\n")
    for i, ligne in enumerate(lignes):
        for j, c in enumerate(ligne):
            if c == lab.get_robot():
                case = Case(nature=" ", robot=True)
                position_du_robot = (i, j)
            else:
                case = Case(nature=c, robot=False)
            lab.insert_une_case((i, j), case)
Ejemplo n.º 6
0
    def organize_cases(self):
        ca = np.array(self.cases)
        np.random.shuffle(ca)  # Randomly shuffle all cases
        if self.config.scale_input and type(self.config.scale_input[0]) is str and "minmaxcolumns" in \
                self.config.scale_input[0]:
            print("Scaling inputs with minmaxcolumns")
            labels = ca[:, -1]
            ca = np.delete(ca, -1, axis=1)  # remove label
            ca = np.apply_along_axis(scale1DArrayMinMax, 1, ca)
            ca = np.insert(ca, ca.shape[1], labels, axis=1)

        # Handle case fraction
        ca = ca[:round(len(ca) * self.case_fraction)]
        ca = ca.tolist()

        self.cases = self.cases[:round(len(self.cases) * self.case_fraction)]

        separator1 = round(len(self.cases) * self.training_fraction)
        separator2 = separator1 + round(
            len(self.cases) * self.validation_fraction)
        self.training_cases = ca[:separator1]
        self.training_cases = self.createCases(self.training_cases)

        self.validation_cases = ca[separator1:separator2]
        self.validation_cases = self.createCases(self.validation_cases)

        self.testing_cases = ca[separator2:]
        self.testing_cases = self.createCases(self.testing_cases)

        if self.config.scale_input and type(self.config.scale_input[0]) is int:
            print("Scale input to ", self.config.scale_input)

            for x in self.training_cases:
                x.input = scaleArray(x.input, self.config.scale_input[0],
                                     self.config.scale_input[1])
            for x in self.validation_cases:
                x.input = scaleArray(x.input, self.config.scale_input[0],
                                     self.config.scale_input[1])
            for x in self.testing_cases:
                x.input = scaleArray(x.input, self.config.scale_input[0],
                                     self.config.scale_input[1])

        if self.labels:
            self.training_cases = [
                Case(input=self.training_cases[i], target=self.labels[i])
                for i in range(len(self.training_cases))
            ]
            self.training_cases = [
                Case(input=case[:-1], target=[case[-1]])
                for case in self.training_cases
            ]
Ejemplo n.º 7
0
    def __init__(self, name, mesh, timestep, staggering, fvSchemes, parallel,
                 fast, fastMesh):
        self.case = Case(name)
        self.fast = fast

        if self.fast:
            fvSchemes = os.path.join('src/schaerWaves/linearUpwindFast')
            mesh = fastMesh
            timestep = 120

        self.timing = Timing(18000, 3600, timestep)
        self.staggering = staggering
        self.sampleDict = os.path.join('src/schaerWaves/sampleLine')

        self.dynamicsExecution = DynamicsExecution(
            self.case,
            mesh,
            self.timing,
            self.staggering,
            StratifiedThermalField(),
            os.path.join('src/schaerWaves/Uf'),
            os.path.join('src/schaerWaves/Exner_init'),
            os.path.join('src/schaerWaves/environmentalProperties'),
            os.path.join('src/schaerWaves/thermophysicalProperties'),
            fvSchemes,
            os.path.join('src/schaerWaves/fvSolution'),
            sponge=True,
            parallel=parallel)
Ejemplo n.º 8
0
def load_case(filename, name=None, exclude_pattern=".*#.*"):
    """
    Load a Case object from the given file. This assumes a number of names for objects found in the file.
    """
    dat = load_mat(filename, exclude_pattern)

    if name is None:
        name = os.path.basename(filename)

    nodes = dat["userdata/surface/triRep/X"].T
    inds = dat["userdata/surface/triRep/Triangulation"].T - 1
    act, bip = dat["userdata/surface/act_bip"]
    uni, imp, frc = dat["userdata/surface/uni_imp_frc"]

    fields = dict(act=act, bip=bip, uni=uni, imp=imp, frc=frc)
    electric = {}
    rf = {}
    other_data = {}

    for k, v in dat.items():
        _, section, *objname = k.split("/", 2)

        if objname and section in ("electric", "rf"):
            dobj = rf if section == "rf" else electric
            dobj[objname[0]] = v
        else:
            other_data[k] = v

    return Case(name, nodes, inds, fields, electric, rf, other_data)
Ejemplo n.º 9
0
 def generate(self):
     """Generate random cases for the board."""
     x, y = self.position
     sx, sy = self.size
     self.cases = [
         Case([x, y - sy // 2], color=colors.random()) for y in range(sy)
     ]
Ejemplo n.º 10
0
    def __init__(self, job_group=''):
        # If job group is not specified, we want latest one
        if job_group == '':
            job_group = config.LATEST
        self.job_group = job_group
        self._cache = os.path.join(config.CACHEDIR, self.job_group,
                                   'main.pickle')

        # Attempt to load data from cache
        if os.path.isfile(self._cache):
            self.data = pickle.load(open(self._cache, 'rb'))
            return

        # Load the actual data
        self.data = []
        for name, meta in config.get_builds(self.job_group).items():
            build = meta['build']
            rhel = meta['rhel']
            tier = meta['tier']
            production_log = ProductionLog(self.job_group, name, build)
            for report in self.pull_reports(name, build):
                report['tier'] = tier
                report['distro'] = rhel
                report['OBJECT:production.log'] = production_log
                self.data.append(Case(report))

        # Dump parsed data into cache
        pickle.dump(self.data, open(self._cache, 'wb'))
    def gen_multi_test_objects_cases(self,
                                     test_funcs,
                                     random_cleanup=False,
                                     need_cleanup=False,
                                     src_env=None,
                                     no_extra=True):
        # TODO: merge this method with gen_cases
        if src_env is None:
            src_env = Env()

        rets = list()

        def _find_next_steps(int_test_funcs, cur_env, exist_steps, old_env):
            if int_test_funcs:
                test_func = int_test_funcs[0]
                rest_func = int_test_funcs[1:]
                new_env = cur_env.gen_transfer_env(test_func)
                if no_extra and new_env is not None:
                    # this means current env is okay
                    # python3: new_exist_steps = exist_steps.copy()
                    new_exist_steps = copy.deepcopy(exist_steps)
                    new_exist_steps.append(test_func)
                    _find_next_steps(rest_func, new_env, new_exist_steps,
                                     cur_env)
                else:
                    # sigh, need find a route
                    target_env = list(Env.gen_require_env(test_func))
                    for tgt_env in self.find_suit_envs(target_env):
                        steps_list = self.compute_route_permutations(
                            cur_env, tgt_env)
                        new_env = tgt_env.gen_transfer_env(test_func)
                        if not new_env:
                            # BUG: this should not happen
                            LOGGER.info('Cannot use env %s for testing',
                                        tgt_env)
                            continue
                        for steps in steps_list:
                            # python3: new_exist_steps = exist_steps.copy()
                            new_exist_steps = copy.deepcopy(exist_steps)
                            new_exist_steps.extend(steps)
                            new_exist_steps.append(test_func)
                            _find_next_steps(rest_func, new_env,
                                             new_exist_steps, tgt_env)
            else:
                # this is the end of the test_funcs
                # drop last test func
                final_steps = exist_steps[:-1]
                if need_cleanup:
                    cleanup_steps = self.gen_cleanups(cur_env, src_env,
                                                      random_cleanup)
                else:
                    cleanup_steps = None
                # pass old_env since we drop last test func
                rets.append((final_steps, old_env, cleanup_steps))

        _find_next_steps(test_funcs, src_env, [], None)
        for steps, tgt_env, cleanup_steps in rets:
            tmp_case = self.restore_onigin_data(steps)
            case_obj = Case(tmp_case, tgt_env=tgt_env, cleanups=cleanup_steps)
            yield case_obj
Ejemplo n.º 12
0
    def initialiser_tableau(self):
        """
        Initialise le tableau à son contenu initial en suivant les étapes suivantes:
            1) On crée chacune des cases du tableau.
            2) On y ajoute ensuite les mines dans certaines cases qui sont choisies au hasard.
            3) À chaque fois qu'on ajoute une mine dans une case, vous devriez incrémenter dans chacune des cases
            voisines un attribut qui représentera le nombre de mines voisines pour ces cases.
        """
        for rangee_x in range(1, self.dimension_rangee+1):
            for colonne_y in range(1, self.dimension_colonne+1):
                coordonnees = (rangee_x, colonne_y)
                self.dictionnaire_cases[coordonnees] = Case()

        nb_mines_placees = 0

        while nb_mines_placees < self.nombre_mines:
            mine_x = randint(1, self.dimension_rangee)
            mine_y = randint(1, self.dimension_colonne)
            la_case = self.dictionnaire_cases[(mine_x, mine_y)]

            # Comme la position de la mine est aléatoire, il est possible que la case soit déjà minée.
            # Dans ce cas, on recommence!
            if not la_case.est_minee:
                la_case.ajouter_mine()
                nb_mines_placees += 1
                
                for coord_voisin in self.obtenir_voisins(mine_x, mine_y):
                    voisin = self.dictionnaire_cases[coord_voisin]
                    voisin.ajouter_une_mine_voisine()
Ejemplo n.º 13
0
    def __init__(self, url, uname, passwd):

        super().__init__(url)

        self.client = APIClient(url)
        self.client.user = uname
        self.client.password = passwd

        # Classes for each endpoint
        self.attachment = Attachment(self.client)
        self.case = Case(self.client)
        self.case_field = CaseField(self.client)
        self.case_type = CaseType(self.client)
        self.config = Configuration(self.client)
        self.milestone = Milestone(self.client)
        self.plan = Plan(self.client)
        self.priority = Priority(self.client)
        self.project = Project(self.client)
        self.report = Report(self.client)
        self.result = Result(self.client)
        self.result_field = ResultField(self.client)
        self.run = Run(self.client)
        self.section = Section(self.client)
        self.status = Status(self.client)
        self.suite = Suite(self.client)
        self.template = Template(self.client)
        self.test = Test(self.client)
        self.user = User(self.client)
Ejemplo n.º 14
0
    def gen_cases(self,
                  test_func,
                  random_cleanup=False,
                  need_cleanup=False,
                  src_env=None):
        if not src_env:
            src_env = Env()
        target_env = list(Env.gen_require_env(test_func))
        for tgt_env in self.find_suit_envs(target_env):
            cases = self.compute_route_permutations(src_env, tgt_env)
            if not tgt_env.gen_transfer_env(test_func):
                LOGGER.info('Cannot use env %s for testing', tgt_env)
                continue
            cleanup_steps = None
            if need_cleanup:
                new_tgt_env = tgt_env.gen_transfer_env(test_func)
                cleanups = self.compute_route_permutations(
                    src_env, new_tgt_env, True)
                if cleanups:
                    if random_cleanup:
                        cleanup_steps = random.choice(cleanups)
                    else:
                        cleanup_steps = min(cleanups)
                    cleanup_steps = self.restore_onigin_data(cleanup_steps)

            LOGGER.debug("env: %s case num: %d" % (tgt_env, len(cases)))
            for case in cases:
                tmp_case = self.restore_onigin_data(case)
                case_obj = Case(tmp_case,
                                tgt_env=tgt_env,
                                cleanups=cleanup_steps)
                yield case_obj
Ejemplo n.º 15
0
 def creationCases(self):
     for i in range(0, 8):
         self.cases.append([])
         for j in range(0, 8):
             self.cases[i].append(Case(i, j))
     print("cases crees :{0}x{1}".format(len(self.cases),
                                         len(self.cases[0])))
Ejemplo n.º 16
0
 def __init__(self,
              name,
              blockMeshDict,
              controlDict=os.path.join("src", "controlDict")):
     self.case = Case(name)
     self.blockMeshDict = blockMeshDict
     self.controlDict = controlDict
Ejemplo n.º 17
0
    def createCases(self, list):
        if self.config.one_hot_output and self.config.one_hot_output[0]:

            return [
                Case(input=unpack(case[:-1]),
                     target=unpack(
                         tft.int_to_one_hot(
                             int(case[-1]),
                             size=self.config.one_hot_output[-1])))
                for case in list
            ]
        else:
            return [
                Case(input=unpack(case[:-1]), target=unpack(case[-1]))
                for case in list
            ]
Ejemplo n.º 18
0
 def __init__(self,
              name,
              dx,
              mesh,
              timestep,
              fvSchemesPrimary,
              fvSchemesGhost,
              parallel,
              fast,
              controlDict=None,
              solverRule=None):
     self.case = Case(name)
     self.dx = dx
     self.mesh = mesh
     self.timing = Timing(5, 1, timestep)
     self.fvSchemesPrimary = fvSchemesPrimary
     self.fvSchemesGhost = fvSchemesGhost
     self.fvSolution = os.path.join('src/deformationPlane/fvSolution')
     self.controlDict = controlDict or os.path.join(
         'src/deformationPlane/controlDict.template')
     self.setGaussiansDict = os.path.join(
         'src/deformationPlane/setGaussiansDict')
     self.deformationalAdvectionDict = os.path.join(
         'src/deformationPlane/deformationalAdvectionDict')
     self.solverRule = solverRule or 'scalarDeformation'
Ejemplo n.º 19
0
    def case(self, **kwargs):
        """Return a instance of Case object.

        Args:
            tcex (TcEx): An instantiated instance of TcEx object.
            artifacts (Artifact, kwargs): a list of Artifacts corresponding to the Case
            assignee (Assignee, kwargs): the user or group Assignee object for the Case
            created_by (User, kwargs): [Read-Only] The **Created By** for the Case.
            date_added (str, kwargs): [Read-Only] The **Date Added** for the Case.
            description (str, kwargs): The **Description** for the Case.
            name (str, kwargs): [Required] The **Name** for the Case.
            notes (Note, kwargs): a list of Notes corresponding to the Case
            owner (str, kwargs): The Org/Owner name for the Case.
            related (Case, kwargs): The **Related** for the Case.
            resolution (str, kwargs): The **Resolution** for the Case.
            severity (str, kwargs): [Required] The **Severity** for the Case.
            status (str, kwargs): [Required] The **Status** for the Case.
            tags (tcex.case_management.tag.Tag, kwargs): a list of Tags corresponding to the Case
                (NOTE: Setting this parameter will replace any existing tag(s) with
                the one(s) specified)
            tasks (case_management.task.Task, kwargs): a list of Tasks corresponding to the Case
            user_access (User, kwargs): a list of Users that, when defined, are the only
                ones allowed to view or edit the Case
            workflow_events (WorkflowEvent, kwargs): The **Events** for the Case.
            workflow_template (WorkflowTemplate, kwargs): the Template that the Case is
                populated by.
            xid (str, kwargs): The **Xid** for the Case.
        """
        return Case(self.tcex, **kwargs)
Ejemplo n.º 20
0
    def avance(self, direction, pomme):
        # D'abord on calcule les nouvelles coordonnées de la tête
        new_tete_x = self.tete.x + direction[0]
        new_tete_y = self.tete.y + direction[1]
        # Puis on détermine si la tête va être sur la même case que la pomme (le serpent mange la pomme)
        mange_pomme = pomme.x == new_tete_x and pomme.y == new_tete_y
        if mange_pomme:  # Si le serpent mange la pomme on ajoute une écaille au serpent
            self.queue.append(
                Case(0, 0)
            )  # On la met en (0,0) car elle prendra les coords de la dernière case

        # La liste des index inversés dans la queue du serpent
        index_list = reversed(range(self.longueur() - 1))
        # C'est à dire qu'on part de la dernière écaille et on remonte jusqu'à la première
        for index in index_list:
            if index == 0:  # Première écaille (en dernier dans la liste), elle prend les coords de la tête
                self.queue[index].x = self.tete.x
                self.queue[index].y = self.tete.y
            else:  # Toutes les autres écaille prennent les coords de l'écaille qui la précède
                self.queue[index].x = self.queue[index - 1].x
                self.queue[index].y = self.queue[index - 1].y

        # Enfin, la tête prend ses nouvelles coords
        self.tete.x = new_tete_x
        self.tete.y = new_tete_y
        return mange_pomme
Ejemplo n.º 21
0
    def __init__(self, name, mountainHeight, mesh, timestep, fvSchemes,
                 parallel, fast):
        self.case = Case(name)
        self.mountainHeight = mountainHeight
        self.fast = fast

        if fast:
            timing = Timing(500, 500, timestep)
        else:
            timing = Timing(21600, 10800, timestep)

        self.dynamicsExecution = DynamicsExecution(
            self.case,
            mesh,
            timing,
            Lorenz.dynamics(os.path.join('src/resting/theta_init')),
            StratifiedThermalField(),
            os.path.join('src/resting/Uf'),
            os.path.join('src/resting/Exner_init'),
            os.path.join('src/resting/environmentalProperties'),
            os.path.join('src/resting/thermophysicalProperties'),
            fvSchemes,
            os.path.join('src/resting/fvSolution'),
            sponge=False,
            parallel=parallel)
Ejemplo n.º 22
0
    def gen_cases_special(self, src_env, start_env, end_env):
        """
        Support find cases reach mutli target env
        """
        # TODO: this is tied to mist to close
        for tgt_start_env in self.find_suit_envs(start_env):
            if tgt_start_env == src_env:
                cases = None
            else:
                cases = self.compute_route_permutations(src_env, tgt_start_env)
                if not cases:
                    continue
            for tgt_end_env in self.dep_graph[tgt_start_env].keys():
                if end_env <= tgt_end_env:
                    funcs = self.dep_graph[tgt_start_env][tgt_end_env]
                    if cases:
                        for data in itertools.product(cases, funcs):
                            case = list(data[0])
                            case = self.restore_onigin_data(case)

                            case.append(data[1])
                            case_obj = Case(case, tgt_env=tgt_end_env)
                            yield case_obj
                    else:
                        for func in funcs:
                            case_obj = Case([func], tgt_env=tgt_end_env)
                            yield case_obj
Ejemplo n.º 23
0
class BoxedBoard(cqparts.Assembly):
    clearance = PositiveFloat(12)
    case = Case(thickness=3, height=30, screw=Screw)
    # board = Pizero()
    board = PartRef(PizeroBoard)

    def initialize_parameters(self):
        self.coll = []

    def make_components(self):
        board = self.board()
        bb = board.bounding_box
        items = {"case": self.case, "board": board}
        # modify the box to fit the board

        self.case.length = board.length + 2 * self.clearance
        self.case.width = board.width + 2 * self.clearance
        self.case.explode = 0.0
        self.case.screw.length = PositiveFloat(15.0)
        return items

    def make_constraints(self):
        constraints = [
            Fixed(self.components["case"].mate_origin),
            Fixed(self.components["board"].mate_origin),
        ]
        return constraints
Ejemplo n.º 24
0
def calculateSigmaThroughInterpolation(caseList, Re):
    '''
    Creates, through interpolation new result for a given Re
    accepts caseList for a given alfa
    '''
    S = [
        0.01, 0.025, 0.04, 0.055, 0.07, 0.085, 0.1, 0.115, 0.13, 0.145, 0.16,
        0.175, 0.19, 0.205, 0.22, 0.235, 0.25
    ]
    caseList.sort(key=lambda l: l.alfa)
    out = []
    for key, group in groupby(caseList, lambda x: x.alfa):
        alist = list(group)

        case = Case()
        case.alfa = alist[0].alfa
        case.Re = Re
        stab = []
        sigma = []
        for s in S:
            #            try:
            sig = calculateSigmaForS(alist, s, Re)
            sigma.append(sig)
            stab.append(s)


#            except:
#                print "Failed for:"
#                print "Alfa=" + str(case.alfa) + " S=" + str(s)
#                continue
        case.S = stab
        case.sigma = sigma
        out.append(case)
    return out
Ejemplo n.º 25
0
def parse_unseparated(resources_and_tests):
    top_level_suite = Suite(name="Top level suite")
    resources = []
    sequence = 1

    args_are_resources = True
    for test_or_resource in resources_and_tests:

        # Test for suites or test cases.
        try:
            if looks_like_a_suite(test_or_resource):
                parsed_suite = parse_yaml_suite(test_or_resource,
                                                parent=top_level_suite,
                                                sequence=sequence)
                top_level_suite.append_test(parsed_suite)
                args_are_resources = False
                sequence = sequence + 1
            elif looks_like_a_case(test_or_resource):
                case = Case(test_or_resource,
                            parent=top_level_suite,
                            sequence=sequence)
                top_level_suite.append_test(case)
                sequence = sequence + 1
            elif args_are_resources:
                resources.append(test_or_resource)
            else:
                sys.exit(test_or_resource + " does not appear to be a"
                         " test case or suite")
Ejemplo n.º 26
0
    def __init__(self,
                 name,
                 dx,
                 mountainHeight,
                 mesh,
                 staggering,
                 tracerFieldDict,
                 velocityFieldDict,
                 timing,
                 fvSchemes,
                 parallel,
                 fast,
                 controlDict=Paths.defaultControlDict,
                 solverRule=None):
        self.case = Case(name)
        self.dx = dx
        self.mountainHeight = mountainHeight
        self.mesh = mesh
        self.staggering = staggering
        self.tracerFieldDict = tracerFieldDict
        self.velocityFieldDict = velocityFieldDict
        self.timing = timing
        self.fvSchemes = fvSchemes
        self.fvSolution = os.path.join('src/fvSolution')
        self.controlDict = controlDict
        self.parallel = parallel
        self.fast = fast
        self.solverRule = solverRule or self.staggering.advectionSolverRule

        self.solverDependencies = [
                self.case.path('0', staggering.T),
                self.case.path('0/phi')] + \
                self.staggering.advectionSolverDependencies(self.case)
Ejemplo n.º 27
0
 def __init__(self, minesCnt, dimensions):
     self.width = dimensions[0]  # larg
     self.height = dimensions[1]  # long
     self.minesCnt = minesCnt
     self.field = [[Case((x, y), 'safe') for x in range(self.width)]
                   for y in range(self.height)]
     self.mines = []
Ejemplo n.º 28
0
    def create_case(self, name=None, replace=False):
        """
        Create a new Case in the history.

        Attributes:
            name (Optional[str]): Name of Case being created. Default to
                *None* (in this case name is auto-assigned to Case).
            replace (Optional[bool]): Specifies if *current* Case should
                be replaced (*True*) or kept (*False*). Defaults to
                *False*.

        Returns:
            Case: New Case.

        Note:
            New Case becomes a *current* one; previous *current* Case is
            added to the list of *run* Cases (if `replace` is *False*) or
            replaced by new one (if `replace` is *True*).
        """
        if not name:
            idx = self.nb_cases if replace else self.nb_cases + 1
            name = "Case_{}".format(idx)
        case = Case(name)
        self.insert_case(case, replace)
        return case
Ejemplo n.º 29
0
 def __init__(self):
     self.grille = []
     for i in range(9):
         for j in range(9):
             self.grille.append(Case(i, j))
     self.savegrille = copy.deepcopy(self.grille)
     self.vtest = []
Ejemplo n.º 30
0
def build_grid(nb_rows, nb_cols):
    grid = []
    for i in range(nb_rows):
        line = []
        for j in range(nb_cols):
            line.append(Case(i, j))
        grid.append(line)
    return grid