Skip to content

Commit

Permalink
some fixes for ruff UP
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Feb 23, 2024
1 parent 5e02548 commit 1780ab1
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 36 deletions.
1 change: 0 additions & 1 deletion oriented_matroids/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from .oriented_matroid import OrientedMatroid
from .abstract_oriented_matroid import AbstractOrientedMatroid

Expand Down
3 changes: 1 addition & 2 deletions oriented_matroids/abstract_oriented_matroid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Abstract class for oriented matroids.
Expand Down Expand Up @@ -69,7 +68,7 @@ def __init__(self, category=None):
Parent.__init__(self, category=category)

@abstract_method
def is_valid(self):
def is_valid(self) -> bool:
r"""
Return whether satisfies oriented matroid axioms.
Expand Down
1 change: 0 additions & 1 deletion oriented_matroids/all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from oriented_matroid import OrientedMatroid
from abstract_oriented_matroid import AbstractOrientedMatroid

Expand Down
17 changes: 8 additions & 9 deletions oriented_matroids/circuit_oriented_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ def __classcall__(cls, data, groundset=None, category=None):
"""
if category is None:
category = Sets()
return super(CircuitOrientedMatroid, cls) \
.__classcall__(cls,
data=data,
groundset=groundset,
category=category)
return super().__classcall__(cls,
data=data,
groundset=groundset,
category=category)

def __init__(self, data, groundset=None, category=None):
"""
Expand Down Expand Up @@ -121,7 +120,7 @@ def __init__(self, data, groundset=None, category=None):
else:
self._groundset = tuple(groundset)

def is_valid(self):
def is_valid(self) -> bool:
"""
Return whether our circuits satisfy the circuit axioms.
Expand Down Expand Up @@ -191,7 +190,7 @@ def is_valid(self):

return True

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of ``self``.
Expand All @@ -204,14 +203,14 @@ def _repr_(self):
"""
try:
rep = "Circuit oriented matroid of rank {}".format(self.rank())
rep = f"Circuit oriented matroid of rank {self.rank()}"
except ValueError:
rep = "Circuit oriented matroid"
return rep

def matroid(self):
r"""
Returns the underlying matroid.
Return the underlying matroid.
Given an oriented matroid defined using circuits, the *underlying
matroid* is the (circuit) matroid whose ground set is the ground set of
Expand Down
12 changes: 6 additions & 6 deletions oriented_matroids/covector_oriented_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def __classcall__(cls, data, groundset=None, category=None):
"""
if category is None:
category = Sets()
return super(CovectorOrientedMatroid, cls) \
.__classcall__(cls, data, groundset=groundset, category=category)
return super().__classcall__(cls, data, groundset=groundset,
category=category)

def __init__(self, data, groundset=None, category=None):
"""
Expand Down Expand Up @@ -115,19 +115,19 @@ def __init__(self, data, groundset=None, category=None):
else:
self._groundset = tuple(groundset)

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of ``self``.
"""
try:
rep = "Covector oriented matroid of rank {}".format(self.rank())
rep = f"Covector oriented matroid of rank {self.rank()}"
except ValueError:
rep = "Covector oriented matroid"
return rep

def is_valid(self):
def is_valid(self) -> bool:
"""
Returns whether our covectors satisfy the covector axioms.
Return whether our covectors satisfy the covector axioms.
EXAMPLES::
Expand Down
3 changes: 1 addition & 2 deletions oriented_matroids/oriented_matroid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Oriented matroids construction
Expand Down Expand Up @@ -260,7 +259,7 @@ def OrientedMatroid(data=None, groundset=None, key=None, **kwds):

if OM is None:
raise NotImplementedError(
"Oriented matroid of type {} is not implemented".format(key))
f"Oriented matroid of type {key} is not implemented")

if OM.is_valid():
return OM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ def __classcall__(cls, data, groundset=None, category=None):
"""
if category is None:
category = Sets()
return super(RealHyperplaneArrangementOrientedMatroid, cls) \
.__classcall__(cls,
data=data,
groundset=groundset,
category=category)
return super().__classcall__(cls,
data=data,
groundset=groundset,
category=category)

def __init__(self, data, groundset=None, category=None):
"""
Expand All @@ -91,7 +90,7 @@ def __init__(self, data, groundset=None, category=None):

CovectorOrientedMatroid.__init__(self, data=faces, groundset=groundset, category=category)

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of ``self``.
"""
Expand All @@ -102,11 +101,10 @@ def _repr_(self):
rep = "Hyperplane arrangement oriented matroid"
return rep

def is_valid(self):
def is_valid(self) -> bool:
"""
Return whether or not the arrangement is an oriented matroid
"""

if not self.arrangement().is_central():
raise ValueError("Hyperplane arrangements must be central to be an oriented matroid.")

Expand Down
3 changes: 1 addition & 2 deletions oriented_matroids/signed_subset_element.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Abstract class for oriented matroids.
Expand Down Expand Up @@ -509,7 +508,7 @@ def reorientation(self, change_set):
# ensure every elt is in the groundset
for i in change_set:
if i not in self.groundset():
raise ValueError("{} is not in the ground set".format(i))
raise ValueError(f"{i} is not in the ground set")

p = self.positives().difference(change_set).union(
self.negatives().intersection(change_set))
Expand Down
10 changes: 5 additions & 5 deletions oriented_matroids/vector_oriented_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def __classcall__(cls, data, groundset=None, category=None):
"""
if category is None:
category = Sets()
return super(VectorOrientedMatroid, cls) \
.__classcall__(cls, data, groundset=groundset, category=category)
return super().__classcall__(cls, data, groundset=groundset,
category=category)

def __init__(self, data, groundset=None, category=None):
"""
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(self, data, groundset=None, category=None):
else:
self._groundset = tuple(groundset)

def is_valid(self):
def is_valid(self) -> bool:
"""
Return whether our vectors satisfy the vector axioms.
Expand Down Expand Up @@ -181,7 +181,7 @@ def is_valid(self):

return True

def _repr_(self):
def _repr_(self) -> str:
"""
Return a string representation of ``self``.
Expand All @@ -194,7 +194,7 @@ def _repr_(self):
"""
try:
rep = "Vector oriented matroid of rank {}".format(self.rank())
rep = f"Vector oriented matroid of rank {self.rank()}"
except ValueError:
rep = "Vector oriented matroid"
return rep
Expand Down

0 comments on commit 1780ab1

Please sign in to comment.