Quantcast
Channel: User abought - Stack Overflow
Browsing latest articles
Browse All 40 View Live

Comment by abought on Can't figure out a Python exercise with dictionaries

This isn't a homework site. It sounds like you need to read the documentation for (the type of data structure represented by inventory), to discover: how to check whether a key is present; how to get...

View Article



Comment by abought on How to parse a structured text file into MySQL records...

I haven't used it personally, but- recognizing that ubuntu is a flavor of debian- you might be able to reuse a prebuilt parser for debian package files. Eg packages.debian.org/sid/python-debian /...

View Article

Comment by abought on Generate one specific permutation of array based on an...

We could hard-code the list of all permutations, but for a 6-item list, that's 720 hard coded items. (it gets big fast) There's no caching because the list of possible arrangements is generated on the...

View Article

Comment by abought on Generate one specific permutation of array based on an...

If I'm reading this correctly, one drawback is the need to brute-force calculate at least every arrangement up to and including the one desired. This might be be feasible, but as people progress deeper...

View Article

Comment by abought on Filter data using params in ember

You already do. It's the if block that doesn't return a promise. It should read: something like return this.get('store').query('car', { filter: { brand: params['marca'] }});

View Article


Comment by abought on Is it ok/pythonic to call another function as an...

You can slightly shorten the second example as name = name or get_name(). But Daniel is right- the first example runs a risk of introducing very subtle bugs.

View Article

Comment by abought on Mouse pointer not staying hidden on chrome fullscreen div

Interesting. I'm not sure why inlining the image solves this (especially when the alternative was cursor: none), but it does seem to help in preliminary testing. A strange issue with a strange answer,...

View Article

Comment by abought on EmberJS Getting Broccoli error when Ember build prod

Did you always see this error, or is it new? We had a similar (though different) error message today, which we traced to a recently released new version of a dependency (ember-cli in our case). Pinning...

View Article


Comment by abought on Ember ember-simple-auth override...

For details on available options, see the API docs: ember-simple-auth.com/api/classes/Configuration.html

View Article


Comment by abought on Hiding an (active) app/game from search results

@MarcinOrlowski : Because our app is in a broken state without it- configuration is part of making things work. Slightly less cheekily, this is the recommended mechanism for in depth questions on...

View Article

Comment by abought on Issue making range requests in some browsers

Thanks for the helpful links- particularly the ticket with browser status! Though it seems there is some role in the server sending back an unreadable response, GitHub's support page explicitly...

View Article

Comment by abought on Total memory used by Python process?

Note that this may fail if you just try to use time instead of /usr/bin/time. See: askubuntu.com/questions/434289/…

View Article

Comment by abought on Terraform output being flagged as sensitive

This fixed it for me as well. Very unintuitive: a) without the extra cloud security setting, terraform console on my local machine could see the value from that provider even when running within the...

View Article


Answer by abought for Python text clustering software or package

It's not entirely clear what your goals are, or what your data looks like. (A list of wordcounts per passage? Something else?)For starters, then, I would recommend separating the data collection/...

View Article

Answer by abought for Compare multiple columns in numpy array

Extending on unutbu's longer answer above, it's possible to generate the masked array of scores automatically. Since your scores for values are consistent every pass through the loop, so the scores for...

View Article


Answer by abought for Tuple as index of multidimensional array

You can also pass in your first tuple alone to get the slice of interest, then index it seprately:from numpy.random import randbig_array=rand(3,3,4,5)chosen_slice = (2,2)>>> big_array[...

View Article

Answer by abought for Convert lists into 'transposed' list

I notice that your data includes time stamps and numbers. If you're doing number-intensive calculations, then numpy arrays might be worth a look. They offer better performance, and transposing is very...

View Article


Answer by abought for Split a tuple of tuples (or list of lists) of paired...

You could manually define your sublists using slicing:completeset1=megalist[0:4]completeset2=megalist[4:]However, it really sounds like you'd like to apply some deeper logic, or use additional data, to...

View Article

Answer by abought for Histogram with bins a percentage of values?

In general, it's convenient to create histograms using pre-defined tools like numpy.histogram , though your newly posted comment- suggesting that you're using matplotlib- is also totally fine. Either...

View Article

Answer by abought for Why I can't read anything with File.open in python when...

In line 3, f.close should read f.close(). To force the file to write immediately (rather than when the file is closed), you can call f.flush() after writing: see Why file writing does not happen when...

View Article

Answer by abought for print number is even

Python requires indentation, as well as a : after the if statement. Here is a corrected version of the above that would work:number = 7remainder = number%2if remainder == 0: print("Number is...

View Article


Answer by abought for Proper data visualization to graph sleep data

This is an extremely specific and narrowly focused question. That said, I see two problems with the color bar visualization proposed:It only differentiates between different data segments by color. A...

View Article


Answer by abought for How to find the most recently added item to a Queue in...

How are you implementing your queue? If it's implemented as a list, then presumably yourdata.pop(0) would remove and return the first item. The most recently enqueued item would be at the end of the...

View Article

Answer by abought for python: why IDLE is slower than terminal?

The bulk of the problem is in how IDLE handles printing of text to the output window; try commenting out the print statement and see if the performance gap remains. See this closely related thread:...

View Article

Answer by abought for Count all values in a matrix less than a value

The numpy.where function is your friend. Because it's implemented to take full advantage of the array datatype, for large images you should notice a speed improvement over the pure python solution you...

View Article


Answer by abought for Running a Python script for the first time. Using...

You actually can run your script from inside the interactive interpreter (which is what you get when you run python instead of running a script from the terminal as python scriptname.py). First, cd to...

View Article

Answer by abought for Separating list elements in Python

Python for loops iterate over actual object references. You may be seeing strange behavior partly because you're giving the object reference i where a numerical list index should go ( the statement...

View Article

Answer by abought for python decorator for field

If you want to preserve variable names for referring to later, you could use a dictionary. Hence, this code inside your object...self.dict_bar_props = {}self.dict_bar_props["a"] =...

View Article

Answer by abought for How to use a pair of nested for loops to iterate over a...

Based on your question, it appears you're using Numpy. If you're not too concerned about speed, you can simply call the function with a numpy array; the function will operate on the entire array for...

View Article



Answer by abought for Most pythonic way to delete a file which may not exist

os.path.exists returns True for folders as well as files. Consider using os.path.isfile to check for whether the file exists instead.

View Article

Answer by abought for Nested list comprehension, python, pattern printing

List comprehensions aren't a direct replacement for loops in every case.You use a list comprehension when you want to store the resulting data structure for later use- it takes up space in memory, etc....

View Article

Answer by abought for Ember non-static Navbar

It sounds like you want to change the contents of a parent route based on the state (and type) of the logged in user. This is often done via ember services- shared data that persists for the lifetime...

View Article

Answer by abought for Accessing Ember environment config (ENV) from addon?

I've used this package in my projects to good effect:https://github.com/null-null-null/ember-get-config

View Article


Mouse pointer not staying hidden on chrome fullscreen div

I would like to make an HTML element fullscreen (a div), and have the pointer remain hidden.This would seem straightforward (set cursor:none on the div when it becomes fullscreen), but it is not...

View Article

Answer by abought for how do post to a nested route in emberjs

Two possible options:If you are using ember data, define a model with fields that match your API endpoint, and use this.store.createRecord(...) to create the model. By default, ember-data will try to...

View Article

Answer by abought for How to validate checkbox, selectbox and radiobutton in...

ember-cp-validations validates the value of variables (whether on a model, controller, etc). As long as the checkbox is bound to a variable of the same name as specified in the validator, it should...

View Article


Answer by abought for Using print with open=

In python, we don't normally do this using print statements. Consider the following alternative. Using a "context manager" allows you to write more than one line, and also helps avoid certain problems...

View Article


Issue making range requests in some browsers

Summary: I would like to make a Range header request from GitHub pages. However, in some browsers this is failing- possibly due to Gzip compression issues. It works in Chrome (v74) but not in FF (v66),...

View Article

Image may be NSFW.
Clik here to view.

Cloudwatch alarm triggers too often

Summary: We are using a Cloudwatch alarm to tell us when a certain (EMR) cluster is having trouble getting (spot) instances. The alarm is triggering more often than it should. Why?Detail: In theory, it...

View Article

Dynamically adding new fabric canvases

I am working on a project that requires creating multiple canvas elements (separate bars each representing one distinct gradient). I would like to do this dynamically with fabric.js, eg: function...

View Article
Browsing latest articles
Browse All 40 View Live




Latest Images