-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: pvconst is not a singleton, inconsistent, doesn't update (GH38) (#…
…62) * fixes #59 * add class attr _calc_now * override _calc_now with instance attribte at the end of constructor * check if _calc_now is True to decide to call self.calcCell() instead of checking for pvconst * use self.__dict__.update() instead of using super(PVcell, self).__setattr__(key, value) * in update, remove TODO, b/c even tho __dict__.update() would bypass __setattr__() then would have to check for floats, and still set _calc_now = True to trigger recalc, so instead, just set _calc_now = False first to turn calculations off, until all attr are set, then recalc * don't set pvcell.pvconst in pvstring * just raise an exception if they don't match for now * remove comments about "deepcopy" everywhere * oops, recalculate means _calc_now = True, duh! * remove commented legacy code in __setattr__, add comment in update re checking for floats * add test for new _calc_now flag * if _calc_now == False, then calcCell() is not called in __setattr__ * if _calc_now == True, then calcCell() is called in __setattr__ * closes #38 consistent pvconst behavior * use duck typing to check pvstrs in PVsystem() for list, object or none * set pvconst from pvstrs if given * set numbstrs from pvstrs if given * set numbermods form pvstrs.pvmods if given * check that pvconst and pvmods are consistent * add tests * apply same changes in pvsystem from last commit to pvstr * change default pvconst arg to None * use duck typing to check if pvmods is a list, an object, or None * relax requirement that all strings have same number of modules * change pvsys.numberMods to a list of number of modules in each string * add test to check pvstring * check that all pvconst are the same for all modules * add docstring for members * also test that pvsys.numberMods is now a list * each item in list is number of modules in corresponding string * use ducktyping to determine if pvcells is list or obj or None * add missing blank lines and wrap long lines per pep8 * add pvcell object to pvcells docstring arg type * add tests in test_module to check that pvconst is the same for module and all cells * add test for update method * replace npts attr with a property * add new private _npts attribute, return for npts in getter * set npts, pts, negpts, Imod_pts, and Imod_negpts in setter * add test to show that changing npts changes pts, negpts, Imod_pts, and Imod_negpts * add pvsystem update method * make system calculation DRY, use everywhere calcSystem and calcMPP_IscVocFFeff are called back to back to set Isys, Vsys, Psys, etc. * also makes it explicity to recalc the system after a change, like change pvconst.npts
- Loading branch information
Showing
9 changed files
with
234 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pvmismatch import * | ||
|
||
|
||
def test_pvconst_npts_setter(): | ||
"""Test pvconst property and setter methods""" | ||
pvconst = pvconstants.PVconstants() | ||
assert pvconst.npts == pvconstants.NPTS | ||
assert len(pvconst.pts) == pvconst.npts | ||
assert pvconst.pts[0] == 0 | ||
assert pvconst.pts[-1] == 1 | ||
assert len(pvconst.negpts) == pvconst.npts | ||
assert pvconst.negpts[0] == 1 | ||
assert pvconst.negpts[-1] > 0 | ||
pvconst.npts = 1001 | ||
assert pvconst.npts == 1001 | ||
assert len(pvconst.pts) == pvconst.npts | ||
assert pvconst.pts[0] == 0 | ||
assert pvconst.pts[-1] == 1 | ||
assert len(pvconst.negpts) == pvconst.npts | ||
assert pvconst.negpts[0] == 1 | ||
assert pvconst.negpts[-1] > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pvmismatch import * | ||
|
||
|
||
def check_same_pvconst_and_lengths(pvstr): | ||
assert len(pvstr.pvmods) == pvstring.NUMBERMODS | ||
for p in pvstr.pvmods: | ||
assert p.pvconst is pvstr.pvconst | ||
|
||
|
||
def test_pvstring_with_pvmods_list(): | ||
pvmods = [pvmodule.PVmodule()] * pvstring.NUMBERMODS | ||
pvstr = pvstring.PVstring(pvmods=pvmods) | ||
check_same_pvconst_and_lengths(pvstr) | ||
|
||
|
||
def test_pvstring_with_pvmods_obj(): | ||
pvmods = pvmodule.PVmodule() | ||
pvstr = pvstring.PVstring(pvmods=pvmods) | ||
check_same_pvconst_and_lengths(pvstr) | ||
|
||
|
||
def test_pvstring_with_no_pvmods(): | ||
pvstr = pvstring.PVstring() | ||
check_same_pvconst_and_lengths(pvstr) |
Oops, something went wrong.