the path starts with
> /usr/bin or whether it belongs to root. Tying into the system's package
> manager doesn't look appealing to me (not to mention that it might be
> unacceptably slow).
Couldn't the system-installed scripts have a shebang like:
#!/usr/bin/python3 -s
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
't come up in string parsing if not using
eval. Not a likely security issue but I am suddenly reminded of this
dangerous snippet:
x = [0]; x.extend(iter(x))
If you want to test it then make sure to save your work etc and be
prepared to hard reset the computer. On this machine Ct
.0571428571428571428571428571428571428571428571428571428571429
SymPy uses mpmath for evalf but it allows doing exact calculations
first and then evaluating the final exact expression to however many
digits are desired at the end which means that you don't need to
accumulate rounding errors before calling evalf.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
pose(a))
Out[10]: array([1, 2, 3])
https://en.wikipedia.org/wiki/Greatest_common_divisor
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
that raises a particular exception type and only
one place that catches it then it is usually going to be clear that
you are catching the expected exception.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
t also you first need to build/install a BLAS
library.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 12 Jun 2024 at 23:11, Chris Angelico via Python-list
wrote:
>
> On Thu, 13 Jun 2024 at 07:57, Oscar Benjamin via Python-list
> wrote:
> > They are seeing a warning that explicitly says "You can upgrade to a
> > newer version of Python to solve this"
entirely reasonable to start by suggesting to use a newer
version of Python until some reason is given for not doing that.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
shared.
I am not going to reply to your other points except to say that if you
want to influence anything then I expect that you would have more
success with a different approach.
To anyone else considering replying in this thread: please don't. I
very much doubt that anything good will happen
precisely why moderation
(including deleting posts such as yours) is needed to *prevent* a
forum from turning into a toxic pit.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
pep-deferral
Instead for understanding the wheel format the appropriate document is:
https://packaging.python.org/en/latest/specifications/binary-distribution-format/
That document does not mention Install-Paths-To because it documents
the standards as defined and accepted via the PEP proces
thod.
In principle this could use a large number of man>>=8 shifts which
would potentially be quadratic in the bit size of man. In practice the
probability of hitting the worst case is very low so the code is
instead optimised for the expected common case of large man with few
trailing zeros.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ributeError: module 'tkinter' has no attribute 'messagebox'
> >>>
>
> Why is this?
Do you have a file called tkinter.py in the current directory?
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
fusing
though because the possible behaviour of enumerate(a) would be
different depending on the type of a.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
before making a
release that is fully tested with it (even if you are testing the
alphas etc in CI and making incremental fixes before 3.12 is
released).
The other option could be changing the downloads page so that it does
not suggest 3.12.0 as the default option until it is clear that at
least some baseline of widely used packages have uploaded compatible
wheels.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
certain extent it just forms part of
the normal CI setup that a project like numpy would want to have
anyway.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
'expm1',
'fabs',
'factorial',
'floor',
'fmod',
'frexp',
'fsum',
'gamma',
'gcd',
'hypot',
'inf',
'isclose',
'isfinite',
'isinf',
'isnan',
'isqrt',
'ldexp',
'lgamma',
'log',
'log10',
'log1p',
'log2',
'modf',
'nan',
'perm',
'pi',
'pow',
'prod',
'radians',
'remainder',
'sin',
'sinh',
'sqrt',
'tan',
'tanh',
'tau',
'trunc']
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
at the built-in version can not do, and
> if not, why is it even there?
It is useful for when you want the pure floating point power which has
an approximately fixed computational cost (unlike integer powers).
Perhaps it would have been better if it was named fpow similar to fsum
vs sum.
--
Osca
ation in your code would be weights[input].sum()
and would be much faster than the loop shown (the speed difference
will be larger if you increase the size of the input array).
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Tue, 28 Feb 2023 at 20:55, Mats Wichmann wrote:
>
> On 2/27/23 16:42, Oscar Benjamin wrote:
> > On Mon, 27 Feb 2023 at 21:06, Ethan Furman wrote:
> >>
> >> On 2/27/23 12:20, rbowman wrote:
> >>
> >> > "By using Black, you agree to ced
have also reviewed code where it is clear that the author
has used black and their code came under case 2. In that case Black
seems to produce awful things. What I can't understand is someone
accepting the awful rewrite rather than just fixing the code. Treating
Black almost like a linter make
On Sat, 18 Feb 2023 at 11:19, Peter J. Holzer wrote:
>
> On 2023-02-18 03:52:51 +, Oscar Benjamin wrote:
> > On Sat, 18 Feb 2023 at 01:47, Chris Angelico wrote:
> > > On Sat, 18 Feb 2023 at 12:41, Greg Ewing via Python-list
> > > > To avoid it you would need
your use case. IEEE standards do their best to make
results reproducible across machines as well as limiting avoidable
local errors so that global errors in larger operations are *less
likely* to dominate the result. Their guarantees are only local though
so as soon as you have more complicated calculations you need your own
error analysis somehow. IEEE guarantees are in that case also useful
for those who actually want to do a formal error analysis.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ion and eager evaluation are
the only option.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
a**(1/3)*(x - 1/3)*log(a) + O((x - 1/3)**2, (x, 1/3))
You can see that the leading relative error term from x being not
quite equal to 1/3 is proportional to the log of the base. You should
expect this difference to grow approximately linearly as you keep
adding more zeros in the base.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
_key": {'a':1, 'b':2}},
...: { "some_other_key": {'a':3, 'b':4}}
...: ]
In [40]: [{"value": k, **m} for l in L for k, m in l.items()]
Out[40]:
[{'value': 'some_key', 'a': 1, 'b': 2},
{'value': 'some_other_key', 'a': 3, 'b': 4}]
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ightly more than getch is readchar's
readkey which also works for pressing non-character keys. There were
times in the past where I might have used that if I'd known about it.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
el *within the same program*. If you relax that constraint the
problem becomes a lot simpler.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
here is math.prod:
>>> from math import prod
>>> prod([1, 2, 3, 4])
24
https://docs.python.org/3/library/math.html#math.prod
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
in creating NumPy (in the NumPy/SciPy split) was that
it might be possible that NumPy could be merged into core Python.
Unfortunately that didn't come to be.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
tten in C but not as well optimised. This used to be the default
for a pip install on Linux in pre-wheel times.
Many operations in NumPy don't actually use BLAS/LAPACK and for those
parts the heavy lifting is all done in NumPy's own C code.
Lastly SciPy which is very often used together w
uot;time" command does). You
can also use time.time() from Python for this. Profilers and timeit
help to identify ways to speed up your code but should not be used as
the way to assess the final impact of the changes you make to a long
running program.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Fri, 17 Dec 2021 at 23:11, Chris Angelico wrote:
>
> On Sat, Dec 18, 2021 at 10:01 AM Oscar Benjamin
> wrote:
> >
> > On Fri, 17 Dec 2021 at 22:40, Chris Angelico wrote:
> > >
> > > On Sat, Dec 18, 2021 at 9:24 AM Oscar Benjamin
> > > wrote:
On Fri, 17 Dec 2021 at 22:40, Chris Angelico wrote:
>
> On Sat, Dec 18, 2021 at 9:24 AM Oscar Benjamin
> wrote:
> > When I timed the result in Julia and in Python I found that the Julia
> > code was slower than the Python code. Of course I don't know how to
> > op
accurate for other
situations but at least with Symbolics it's wildly out which makes me
question any timings that I see reported by proselytisers of Julia.
I don't want to knock Julia as a language or the Symbolics.jl library.
I think it's a nice language and I'm sure it's well suited to certain
applications. I'm also sure that many of the things I've mentioned
above are being worked on and will improve over time. However the idea
that Julia is faster than Python in general should not go
unquestioned.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
elements being multiplied and summed have pure-Python
__add__/__mul__ methods or the container has a pure Python
__iter__/__next__ then any of those methods will typically dominate
the runtime over any of the overheads considered here.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 25 Sept 2021 at 02:11, Oscar Benjamin
wrote:
> On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote:
>
>> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin
>> wrote:
>> >
>> > On Sat, 25 Sept 2021 at 00:37, Greg Ewing
>> > wrote:
>> >
On Sat, 25 Sept 2021 at 02:16, Chris Angelico wrote:
> On Sat, Sep 25, 2021 at 11:11 AM Oscar Benjamin
> wrote:
> >
> > On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote:
> >>
> >> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin
> >> wrote:
>
On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote:
> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin
> wrote:
> >
> > On Sat, 25 Sept 2021 at 00:37, Greg Ewing
> > wrote:
> > > I suppose they could be fiddled somehow to make it possible, but
> > &g
with
> sum().
>
A separate union function would be good. Even in a situation where all
inputs are assured to be sets the set.union method fails the base case:
>>> sets = []
>>> set.union(*sets)
Traceback (most recent call last):
File "", line 1, in
TypeError:
ill be the exact value that fsum will return. In other
> words, its accuracy is exactly as good as the final result can be.
It's as good as it can be if the result must fit into a single float.
Actually the algorithm itself maintains an exact result for the sum
internally using a list of floats whose exact sum is the same as that
of the input list. In essence it compresses a large list of floats to
a small list of say 2 or 3 floats while preserving the exact value of
the sum.
Unfortunately fsum does not give any way to access the internal exact
list so using fsum repeatedly suffers the same problems as plain float
arithmetic e.g.:
>>> x = 10**20
>>> fsum([fsum([1, x]), -x])
0.0
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
.
If there is a bug in multiprocessing then the issue should be clearer about
what it is or why it should be considered a bug. Which function is
documented as doing something that apparently does not work in this case?
Why should it be expected to work?
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
In article ,
Henning Follmann wrote:
>>>Looks like you (the project leader?) needs training, not the
>>>software engineers.
>>>
>>>"Making Things Happen" by Scott Berkun
>>
>> This looks like a very interesting book to add to my reading list, but
>> how do you think it will help the OP with his/
In article ,
Henning Follmann wrote:
>On 2021-02-10, Python wrote:
>> Hi,
>>
>> If you had to train engineers who are used to write
>> Python scripts for image processing, data format conversion,
>> etc. (so they know most the basics of Python types and
>> programming structures except advance
In article <5fd4f4b5$0$8928$426a7...@news.free.fr>, ast wrote:
>Le 12/12/2020 à 17:10, Oscar a écrit :
>> In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote:
>>> Hello
>>>
>>> In case a function recursively calls itself many times,
In article ,
Bischoop wrote:
>
>I need to check if input number is 1-5. Whatever I try it's not working.
>Here are my aproaches to the problem: https://bpa.st/H62A
>
>What I'm doing wrong and how I should do it?
You need to learn about types. ;-)
Input returns a string. That string is not in th
In article <5fd465b5$0$8956$426a7...@news.free.fr>, ast wrote:
>Hello
>
>In case a function recursively calls itself many times,
>is there a way to return a data immediately without
>unstacking all functions ?
If you are referring to your "are you ok?" problem, please read up on
recursion and wh
In article ,
Bischoop wrote:
>I've also convert the choice to int() but doesn't help.
Oh.. did not read this yet. How did you do this? In both places after
the input or during the comparison? If so, in which version? Only the
first version would work. The other two are just plain wrong.
--
[J|O
tors can return instances of Relational. When they can
be evaluated those will give sympy's Booleans rather than bool.
In [6]: import sympy as sym
In [7]: x = sym.Symbol('x')
In [8]: x > 0
Out[8]: x > 0
In [9]: type(_)
Out[9]: sympy.core.relational.StrictGreaterThan
I
er a few examples and some familiarity it could be time to
suggest installing locally. That should be with a no nonsense
explanation that makes no reference to terminals, PATH, etc because
those are just intimidating distractions to a novice at that point in
time.
The sympy docs have a lo
where once Python is
installed it can be run by typing "python" in whatever terminal you
want.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ife much easier for yourself by choosing a subset of the
columns that you are likely to be interested in and reducing the size
of your dataset before you begin.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
; imagines it could make porting some code in or out of Python trickier
Python 2 used comparison functions but Python 3 uses key functions.
There is a helper called cmp_to_key that can convert a comparison
function into a key function:
https://docs.python.org/3.8/library/functools.html#functools.c
if the exception is
raised in your code then it should be a dedicated exception class. If
that exception is only raised in one specific place I see nothing
wrong with wrapping all of your code in a try/except that catches that
one exception: when the exception is caught you know exactly why and
can handle appropriately.
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
t as well as of type:
>>> isinstance(object, object)
True
>>> isinstance(object, type)
True
>>> isinstance(type, object)
True
>>> isinstance(type, type)
True
>>> issubclass(object, type)
False
>>> issubclass(type, object)
True
>>> type.mro(type)
[, ]
>>> type.mro(object)
[]
>>> type(object)
>>> type(type)
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
t;"
Output:
$ python tmp.py
A.__init__ a
C.__init__ c
D.__init__ foo
D.__init__ d
So B.__init__ is never called and D.__init__ is called twice. I wonder
if there is a sensible way of organising this. Certainly I've always
taken the approach that you either use __new__ or __init__ and don't
mix them up.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Sat, 14 Sep 2019 at 07:22, ast wrote:
>
> Le 14/09/2019 à 04:26, Oscar Benjamin a écrit :
> >
> > What am I missing?
>
> here is a pseudo code for product:
>
> def product(*args, repeat=1):
> # product('ABCD', 'xy') --> Ax Ay Bx By
On Sat, 14 Sep 2019 at 03:26, Oscar Benjamin wrote:
>
> I've been staring at this for a little while:
>
> from itertools import product
>
> class Naturals:
> def __iter__(self):
> i = 1
> while True:
> yield i
> i
product hangs but I can't see why. I
would expect that since I'm not iterating over the product it would
just call iter(N) but clearly not since iter(N) returns a generator
instantly where as product(N) hangs.
What am I missing?
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
so:
https://github.com/pypa/setuptools/issues
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ot being
synchronised. Pip depends on setuptools and cannot be used without it.
Both setuptools and pip are maintained under the PyPA. They are
intended to work together. in fact if your setup.py uses distutils
instead of setuptools then pip will "inject" setuptools into it to
ensure that
On Fri, 21 Dec 2018 at 09:32, Umar Yusuf wrote:
>
> On Wednesday, 19 December 2018 19:22:51 UTC+1, Oscar Benjamin wrote:
> > On Wed, 19 Dec 2018 at 05:42, Umar Yusuf wrote:
> > >
> > > Hello there,
> > > How do I supper impose an image design on a transpar
stackoverflow.com/questions/53791510/python-opencv-mask-and-glow
I don't understand what you're trying to do. Can you show example
input and desired output with example numbers? E.g.:
mask = [
[0, 0, 0, 0],
[0, 1, 1, 0],
...
]
image = [
[12, 32, 45, 56],
...
expected_output = ?
--
Osca
but when you say
k-clusters I assume you mean k-means:
https://en.wikipedia.org/wiki/K-means_clustering
Most discussions of k-means will assume that you are working in at
least 2 dimensions but in your case your data is 1D so bear that in
mind when comparing.
It's not hard to implement k-means
ix_scale is the
number of pixels that corresponds to a distance of 1 in your polar
coordinate system. You might choose this parameter based on the
height/width in pixels of the window. Depending on what you're doing
you may need to convert xq_p and yq_p to int rounding in some way.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, 5 Dec 2018 at 07:57, Peter Otten <__pete...@web.de> wrote:
>
> Oscar Benjamin wrote:
> >
> > I'm looking to import a module given a string representing the path to
> > the .py file defining the module.
>
> I am not aware of a clean way. I ha
n the file
'/home/oscar/work/project/a/b/c/stuff.py'. Given that a.b.c.stuff is
importable and I have the (relative or absolute) path of stuff.py as a
string I would like to import that module.
I want this to work in 2.7 and 3.4+ and have come up with the
following which works for valid
fair at?
This is easy enough to in OpenCV. The code at the top of this page
does what you want:
https://docs.opencv.org/3.4.2/dd/d49/tutorial_py_contour_features.html
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
how it
is designed):
class enumerate:
def __init__(self, iterable, start=0):
self.iterable = iterable
self.start = start
def __iter__(self):
count = self.start
for val in self.iterable: # Implicitly calls iter on iterable again
yield count, val
count += 1
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ting with
exit(). If I had written your script then it might look something
like:
def main():
password = 'bad'
if password == 'bad':
print('bad password')
return # <-- Not exit()
else:
print('good password')
e it is 'safe enough' for their purposes, so I don't
> want to overstate my case. Are there edge cases where that rounding method
> could fail?
That rounding method is not suitable. As mentioned by others you
should at least use round() if working with floats. Here&
plotlib.org/users/pyplot_tutorial.html
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On Sun, 26 Aug 2018 at 20:32, Musatov wrote:
>
> On Sunday, August 26, 2018 at 2:14:29 PM UTC-5, Oscar Benjamin wrote:
> > > > > > > >> On Fri, 24 Aug 2018 14:40:00 -0700, tomusatov wrote:
> > > > > > > >>
> > > &g
On Sat, 25 Aug 2018 at 20:27, Musatov wrote:
>
> On Saturday, August 25, 2018 at 2:18:09 PM UTC-5, Musatov wrote:
> > On Saturday, August 25, 2018 at 1:52:17 PM UTC-5, Oscar Benjamin wrote:
> > > > > >
> > > > > >> On Fri, 24 Aug 2018 14:40:00 -
, 2, 0, 2, 1, 0, 3, 1, 0, 1, 2, 0, 1, 1, 0, 5, 2, 0, 1, 1, 0,
> 2, 1, 0, 3, 1, 0, 1
Looks like it's zero for any multiple of 3 (apart from 3 itself). This
makes sense since if n is a equal to b*3 for some integer b then
n*2^k - 3 = b*3*2^k - 3 = (b*2^k - 1)*3
which can only be prime if
b*2^k - 1 = 1
which can only be true if b=1 (since k>0) implying that n=3. So for
any *other* multiple of 3 you must necessarily have a(n) = 0.
The above means that you can handle all multiples of 3 but how do you
know that you won't hit an infinite loop when n is not a multiple of
3? For that you need the converse of the above:
whenever n is not a multiple of 3 then a(n) != 0
I haven't put much thought into it but that might be easy to prove.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
r system you can
then consider all the permutations of mapping your students onto the
elements of the system - there will be N! of those but possibly with a
k! duplication so maybe there's an efficient way to only enumerate the
N!/k! possibilities. Hopefully N isn't too large...
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
it's not obvious from your snippet of code what you're
>> trying to achieve).
>
> To send and receive text from a subprocess..even when there are exceptions.
You can do this without threads on Linux using select (or similar):
https://docs.python.org/3.7/library/select.html#select.select
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
eld lineno, last_line[0], row
infile = ['a,b,c', '1,2,3', '4,5,6']
for lineno, line, row in csv_with_line(infile):
print(lineno, line, row)
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ssfully
> self definitely exists: <__main__.Eggs object at 0xb7bf21ec>
> Traceback (most recent call last):
> File "", line 1, in
> File "", line 8, in __init__
> Exception
Maybe the Exception traceback holds a reference to the object. Also try the
example outside of interactive mode since that can hold references.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
In article ,
Chris Angelico wrote:
>Yes, it's a third-party dependency. (Sorry, should have mentioned
>that.) You're welcome to consider that to be too much risk and/or
>hassle to be worth improving on getopt, but personally, I *really*
>like the simplicity of just writing docstrings that still r
In article ,
Chris Angelico wrote:
>On Wed, Jul 6, 2016 at 2:04 PM, Lawrence DâOliveiro
> wrote:
>> On Tuesday, July 5, 2016 at 1:42:42 AM UTC+12, Chris Angelico wrote:
>>
>>> The getopt module is designed to match the C getopt function, which I've
>>> never used; for my command-line parsing, I
In article ,
Chris Angelico wrote:
>On Mon, Jul 4, 2016 at 9:24 PM, Oscar wrote:
>> Is this:
>>
>> a) a bug in getopt.getopt
>> b) a bug in my code
>> c) a great way to keep me busy for a while
>> d) all of the above?
>>
>>
>> #!/u
Is this:
a) a bug in getopt.getopt
b) a bug in my code
c) a great way to keep me busy for a while
d) all of the above?
#!/usr/bin/python
from __future__ import print_function
from getopt import getopt, GetoptError
import sys
try:
opts, args = getopt(sys.argv[1:], 'b', ['bug '])
except Ge
. using (2) for complex numbers with
zero imaginary part) would probably lead to the results Steve expects.
I'm not really sure what the gain is though since we can't really do
robust algebra with infinities anyway.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
hink that you need Linux to run this code?
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
e-specific assumptions to be able to use
that information.
My understanding (although I have no direct experience here) is that
Stackless Python is an alternative implementation that gets around all
of these problems by avoiding the recursion altogether.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
ec = 2*prec + 1
N = Decimal(10)**(prec)
eapprox = (1 + 1/N)**N
ctx.prec = prec
return +eapprox
print(e(50))
Alternatively you can just use Decimal(1).exp().
> How does the math
> module calculate the vale of e?
https://hg.python.org/cpython/file/tip/Include/p
of 1e-4 we need N =
1/(2*1e-4) = 1e4/2 = 5e3 = 5000.
>>> import math
>>> N = 5000
>>> error = math.e - (1 + 1.0/N)**N
>>> relative_error = error / math.e
>>> relative_error
9.998167027596845e-05
Which is approximately 1e-4 as required.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
omputing the above numbers but in a slower way that
also has more potential for rounding error. The error here is 1e-13
for the last numbers in this sequence. But N=2**40 so your Euler
method would need approximately 10**12 iterations in your inner loop
to get the same result. That's going to be slow even if you don't use
a quadratic algorithm.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On 21 April 2016 at 15:12, Chris Angelico wrote:
> On Fri, Apr 22, 2016 at 12:01 AM, Oscar Benjamin
> wrote:
>> In the recursive stack overflow case what you'll usually have is
>>
>> 1) A few frames leading up to the start of recursion
>> 2) A long repeti
On 21 April 2016 at 13:15, Steven D'Aprano wrote:
> On Thu, 21 Apr 2016 06:53 pm, Oscar Benjamin wrote:
>
>> On 21 April 2016 at 04:07, Steven D'Aprano wrote:
>>> I want to group repeated items in a sequence. For example, I can group
>>> repeated se
that those are for a sequence made as x[n+1] = f(x[n]) for some
function f. In your case that's just the function that gets the next
frame up/down in the call stack.
--
Oscar
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
On 20 April 2016 at 12:30, wrote:
> On Wednesday, April 20, 2016 at 2:09:10 PM UTC+3, liran@gmail.com wrote:
>> On Tuesday, April 19, 2016 at 9:21:42 PM UTC+3, eryk sun wrote:
>> > On Tue, Apr 19, 2016 at 12:05 PM, Oscar Benjamin
>> > wrote:
>>
ht be disabled, missing, or
> out of date."
>
> Yeah, thanks guys. Really helpful.
Having a flash-enabled browser is a lower barrier to entry for most
people in the world than having a code editor and (being able to use)
say a terminal to run your code.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
if n % 2:
>> n = (n + 1) * 3 / 2
>> else:
>> n = n * 2 + 3
>>
>> with stripes of colour, with the entire first column of spaces all
>> tied to the "def", and then the next block of four tied to the &q
all scipy.
I'm not on Windows to check myself though I'm afraid.
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
t; result shows that scipy-0.17.0-cp27-none-win_amd64.whl is not a supported
> wheel on this platform.
That should be the right wheel if you have 64-bit Python 2.7 on
Windows. Note that it's possible you have 32 bit Python even if the
computer and Windows is 64-bit.
It's also p
re install anaconda
> ?how can anaconda packages to run with old idle ?because i have to many
> packages in old python.
Just install numpy and scipy from here (as already mentioned earlier
in the thread):
http://www.lfd.uci.edu/~gohlke/pythonlibs/
--
Oscar
--
https://mail.python.org/mailman/listinfo/python-list
owever...
Numpy now has binary (pre-complied) wheels for Windows, OSX and Linux
on PyPI so you should be able to just install it with:
$ pip install numpy
This is much easier than what you're currently attempting. I don't
know if the same works for scipy now or not.
Here on Linux I
On 15 April 2016 at 11:10, Ben Bacarisse wrote:
> Oscar Benjamin writes:
>
>> On 15 April 2016 at 10:24, Robin Becker wrote:
>
>>> yes indeed summation is hard :(
>>
>> Not with Fraction it isn't:
>>
>> from fractions import Fraction
>
1 - 100 of 654 matches
Mail list logo