Git Product home page Git Product logo

Comments (10)

vvnkr avatar vvnkr commented on September 25, 2024

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.

vvnkr avatar vvnkr commented on September 25, 2024

@filipsch Referencing this for pythonwhat implementation: http://stackoverflow.com/questions/10710328/comparing-numpy-arrays-containing-nan

from pythonwhat.

hugobowne avatar hugobowne commented on September 25, 2024

holy wacky races! spooky NumPy. The issue also occurs w/ dataframes FYI:

https://campus.datacamp.com/courses/1167/2627?ex=15

from pythonwhat.

hugobowne avatar hugobowne commented on September 25, 2024

it also occurs with pickle.load when there are no NaNs. I can raise another issue if necessary. see screenshot

screenshot 2016-06-09 07 28 27

https://campus.datacamp.com/courses/1167/2628?ex=3

from pythonwhat.

hugobowne avatar hugobowne commented on September 25, 2024

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

screenshot 2016-06-09 07 30 20

from pythonwhat.

hugobowne avatar hugobowne commented on September 25, 2024

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.

hugobowne avatar hugobowne commented on September 25, 2024

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.

vvnkr avatar vvnkr commented on September 25, 2024

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.

hugobowne avatar hugobowne commented on September 25, 2024

thanks!working in all cases except one:

https://campus.datacamp.com/courses/1167/2627?ex=13

screenshot 2016-06-18 14 40 20

thoughts?

from pythonwhat.

vvnkr avatar vvnkr commented on September 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.