Comments (10)
Problem is that test_object()
uses np.all()
in this case. If you test this code:
import numpy as np
file = 'titanic.csv'
data1 = np.genfromtxt( file , delimiter = ',', names = True , dtype = None )
data2 = np.genfromtxt( file , delimiter = ',', names = True , dtype = None )
np.all(data1==data2)
You'll notice that it results in False
, even though the arrays seem exactly the same. This means test_object()
will test false when it compares data
from the solution environment with data
in the student environment. The reason is because you have numpy.float64
characters in the column with index 4
. This sometimes is nan
, which is an object of the type numpy.float64
. Apparently numpy doesn't count nan == nan
as True
.
@filipsch we'll need a workaround for this. Maybe use numpy.testing.assert_equal
.
from pythonwhat.
@filipsch Referencing this for pythonwhat implementation: http://stackoverflow.com/questions/10710328/comparing-numpy-arrays-containing-nan
from pythonwhat.
holy wacky races! spooky NumPy. The issue also occurs w/ dataframes FYI:
https://campus.datacamp.com/courses/1167/2627?ex=15
from pythonwhat.
it also occurs with pickle.load
when there are no NaNs. I can raise another issue if necessary. see screenshot
https://campus.datacamp.com/courses/1167/2628?ex=3
from pythonwhat.
same issue with pd.ExcelFile()
https://campus.datacamp.com/courses/1167/2628?ex=4
in this case NOT dataframe but type(xl) = pandas.io.excel.ExcelFile
from pythonwhat.
Hi guys, this issue will block beta testing, which is slated for next Thursday 06/23. I'll need this to work before emailing potential beta testers, which I need to 4 days before beta testing starts (Sunday 06/19).
from pythonwhat.
i checked out commit for this issue: will it work in the dataframe and excel cases?
see here:
https://campus.datacamp.com/courses/1167/2627?ex=15
and here:
https://campus.datacamp.com/courses/1167/2628?ex=4
from pythonwhat.
Correct, this will do.
Note that this time I created specific equality tests for these kind of objects. If it's only used in just a few exercises and you can avoid it by using do_eval = False
and test_function()
, then do that. It's not manageable to create equality tests for all kinds of objects.
from pythonwhat.
thanks!working in all cases except one:
https://campus.datacamp.com/courses/1167/2627?ex=13
thoughts?
from pythonwhat.
Use a workaround here (with test_object(..., do_eval = False)
and test_function(...)
). Use this wiki section as a reference.
Btw, problem is that:
np.testing.assert_equal(np.genfromtxt(file , delimiter = ",", names = True , dtype = None), np.genfromtxt(file , delimiter = ",", names = True , dtype = None))
throws an AssertionError
. Which means that even np
's testing framework doesn't see those numpy arrays as equal.
from pythonwhat.
Related Issues (20)
- Better support to check pandas chains
- Get rid of test_with()
- More clearly document check_args() for check_function_def()
- Fix old SCTs that fail assertions HOT 2
- check_class_def support HOT 6
- check_function inside for loop can't find aliases outside
- Expose and document `has_error()` function
- Incorrect highlighting because of flaws in ObjectAssignmentParser
- Add article about message generation
- Improve API for checking the signature in check_function_def
- Reference: check_object missing explanation of two params HOT 1
- Unable to Install HOT 2
- Document the order to check chained functions
- The easy way to extract the message associated with "TestFail" HOT 2
- Specifying filenames to setup_state() HOT 2
- Add a tolerance argument to has_equal_value()
- Add a test based on the line of a code
- check_function() not working as documented (or what am I missing?)
- has_output() doesn't work with two 'print'
- Small documentation error on check_function_def
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pythonwhat.