Search Results

Search found 5 results on 1 pages for 'cpplearner'.

Page 1/1 | 1 

  • Shutdown issues on my Dell XPS M1530

    - by CppLearner
    On my Dell XPS M1530 lapttop, I am facing issues with shut-down option after upgrading to 12.04 LTS from 11.10. Sometimes it shutdowns "cleanly". But other times everything goes down but I can still see the power LED glowing (even after removing the power cord). If I keep it like that laptop temperature increases. So finally I opt for "hard shut-down" (i.e. pressing the power button on). Any thoughts what is happening here?. Edit: I just found this link to already reported bug https://bugs.launchpad.net/ubuntu/+source/linux/+bug/987933

    Read the article

  • Am I mocking this helper function right in my Django test?

    - by CppLearner
    lib.py from django.core.urlresolvers import reverse def render_reverse(f, kwargs): """ kwargs is a dictionary, usually of the form {'args': [cbid]} """ return reverse(f, **kwargs) tests.py from lib import render_reverse, print_ls class LibTest(unittest.TestCase): def test_render_reverse_is_correct(self): #with patch('webclient.apps.codebundles.lib.reverse') as mock_reverse: with patch('django.core.urlresolvers.reverse') as mock_reverse: from lib import render_reverse mock_f = MagicMock(name='f', return_value='dummy_views') mock_kwargs = MagicMock(name='kwargs',return_value={'args':['123']}) mock_reverse.return_value = '/natrium/cb/details/123' response = render_reverse(mock_f(), mock_kwargs()) self.assertTrue('/natrium/cb/details/' in response) But instead, I get File "/var/lib/graphyte-webclient/graphyte-webenv/lib/python2.6/site-packages/django/core/urlresolvers.py", line 296, in reverse "arguments '%s' not found." % (lookup_view_s, args, kwargs)) NoReverseMatch: Reverse for 'dummy_readfile' with arguments '('123',)' and keyword arguments '{}' not found. Why is it calling reverse instead of my mock_reverse (it is looking up my urls.py!!) The author of Mock library Michael Foord did a video cast here (around 9:17), and in the example he passed the mock object request to the view function index. Furthermore, he patched POll and assigned an expected return value. Isn't that what I am doing here? I patched reverse? Thanks.

    Read the article

  • Solving for the coefficent of linear equations with one known coefficent

    - by CppLearner
    clc; clear all; syms y a2 a3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % [ 0.5 0.25 0.125 ] [ a2 ] [ y ] % [ 1 1 1 ] [ a3 ] = [ 3 ] % [ 2 4 8 ] [ 6 ] [ 2 ] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% M = [0.5 0.25 0.125; 1 1 1; 2 4 8]; t = [a2 a3 6]; r = [y 3 2]; sol = M * t' s1 = solve(sol(1), a2) % solve for a2 s2 = solve(sol(2), a3) % solve for a3 This is what I have so far. These are my output sol = conj(a2)/2 + conj(a3)/4 + 3/4 conj(a2) + conj(a3) + 6 2*conj(a2) + 4*conj(a3) + 48 s1 = - conj(a3)/2 - 3/2 - Im(a3)*i s2 = - conj(a2) - 6 - 2*Im(a2)*i sol looks like what we would have if we put them back into equation form: 0.5 * a2 + 0.25 * a3 + 0.125 * a4 a2 + a3 + a4 = 3 2*a2 + 4*a3 + 8*a4 = 2 where a4 is known == 6. My problem is, I am stuck with how to use solve to actually solve these equations to get the values of a2 and a3. s2 solve for a3 but it doesn't match what we have on paper (not quite). a2 + a3 + 6 = 3 should yield a3 = -3 - a2. because of the imaginary. Somehow I need to equate the vector solution sol to the values [y 3 2] for each row.

    Read the article

  • Scheme - What is wrong with my attempt to extend this declaration?

    - by CppLearner
    This is a homework question. Question My attempt (the whole file): http://pastebin.com/vt3Q3dqs If you search let var = exp1 in body, that's the function I need to extend according to the question. When I test the sample code above, I get an error apply-env: No binding for y (eval "let x = 30 in let x = -(x,1) y = -(x,2) in -(x,y)") ; The following is execution log The-next-two-lines-shows-var-and-exp1 (x) (#(struct:const-exp 30)) diff-exp #(struct:var-exp x) #(struct:const-exp 1) diff-exp #(struct:var-exp x) #(struct:const-exp 2) The-next-two-lines-shows-var-and-exp1 (x y) (#(struct:diff-exp #(struct:var-exp x) #(struct:const-exp 1)) #(struct:diff-exp #(struct:var-exp x) #(struct:const-exp 2))) diff-exp #(struct:var-exp x) #(struct:var-exp y) As you can see, when the interperter reads the last line -(x,y) it complains because there is no binding. What did I do wrong? I know this is really long language, but if anyone can kindly lead me to the right direction would be really really nice. Thank you!

    Read the article

  • What is an alternative to eval in this situation?

    - by CppLearner
    Many of my view functions do similar things. For the most part, they reverse to a different views upon clicking a button / a text link. So I wrote a helper function render_reverse def render_reverse(f, args): # args are all string type return eval('reverse(' + f + ', ' + args + ')' ) eval is a bad practice, and is pretty slow. It takes 3 seconds to start redirecting, whereas calling reverse directly takes less than 1 second to start redirecting. What alternative do I have? By the way, the function above doesn't work properly. I was modelling after this line (which works) eval('reverse("homepage", args=["abcdefg"])') Thanks.

    Read the article

1