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

Fix #62 #65

Merged
merged 4 commits into from
Oct 24, 2023
Merged

Fix #62 #65

merged 4 commits into from
Oct 24, 2023

Conversation

aseyboldt
Copy link
Member

@aseyboldt aseyboldt commented Sep 14, 2023

Seems the coords can be None in pymc...
fixes #62

python/advi.py Outdated
return out


def advi(compiled_model, max_iter=10_000, residual=5e-3):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have ADVI at the pytensor level in pymc already?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this wasn't supposed to end up in the PR. I rebased

@twiecki
Copy link
Member

twiecki commented Oct 10, 2023

_______________________________ test_pymc_model ________________________________

    def test_pymc_model():
        with pm.Model() as model:
            model.add_coord("foo", length=5)
            pm.Normal("a", dims="foo")
    
>       compiled = nutpie.compile_pymc_model(model)

tests/test_pymc.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/nutpie/compile_pymc.py:191: in compile_pymc_model
    coords = {name: pd.Index(vals) for name, vals in model.coords.items()}
/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/nutpie/compile_pymc.py:191: in <dictcomp>
    coords = {name: pd.Index(vals) for name, vals in model.coords.items()}
/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pandas/core/indexes/base.py:524: in __new__
    raise cls._raise_scalar_data_error(data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'pandas.core.indexes.base.Index'>, data = None

    @final
    @classmethod
    def _raise_scalar_data_error(cls, data):
        # We return the TypeError so that we can raise it from the constructor
        #  in order to keep mypy happy
>       raise TypeError(
            f"{cls.__name__}(...) must be called with a collection of some "
            f"kind, {repr(data) if not isinstance(data, np.generic) else str(data)} "
            "was passed"
        )
E       TypeError: Index(...) must be called with a collection of some kind, None was passed

/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pandas/core/indexes/base.py:5265: TypeError

@twiecki
Copy link
Member

twiecki commented Oct 10, 2023

Processing ./dist/nutpie-0.9.1-cp310-cp310-manylinux_2_28_x86_64.whl
INFO: pip is looking at multiple versions of nutpie[all] to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement pyarrow>=12.0.0 (from nutpie[all]) (from versions: none)
ERROR: No matching distribution found for pyarrow>=12.0.0

@maresb
Copy link
Contributor

maresb commented Oct 13, 2023

I've never used --find-links before, but this feels like it may be overly-complicated.

I would have done something like

pip install --force-reinstall dist/nutpie*.whl

but maybe this doesn't work cross-platform?

@maresb
Copy link
Contributor

maresb commented Oct 13, 2023

Not sure why this would fail on OSX but succeed on Linux:

=================================== FAILURES ===================================
_______________________________ test_pymc_model ________________________________

    def test_pymc_model():
        with pm.Model() as model:
            model.add_coord("foo", length=5)
            pm.Normal("a", dims="foo")
    
>       compiled = nutpie.compile_pymc_model(model)

tests/test_pymc.py:23: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/nutpie/compile_pymc.py:191: in compile_pymc_model
    coords = {name: pd.Index(vals) for name, vals in model.coords.items()}
../../../hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/nutpie/compile_pymc.py:191: in <dictcomp>
    coords = {name: pd.Index(vals) for name, vals in model.coords.items()}
../../../hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pandas/core/indexes/base.py:524: in __new__
    raise cls._raise_scalar_data_error(data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'pandas.core.indexes.base.Index'>, data = None

    @final
    @classmethod
    def _raise_scalar_data_error(cls, data):
        # We return the TypeError so that we can raise it from the constructor
        #  in order to keep mypy happy
>       raise TypeError(
            f"{cls.__name__}(...) must be called with a collection of some "
            f"kind, {repr(data) if not isinstance(data, np.generic) else str(data)} "
            "was passed"
        )
E       TypeError: Index(...) must be called with a collection of some kind, None was passed

../../../hostedtoolcache/Python/3.10.13/x64/lib/python3.10/site-packages/pandas/core/indexes/base.py:5265: TypeError

@aseyboldt
Copy link
Member Author

Thanks for having a look!

The test failure is I think because it seems to be using the nutpie from pypi instead of the new one. I don't quite understand why that would happen on mac but not on linux though...

@aseyboldt
Copy link
Member Author

Ah, I think we need the separate install step in the other ci jobs as well...

@aseyboldt
Copy link
Member Author

 pip install --force-reinstall dist/nutpie*.whl

I think the problem with this is that there are several whl files, for different python versions.

@aseyboldt aseyboldt merged commit d8f7104 into pymc-devs:main Oct 24, 2023
6 checks passed
@aseyboldt aseyboldt deleted the dev branch October 24, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dimension coordinate with auto-numbering gives error
3 participants