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

Pytest data regression does not recognize float64 as valid object #26

Open
gghiguchi opened this issue Feb 3, 2020 · 4 comments
Open

Comments

@gghiguchi
Copy link

Got this error when using a data regression on top os a numpy created array of zeros, that creates the array as float64 by default

@tadeu
Copy link
Member

tadeu commented Feb 10, 2020

Can you please provide a code sample that reproduces the error? Or, if not, the stacktrace with the full error message.

Thanks!

@gghiguchi
Copy link
Author

Sure

    def test_regression(data_regression):
        from numpy import float64
    
        float_64_numpy_object = float64(10)
>       data_regression.check(float_64_numpy_object)

test_create_scas_calc_dict.py:122: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/gghiguchi/Work/miniconda/envs/rfdap/lib/python3.6/site-packages/pytest_regressions/data_regression.py:55: in dump
    encoding="utf-8",
/home/gghiguchi/Work/miniconda/envs/rfdap/lib/python3.6/site-packages/yaml/__init__.py:278: in dump_all
    dumper.represent(data)
/home/gghiguchi/Work/miniconda/envs/rfdap/lib/python3.6/site-packages/yaml/representer.py:27: in represent
    node = self.represent_data(data)
/home/gghiguchi/Work/miniconda/envs/rfdap/lib/python3.6/site-packages/yaml/representer.py:58: in represent_data
    node = self.yaml_representers[None](self, data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <pytest_regressions.data_regression.RegressionYamlDumper object at 0x7f85fe360b38>, data = 10.0

    def represent_undefined(self, data):
>       raise RepresenterError("cannot represent an object", data)
E       yaml.representer.RepresenterError: ('cannot represent an object', 10.0)

/home/gghiguchi/Work/miniconda/envs/rfdap/lib/python3.6/site-packages/yaml/representer.py:231: RepresenterError

@tarcisiofischer
Copy link
Contributor

Perhaps this can be solved by using the new NDArraysRegressionFixture? @tovrstra What do you think?

@tovrstra
Copy link
Contributor

That would indeed be a solution. The code was recently merged in the master branch (#72) and there is still some API discussion (#73). I believe both num_regressions and ndarrays_regression should work. Just keep in mind that these expect a dictionionary with strings as keys and arrays as values. If you plan to use other shapes than 1D arrays, ndarrays_regression would be the best fit.

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

No branches or pull requests

4 participants