Skip to content

Commit

Permalink
Fixed method naming in stats.py classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gochim committed Nov 11, 2019
1 parent 7a58d97 commit 386e05b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions eos/utils/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ def __itruediv__(self, div):
return self

def __repr__(self):
spec = DmgTypes.Names()
spec = DmgTypes.names()
spec.append('total')
return makeReprStr(self, spec)

@staticmethod
def Names(short=None, postProcessor=None):
def names(short=None, postProcessor=None):
value = ['em', 'th', 'kin', 'exp'] if short else ['em', 'thermal', 'kinetic', 'explosive']

if postProcessor:
Expand Down Expand Up @@ -201,11 +201,11 @@ def __itruediv__(self, div):
return self

def __repr__(self):
spec = RRTypes.Names(False)
spec = RRTypes.names(False)
return makeReprStr(self, spec)

@staticmethod
def Names(ehpOnly=True, postProcessor=None):
def names(ehpOnly=True, postProcessor=None):
value = ['shield', 'armor', 'hull']

if not ehpOnly:
Expand Down
10 changes: 5 additions & 5 deletions service/port/shipstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from eos.utils.stats import RRTypes, DmgTypes
from gui.utils.numberFormatter import formatAmount

tankTypes = RRTypes.Names()
damageTypes = DmgTypes.Names()
tankTypes = RRTypes.names()
damageTypes = DmgTypes.names()
damagePatterns = [DamagePattern.oneType(damageType) for damageType in damageTypes]
damageTypeResonanceNames = [damageType.capitalize() + "DamageResonance" for damageType in damageTypes]
resonanceNames = {tankTypes[0]: [tankTypes[0] + s for s in damageTypeResonanceNames],
Expand Down Expand Up @@ -50,8 +50,8 @@ def tankSection(fit):

def generalOutput():
rowNames = ["EHP"]
rowNames.extend(RRTypes.Names(postProcessor=lambda v: v.capitalize()))
colNames = DmgTypes.Names(short=True, postProcessor=lambda v: " " + v.capitalize())
rowNames.extend(RRTypes.names(postProcessor=lambda v: v.capitalize()))
colNames = DmgTypes.names(short=True, postProcessor=lambda v: " " + v.capitalize())
colNames[0] = colNames[0][1::]

outputScheme = []
Expand Down Expand Up @@ -144,7 +144,7 @@ def repsSection(fit):
shieldRegenStr = [formatAmount(rep, 3, 0, 9) if rep != 0 else "" for rep in shieldRegen]
totalRepStr = [formatAmount(rep, 3, 0, 9) for rep in totalRep]

lines = RRTypes.Names(postProcessor=lambda v: v.capitalize())
lines = RRTypes.names(postProcessor=lambda v: v.capitalize())
lines.append("Total")
lines = ["{:<8}".format(line) for line in lines]

Expand Down
22 changes: 11 additions & 11 deletions tests/test_modules/test_eos/test_utils/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ def setup_damage_types():


def test_dmgtypes_names():
assert DmgTypes.Names() == ['em', 'thermal', 'kinetic', 'explosive']
assert DmgTypes.Names(True) == ['em', 'th', 'kin', 'exp']
assert DmgTypes.Names(short=True) == ['em', 'th', 'kin', 'exp']
assert DmgTypes.names() == ['em', 'thermal', 'kinetic', 'explosive']
assert DmgTypes.names(True) == ['em', 'th', 'kin', 'exp']
assert DmgTypes.names(short=True) == ['em', 'th', 'kin', 'exp']


def test_dmgtypes__repr(setup_damage_types):
assert setup_damage_types.__repr__() == '<DmgTypes(em=10, thermal=20, kinetic=30, explosive=40, total=100)>'


def test_dmgtypes_names_lambda():
assert DmgTypes.Names(False, lambda v: v.capitalize()) == ['Em', 'Thermal', 'Kinetic', 'Explosive']
assert DmgTypes.Names(True, lambda v: v.upper()) == ['EM', 'TH', 'KIN', 'EXP']
assert DmgTypes.names(False, lambda v: v.capitalize()) == ['Em', 'Thermal', 'Kinetic', 'Explosive']
assert DmgTypes.names(True, lambda v: v.upper()) == ['EM', 'TH', 'KIN', 'EXP']


@pytest.fixture()
Expand All @@ -36,18 +36,18 @@ def setup_rr_types():


def test_rrtypes_names():
assert RRTypes.Names() == ['shield', 'armor', 'hull']
assert RRTypes.Names(True) == ['shield', 'armor', 'hull']
assert RRTypes.Names(ehpOnly=True) == ['shield', 'armor', 'hull']
assert RRTypes.Names(False) == ['shield', 'armor', 'hull', 'capacitor']
assert RRTypes.names() == ['shield', 'armor', 'hull']
assert RRTypes.names(True) == ['shield', 'armor', 'hull']
assert RRTypes.names(ehpOnly=True) == ['shield', 'armor', 'hull']
assert RRTypes.names(False) == ['shield', 'armor', 'hull', 'capacitor']


def test_rrtypes__repr(setup_rr_types):
assert setup_rr_types.__repr__() == '<RRTypes(shield=10, armor=20, hull=30, capacitor=40)>'


def test_rrtypes_names_lambda():
assert RRTypes.Names(True, lambda v: v.capitalize()) == ['Shield', 'Armor', 'Hull']
assert RRTypes.Names(postProcessor=lambda v: v.upper(), ehpOnly=False) == ['SHIELD', 'ARMOR', 'HULL', 'CAPACITOR']
assert RRTypes.names(True, lambda v: v.capitalize()) == ['Shield', 'Armor', 'Hull']
assert RRTypes.names(postProcessor=lambda v: v.upper(), ehpOnly=False) == ['SHIELD', 'ARMOR', 'HULL', 'CAPACITOR']


0 comments on commit 386e05b

Please sign in to comment.