Skip to content

Commit

Permalink
Code refactoring: camelCase -> snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
RozeQz committed Nov 20, 2022
1 parent 4683d81 commit 516bd62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
22 changes: 11 additions & 11 deletions binaryRelation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,28 @@ def is_order(self) -> bool:
return self.is_transitive() and not self.is_symmetrical() and (self.is_reflexive() or self.is_irreflexive())

# Сделать отношение рефлексивным
def makeReflexive(self):
def make_reflexive(self):
if not self.is_reflexive():
for k in self.A:
if (k, k) not in self.R:
self.R.append((k, k))

def makeIrreflexive(self):
def make_irreflexive(self):
if not self.is_irreflexive():
for k in self.A:
if (k, k) in self.R:
self.R.remove((k, k))

# Сделать отношение антисимметричным
def makeAntisymmetric(self):
def make_antisymmetric(self):
if not self.is_antisymm():
for (x, y) in self.R:
for (a, b) in self.R:
if (x != y) and (x == b) and (y == a): # Если есть пример, нарушающий антисимметричность
self.R.remove((y, x)) # Удаляем пару, которая нарушает антисимметричность

# Сделать отношение несимметричным
def makeNotSymmetrical(self):
def make_not_symmetrical(self):
while self.is_symmetrical():
for (x, y) in self.R:
if (x != y) and ((y, x) in self.R):
Expand All @@ -115,27 +115,27 @@ def makeNotSymmetrical(self):
self.R.remove((x, y))

# Сделать отношение транзитивным
def makeTransitive(self):
def make_transitive(self):
if not self.is_transitive():
for (a, b) in self.R:
for (c, d) in self.R:
if ((b == c) and (a != b) and ((a, d) not in self.R)):
self.R.append((a, d))

# Сделать отношением порядка
def makeOrder(self):
def make_order(self):
while not self.is_order():
counter = 0
while not self.is_order() and counter < 5:
if random.choice([True, False]):
self.makeNotSymmetrical()
self.make_not_symmetrical()
else:
self.makeIrreflexive()
self.makeTransitive()
self.make_irreflexive()
self.make_transitive()
counter += 1
if counter >= 5:
self.makeReflexive()
self.makeTransitive()
self.make_reflexive()
self.make_transitive()

# Классы бинарных отношений
def class_of_relation(self) -> str:
Expand Down
4 changes: 1 addition & 3 deletions mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ def output(self):
self.lbl_bin_class.setText("Строгий порядок")
if bin_class == "strict preorder":
self.lbl_bin_class.setText("Строгий предпорядок")
if bin_class == "order":
self.lbl_bin_class.setText("Не входит ни в один класс - отношение порядка")

self.resize_event()

Expand Down Expand Up @@ -169,7 +167,7 @@ def create_random_binary_relation(self) -> BinaryRelation:

def input_random_order(self):
bin_rel = self.create_random_binary_relation()
bin_rel.makeOrder()
bin_rel.make_order()
self.edt_setA.setText(str(bin_rel.A)[1:-1])
self.edt_setR.setText(str(bin_rel.R)[1:-1])

Expand Down

0 comments on commit 516bd62

Please sign in to comment.