
GITHUB . COM {
}
Detected CMS Systems:
- Wordpress (2 occurrences)
Title:
Improve pytest.approx error messages readability · Issue #8335 · pytest-dev/pytest
Description:
Hey all. I think that as important as getting PASSED on our tests, it is important to get useful messages when the tests FAIL. That being said... What's the problem this feature will solve? Whi...
Website Age:
17 years and 8 months (reg. 2007-10-09).
Matching Content Categories {📚}
- Dating & Relationships
- Technology & Computing
- Cryptocurrency
Content Management System {📝}
What CMS is github.com built with?
Github.com is powered by WORDPRESS.
Traffic Estimate {📈}
What is the average monthly size of github.com audience?
🚀🌠 Tremendous Traffic: 10M - 20M visitors per month
Based on our best estimate, this website will receive around 10,653,974 visitors per month in the current month.
check SE Ranking
check Ahrefs
check Similarweb
check Ubersuggest
check Semrush
How Does Github.com Make Money? {💸}
Subscription Packages {💳}
We've located a dedicated page on github.com that might include details about subscription plans or recurring payments. We identified it based on the word pricing in one of its internal links. Below, you'll find additional estimates for its monthly recurring revenues.How Much Does Github.com Make? {💰}
Subscription Packages {💳}
Prices on github.com are in US Dollars ($).
They range from $4.00/month to $21.00/month.
We estimate that the site has approximately 5,316,204 paying customers.
The estimated monthly recurring revenue (MRR) is $22,328,057.
The estimated annual recurring revenues (ARR) are $267,936,687.
Wordpress Themes and Plugins {🎨}
What WordPress theme does this site use?
It is strange but we were not able to detect any theme on the page.
What WordPress plugins does this website use?
It is strange but we were not able to detect any plugins on the page.
Keywords {🔍}
assert, pytestapprox, tarcisiofischer, commented, approx, comparison, nicoddemus, issue, numpy, code, failed, obtained, expected, contributor, error, messages, arrays, array, values, index, pytestassertreprcompare, kalekundert, author, zachd, list, elements, open, sign, pytest, projects, tests, nplinspace, message, free, member, numpytesting, implementation, max, difference, show, place, pull, improve, readability, hey, pytestapproxb, solution, nice, similar, guys,
Topics {✒️}
max absolute/relative difference zac-hd mentioned max absolute difference max relative difference /tarcisiofischer/cab56a5eb65aaa03bdbb4d206f1d49f0 examples approx function type py36 -- testing/python/approx assigned labels topic testing numpy arrays tolerance rtol=1e-07 actual formatting code pull request comment metadata assignees improve pytest error message improvements tarcisiofischer mentioned type projects comparing numerical data original implementation relies approx numpy support testing support package projects milestone assert comparison failed error messages numpy arrays guys thing mismatched elements testing import assert_allclose testing open full arrays error message maps open related issue import numpy numpy package similar issue 0e-06 = approx guys deprecate pytest pytest deals diffing elements differing elements approx message lhs data testing module approx classes approx subclasses approx related assert 'assert 2 numpy project
Payment Methods {📊}
- Braintree
Questions {❓}
- Already have an account?
- What you guys thing?
- What's the problem this feature will solve?
- Approx for ndarrays, and keep only the list implementation (So that pytest deals only with the builtin types: float, map and list)?
Schema {🗺️}
DiscussionForumPosting:
context:https://schema.org
headline:Improve pytest.approx error messages readability
articleBody:Hey all. I think that as important as getting `PASSED` on our tests, it is important to get useful messages when the tests `FAIL`. That being said...
#### What's the problem this feature will solve?
While comparing numerical data with `pytest.approx`, I find the messages a bit hard to read when we are comparing big enough numpy arrays. Example:
```python
def test_bla():
import numpy as np
a = np.linspace(0, 100, 20)
b = np.linspace(0, 100, 20)
a[10] += 0.5
assert a == pytest.approx(b)
```
The error message:
```
> assert a == pytest.approx(b)
E assert array([ 0. , 5.26315789, 10.52631579, 15.78947368,\n 21.05263158, 26.31578947, 31.57894737, 36.84210526,\n 42.10526316, 47.36842105, 53.13157895, 57.89473684,\n 63.15789474, 68.42105263, 73.68421053, 78.94736842,\n 84.21052632, 89.47368421, 94.73684211, 100. ]) == approx([0.0 ± 1.0e-12, 5.2631578947368425 ± 5.3e-06, 10.526315789473685 ± 1.1e-05, 15.789473684210527 ± 1.6e-05, 21.05263157894737 ± 2.1e-05, 26.315789473684212 ± 2.6e-05, 31.578947368421055 ± 3.2e-05, 36.8421052631579 ± 3.7e-05, 42.10526315789474 ± 4.2e-05, 47.36842105263158 ± 4.7e-05, 52.631578947368425 ± 5.3e-05, 57.89473684210527 ± 5.8e-05, 63.15789473684211 ± 6.3e-05, 68.42105263157896 ± 6.8e-05, 73.6842105263158 ± 7.4e-05, 78.94736842105263 ± 7.9e-05, 84.21052631578948 ± 8.4e-05, 89.47368421052633 ± 8.9e-05, 94.73684210526316 ± 9.5e-05, 100.0 ± 1.0e-04])
```
This is the main example I want to solve, although I've implemented a solution for other cases.
#### Describe the solution you'd like
Would be nice to have something like this:
```
> assert a == pytest.approx(b)
E assert comparison failed for 1 values:
E Index | Obtained | Expected
E (10,) | 53.131578947368425 | 52.631578947368425 ± 5.3e-05
```
#### ~Alternative~ Solutions
I haven't tried any workaround. But I implemented a solution, using `pytest_assertrepr_compare`. It is in this gist: https://gist.github.com/tarcisiofischer/cab56a5eb65aaa03bdbb4d206f1d49f0
Examples:
```
> assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5])
E assert comparison failed for 2 values:
E Index | Obtained | Expected
E 1 | 2 | 3 ± 3.0e-06
E 3 | 4 | 5 ± 5.0e-06
```
```
> assert 1.0 == pytest.approx(2.0)
E assert comparison failed
E Obtained: 1.0
E Expected: 2.0 ± 2.0e-06
```
```
> assert {'a': 1, 'b': 3} == pytest.approx({'a': 1.7, 'b': 3})
E assert comparison failed for 1 values:
E Index | Obtained | Expected
E a | 1 | 1.7 ± 1.7e-06
```
A big one (sorry for the dump)
```
> assert np.array([
[
[1.1987311, 12412342.3],
[3.214143244, 1423412423415.677]
], [
[1, 2],
[3, 219371297321973]
]
]) == pytest.approx(
np.array([
[
[1.12313, 12412342.3],
[3.214143244, 534523542345.677]
], [
[1, 2],
[3, 7]
]
])
)
E assert comparison failed for 3 values:
E Index | Obtained | Expected
E (0, 0, 0) | 1.1987311 | 1.12313 ± 1.1e-06
E (0, 1, 1) | 1423412423415.677 | 534523542345.677 ± 5.3e+05
E (1, 1, 1) | 219371297321973.0 | 7.0 ± 7.0e-06
```
#### Additional context
Just to mention, I didn't find any similar issue, so I'm starting a new one. The following issue has similar title, but it is completely different: https://github.com/pytest-dev/pytest/issues/6985
Please, let me know if you guys like my proposal, and feel free to suggest improvements - I'll be happy to hear ideas.
Also, feel free to disagree and close this proposal, so I will just move my code to my project's `conftest.py` ;)
author:
url:https://github.com/tarcisiofischer
type:Person
name:tarcisiofischer
datePublished:2021-02-10T21:28:23.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:11
url:https://github.com/8335/pytest/issues/8335
context:https://schema.org
headline:Improve pytest.approx error messages readability
articleBody:Hey all. I think that as important as getting `PASSED` on our tests, it is important to get useful messages when the tests `FAIL`. That being said...
#### What's the problem this feature will solve?
While comparing numerical data with `pytest.approx`, I find the messages a bit hard to read when we are comparing big enough numpy arrays. Example:
```python
def test_bla():
import numpy as np
a = np.linspace(0, 100, 20)
b = np.linspace(0, 100, 20)
a[10] += 0.5
assert a == pytest.approx(b)
```
The error message:
```
> assert a == pytest.approx(b)
E assert array([ 0. , 5.26315789, 10.52631579, 15.78947368,\n 21.05263158, 26.31578947, 31.57894737, 36.84210526,\n 42.10526316, 47.36842105, 53.13157895, 57.89473684,\n 63.15789474, 68.42105263, 73.68421053, 78.94736842,\n 84.21052632, 89.47368421, 94.73684211, 100. ]) == approx([0.0 ± 1.0e-12, 5.2631578947368425 ± 5.3e-06, 10.526315789473685 ± 1.1e-05, 15.789473684210527 ± 1.6e-05, 21.05263157894737 ± 2.1e-05, 26.315789473684212 ± 2.6e-05, 31.578947368421055 ± 3.2e-05, 36.8421052631579 ± 3.7e-05, 42.10526315789474 ± 4.2e-05, 47.36842105263158 ± 4.7e-05, 52.631578947368425 ± 5.3e-05, 57.89473684210527 ± 5.8e-05, 63.15789473684211 ± 6.3e-05, 68.42105263157896 ± 6.8e-05, 73.6842105263158 ± 7.4e-05, 78.94736842105263 ± 7.9e-05, 84.21052631578948 ± 8.4e-05, 89.47368421052633 ± 8.9e-05, 94.73684210526316 ± 9.5e-05, 100.0 ± 1.0e-04])
```
This is the main example I want to solve, although I've implemented a solution for other cases.
#### Describe the solution you'd like
Would be nice to have something like this:
```
> assert a == pytest.approx(b)
E assert comparison failed for 1 values:
E Index | Obtained | Expected
E (10,) | 53.131578947368425 | 52.631578947368425 ± 5.3e-05
```
#### ~Alternative~ Solutions
I haven't tried any workaround. But I implemented a solution, using `pytest_assertrepr_compare`. It is in this gist: https://gist.github.com/tarcisiofischer/cab56a5eb65aaa03bdbb4d206f1d49f0
Examples:
```
> assert [1, 2, 3, 4] == pytest.approx([1, 3, 3, 5])
E assert comparison failed for 2 values:
E Index | Obtained | Expected
E 1 | 2 | 3 ± 3.0e-06
E 3 | 4 | 5 ± 5.0e-06
```
```
> assert 1.0 == pytest.approx(2.0)
E assert comparison failed
E Obtained: 1.0
E Expected: 2.0 ± 2.0e-06
```
```
> assert {'a': 1, 'b': 3} == pytest.approx({'a': 1.7, 'b': 3})
E assert comparison failed for 1 values:
E Index | Obtained | Expected
E a | 1 | 1.7 ± 1.7e-06
```
A big one (sorry for the dump)
```
> assert np.array([
[
[1.1987311, 12412342.3],
[3.214143244, 1423412423415.677]
], [
[1, 2],
[3, 219371297321973]
]
]) == pytest.approx(
np.array([
[
[1.12313, 12412342.3],
[3.214143244, 534523542345.677]
], [
[1, 2],
[3, 7]
]
])
)
E assert comparison failed for 3 values:
E Index | Obtained | Expected
E (0, 0, 0) | 1.1987311 | 1.12313 ± 1.1e-06
E (0, 1, 1) | 1423412423415.677 | 534523542345.677 ± 5.3e+05
E (1, 1, 1) | 219371297321973.0 | 7.0 ± 7.0e-06
```
#### Additional context
Just to mention, I didn't find any similar issue, so I'm starting a new one. The following issue has similar title, but it is completely different: https://github.com/pytest-dev/pytest/issues/6985
Please, let me know if you guys like my proposal, and feel free to suggest improvements - I'll be happy to hear ideas.
Also, feel free to disagree and close this proposal, so I will just move my code to my project's `conftest.py` ;)
author:
url:https://github.com/tarcisiofischer
type:Person
name:tarcisiofischer
datePublished:2021-02-10T21:28:23.000Z
interactionStatistic:
type:InteractionCounter
interactionType:https://schema.org/CommentAction
userInteractionCount:11
url:https://github.com/8335/pytest/issues/8335
Person:
url:https://github.com/tarcisiofischer
name:tarcisiofischer
url:https://github.com/tarcisiofischer
name:tarcisiofischer
InteractionCounter:
interactionType:https://schema.org/CommentAction
userInteractionCount:11
interactionType:https://schema.org/CommentAction
userInteractionCount:11
External Links {🔗}(3)
Analytics and Tracking {📊}
- Site Verification - Google
Libraries {📚}
- Clipboard.js
- D3.js
- Lodash
Emails and Hosting {✉️}
Mail Servers:
- aspmx.l.google.com
- alt1.aspmx.l.google.com
- alt2.aspmx.l.google.com
- alt3.aspmx.l.google.com
- alt4.aspmx.l.google.com
Name Servers:
- dns1.p08.nsone.net
- dns2.p08.nsone.net
- dns3.p08.nsone.net
- dns4.p08.nsone.net
- ns-1283.awsdns-32.org
- ns-1707.awsdns-21.co.uk
- ns-421.awsdns-52.com
- ns-520.awsdns-01.net