Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: better docstrings and signatures for decorators #2

Merged
merged 5 commits into from Feb 1, 2018

Conversation

Projects
None yet
2 participants
@aflaxman
Copy link
Collaborator

commented Aug 3, 2017

For better UX in Jupyter notebooks, I've added some code to change the signature of uses_columns. It does not look quite right, and is a bit nasty, so maybe someone will help me do it better.

WIP: better docstrings and signatures for decorators
For better UX in Jupyter notebooks

@collijk collijk requested a review from alec-deason Aug 4, 2017

"""
from inspect import signature, Parameter, Signature
uses_columns.__signature__ = \

This comment has been minimized.

Copy link
@alec-deason

alec-deason Aug 8, 2017

Contributor

If you want a more tool friendly signature I wouldn't do this. Rather I would wrap the generated function like this:

_uses_columns = resource_injector('population_system_population_view')
def uses_columns(columns, query):
    '''DOCSTRING'''
   return _uses_columns(columns, query)

I haven't actually tried that but it should work and give you the behavior you want.

@aflaxman

This comment has been minimized.

Copy link
Collaborator Author

commented Aug 8, 2017

That is way simpler, but doesn't quite work. Cool that travis can show you how:

___________________________ test_interpolated_tables ___________________________
    def test_interpolated_tables():
        years = build_table(lambda age, sex, year: year)
        ages = build_table(lambda age, sex, year: age)
        one_d_age = ages.copy()
        del one_d_age['year']
        one_d_age = one_d_age.drop_duplicates()
    
>       simulation = setup_simulation([generate_test_population], 10000)
tests/framework/test_lookup.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
vivarium/test_util.py:15: in setup_simulation
    simulation.setup()
vivarium/framework/engine.py:89: in setup
    self.population.setup_components(components)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = PopulationManager(_population= Empty DataFrame
Columns: []
Index: [], growing= False, observers= defaultdict(<class 'set'>, {}))
components = [ValuesManager(_pipelines= []), EventManager(event_types: defaultdict(<function EventManager.__init__.<locals>.<lambda...InterpolatedDataManager(clock= <function Builder.__init__.<locals>.<lambda>.<locals>.<lambda> at 0x7f573215aa60>), ...]
    def setup_components(self, components):
>       uses_columns.set_injector(self._population_view_injector)
E       AttributeError: 'function' object has no attribute 'set_injector'
vivarium/framework/population.py:295: AttributeError

https://travis-ci.org/ihmeuw/vivarium/jobs/262439596

ENH: better signatures for decorators
now working with a simple implementation
@aflaxman

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 31, 2018

This seems safe to merge. I'm going to do it.

@aflaxman

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 31, 2018

Oh, I can't! @alec-deason can you merge this today, or give me feedback on what to change?

@alec-deason alec-deason merged commit f4d5b76 into ihmeuw:develop Feb 1, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@alec-deason

This comment has been minimized.

Copy link
Contributor

commented Feb 1, 2018

I guess I locked it somehow when I started the review. I've never actually sat down and looked at how the github review workflow is structured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.