Skip to content

repr() on a ModelChain instance fails if orientation_strategy = 'None' #352

Closed

Description

@jgaffiot

If orientation_strategy is set to 'None' when creating a ModelChain, the attribute self._orientation_strategy is set to None in the orientation_strategy setter (from line 353).
In the __repr__ method, just above, each attribute is printed thanks to the inner function getmcattr(self, attr). And if the argument attr is None, then the function returns None.
Then, when building the returned chain, None is passed to the concatenation operator, which fails.

Activity

  1. changed the title [-] `repr()` on a `ModelChain` instance fails if `orientation_strategy = 'None'`[/-] [+] repr() on a ModelChain instance fails if orientation_strategy = 'None'[/+] on Jul 25, 2017
  2. jgaffiot commented on Jul 25, 2017

    @jgaffiot
    Author

    Can be fixed by changing line 344 of modelchain.py to:

     ('{}: {}'.format(attr, getmcattr(self, attr)) for attr in attrs)))
    
  3. added this to the 0.4.6 milestone on Jul 25, 2017
  4. wholmgren commented on Jul 25, 2017

    @wholmgren
    Member

    Thanks, it would be great if you could submit a pull request with the fix.

  5. wholmgren commented on Jul 25, 2017

    @wholmgren
    Member

    PVSystem and SingleAxisTracker __repr__ methods enclose getattr(self, attr) in the str function rather than using format:

    https://github.com/pvlib/pvlib-python/blob/master/pvlib/pvsystem.py#L159
    https://github.com/pvlib/pvlib-python/blob/master/pvlib/tracking.py#L62

    Perhaps we should use the same approach in all three __repr__ methods. It's not clear to me if one is better than the other.

  6. jgaffiot commented on Jul 25, 2017

    @jgaffiot
    Author

    Hi wholmgren,

    I'm unfamiliar with the pull request system in third-party project (even with mine, I'm still learning GitHub).
    I naïvely tried:

    git push origin fix_repr_model_chain
    

    but of course I'm not able to access the pvlib repository.

    Concerning the fix, I think that using format is slightly more clean and pythonic than concatenation with '+', and is less error prone. I would use format for the 3 classes.

  7. wholmgren commented on Jul 25, 2017

    @wholmgren
    Member

    I am happy to help new contributors get oriented here. Start with this section of our documentation and then let me know if you have further questions:

    http://pvlib-python.readthedocs.io/en/latest/contributing.html#how-to-contribute-new-code

  8. jgaffiot commented on Jul 25, 2017

    @jgaffiot
    Author

    I have submitted a pull request (#353) to fix the bug.

  9. added a commit that references this issue on Jul 26, 2017
  10. modified the milestones: 0.4.6, 0.5.0 on Aug 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions