Skip to content

Commit ac4ca6f

Browse files
uvchikwholmgren
authored andcommitted
Change method of multi-inheritance to allow kwargs in parent class of LocalizedPVSystem and LocalizedSingleAxisTracker (#330)
* remove superfluous keyword arguments If keyword arguments are present a TypeError will be raised, so it is better to remove it. * Revert "remove superfluous keyword arguments" This reverts commit 45e0518. * use class names instead of super for multiple inheritance * fix test, because 'my name' is expected if my name is given * use class names instead of super for multiple inheritance I have overseen this class so I had to change it in the same way as in commit 6d1beaf. * make pep8 a little happier * add whatsnewfile for 0.4.6 * add whatsnew entry for PR 330 * extend whatsnew entry
1 parent f9f44c7 commit ac4ca6f

File tree

7 files changed

+41
-15
lines changed

7 files changed

+41
-15
lines changed

docs/sphinx/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __getattr__(cls, name):
100100

101101
# List of patterns, relative to source directory, that match files and
102102
# directories to ignore when looking for source files.
103-
exclude_patterns = []
103+
exclude_patterns = ['whatsnew/*']
104104

105105
# The reST default role (used for this markup: `text`) to use for all
106106
# documents.

docs/sphinx/source/whatsnew.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ What's New
66

77
These are new features and improvements of note in each release.
88

9+
.. include:: whatsnew/v0.4.6.rst
910
.. include:: whatsnew/v0.4.5.txt
1011
.. include:: whatsnew/v0.4.4.txt
1112
.. include:: whatsnew/v0.4.3.txt
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
.. _whatsnew_0460:
2+
3+
v0.4.6 ()
4+
---------
5+
6+
7+
Bug fixes
8+
~~~~~~~~~
9+
10+
* Method of multi-inheritance has changed to make it possible to use kwargs in
11+
the parent classes of LocalizedPVSystem and LocalizedSingleAxisTracker
12+
(:issue:`330`)
13+
14+
15+
Enhancements
16+
~~~~~~~~~~~~
17+
18+
19+
API Changes
20+
~~~~~~~~~~~
21+
22+
23+
Documentation
24+
~~~~~~~~~~~~~
25+
26+
27+
Contributors
28+
~~~~~~~~~~~~
29+
30+
* Will Holmgren
31+
* Uwe Krien

pvlib/location.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ def __init__(self, latitude, longitude, tz='UTC', altitude=0,
7979

8080
self.name = name
8181

82-
# needed for tying together Location and PVSystem in LocalizedPVSystem
83-
# if LocalizedPVSystem signature is reversed
84-
# super(Location, self).__init__(**kwargs)
85-
8682
def __repr__(self):
8783
attrs = ['name', 'latitude', 'longitude', 'altitude', 'tz']
8884
return ('Location: \n ' + '\n '.join(

pvlib/pvsystem.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ def __init__(self,
149149

150150
self.racking_model = racking_model
151151

152-
# needed for tying together Location and PVSystem in LocalizedPVSystem
153-
super(PVSystem, self).__init__(**kwargs)
154-
155152
def __repr__(self):
156153
attrs = ['name', 'surface_tilt', 'surface_azimuth', 'module',
157154
'inverter', 'albedo', 'racking_model']
@@ -584,7 +581,8 @@ def __init__(self, pvsystem=None, location=None, **kwargs):
584581
list(loc_dict.items()) +
585582
list(kwargs.items()))
586583

587-
super(LocalizedPVSystem, self).__init__(**new_kwargs)
584+
PVSystem.__init__(self, **new_kwargs)
585+
Location.__init__(self, **new_kwargs)
588586

589587
def __repr__(self):
590588
attrs = [

pvlib/test/test_pvsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def test_LocalizedPVSystem___repr__():
751751
inverter='blarg',
752752
name='my name')
753753

754-
expected = 'LocalizedPVSystem: \n name: None\n latitude: 32\n longitude: -111\n altitude: 0\n tz: UTC\n surface_tilt: 0\n surface_azimuth: 180\n module: blah\n inverter: blarg\n albedo: 0.25\n racking_model: open_rack_cell_glassback'
754+
expected = 'LocalizedPVSystem: \n name: my name\n latitude: 32\n longitude: -111\n altitude: 0\n tz: UTC\n surface_tilt: 0\n surface_azimuth: 180\n module: blah\n inverter: blarg\n albedo: 0.25\n racking_model: open_rack_cell_glassback'
755755

756756
assert localized_system.__repr__() == expected
757757

pvlib/tracking.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __repr__(self):
3838
pvsystem_repr = '\n'.join(pvsystem_repr.split('\n')[1:])
3939
return sat_repr + '\n' + pvsystem_repr
4040

41-
4241
def singleaxis(self, apparent_zenith, apparent_azimuth):
4342
tracking_data = singleaxis(apparent_zenith, apparent_azimuth,
4443
self.axis_tilt, self.axis_azimuth,
@@ -162,14 +161,15 @@ def __init__(self, pvsystem=None, location=None, **kwargs):
162161
list(loc_dict.items()) +
163162
list(kwargs.items()))
164163

165-
super(LocalizedSingleAxisTracker, self).__init__(**new_kwargs)
164+
SingleAxisTracker.__init__(self, **new_kwargs)
165+
Location.__init__(self, **new_kwargs)
166166

167167
def __repr__(self):
168168
attrs = ['latitude', 'longitude', 'altitude', 'tz']
169169
return ('Localized' +
170-
super(LocalizedSingleAxisTracker, self).__repr__() + '\n ' +
171-
'\n '.join(
172-
(attr + ': ' + str(getattr(self, attr)) for attr in attrs)))
170+
super(LocalizedSingleAxisTracker, self).__repr__() + '\n ' +
171+
'\n '.join(
172+
(attr + ': ' + str(getattr(self, attr)) for attr in attrs)))
173173

174174

175175
def singleaxis(apparent_zenith, apparent_azimuth,

0 commit comments

Comments
 (0)