[issue35576] function splitextTest does not return expected value

2018-12-23 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

As Karthikeyan said, (1) is a duplicate of issue35538. This is expected 
behavior.

(2) is a duplicate of issue35183 which is still discussed.

I do not know what relations do tests for third-party Java library have with 
the Python stdlib. Note that that tests imply that the extension of ".." is 
".", that is considered obviously wrong.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> os.path.splitext documentation needs typical example

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35576] function splitextTest does not return expected value

2018-12-23 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Please provide a proper reproducible bug report. Don't make us GUESS what 
function you are referring to.

I don't know any "splitextTest" function that you describe in the bug report 
title. Do you mean os.path.splitext? Then you should say so. If not, then what 
function are you referring to?

What results do you expect, why do you expect them, and what results do you get?

Why should we care what test results some Java library returns? Maybe they've 
got it wrong, or maybe their function just works differently from ours. Unless 
this function is documented as being exactly compatible with the Java code you 
link to, I don't think it is very important what guava does.

Perhaps you should raise a bug report at Guava and tell them that according to 
the Python language, their function is wrong.

The os.path.splitext function is documented as returning the file extension as 
either the empty string "" or beginning with a single period, and leading dots 
are not part of the extension. So the examples you show are correct, if you are 
talking about os.path.splitext. If you are talking about something else, please 
explain what.

https://docs.python.org/3/library/os.path.html#os.path.splitext

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35576] function splitextTest does not return expected value

2018-12-23 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report

> 1. For input ".blah." output is "." 

Please see issue35538

> 2. For input "..." output is "..." 

Please find the tests at 
https://github.com/python/cpython/blob/master/Lib/test/test_posixpath.py#L111

For completeness this is the behavior in master

./python.exe
Python 3.8.0a0 (heads/master:284b787612, Dec 23 2018, 23:11:33)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.splitext("...")
('...', '')
>>> os.path.splitext(".blah.")
('.blah', '.')

You can find links to other discussions in mailing list and other issues raised 
about this behavior at https://bugs.python.org/issue34931#msg328820 . Though 
this might be different from the behavior of guava I think this is something 
discussed extensively in the mailing list and finally to go with this behavior. 
So I don't think this is a bug but a behavior difference between guava and 
CPython implementation.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35576] function splitextTest does not return expected value

2018-12-23 Thread Divya Rani


New submission from Divya Rani :

1. For input ".blah." output is "." 
2. For input "..." output is "..." 

results produced by the function are wrong according to the test suite provided 
by guava.
1. 
https://github.com/google/guava/blob/1e072a7922a0b3f7b45b9f53405a233834175177/guava-tests/test/com/google/common/io/FilesTest.java#L644
2.
https://github.com/google/guava/blob/1e072a7922a0b3f7b45b9f53405a233834175177/guava-tests/test/com/google/common/io/FilesTest.java#L628

--
components: Library (Lib)
messages: 332407
nosy: Divya Rani
priority: normal
severity: normal
status: open
title: function splitextTest does not return expected value
type: behavior
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue35576>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Expected Value

2005-09-12 Thread Steven D'Aprano
On Sat, 10 Sep 2005 17:50:06 -0700, George wrote:

 How would I get the expected value out of this information. I have
 tried many times to understand this but am unable to.

Do you have a specific Python problem here, or do you need help with the
maths? If Python, please tell us what your problem is. If your problem is
with the maths, then a statistics and/or probability forum is probably
going to be more useful to you.

If you are having a problem with the code, not the maths, I frequently
find that it helps to reduce the problem. Instead of calculating the
expectation of a discrete pdf with one hundred thousand values, start with
a toy problem: write code that calculates the expectation of a pdf with
only five values. That is small enough that you can experiment using the
interactive Python interpreter, and if need be calculate the correct
answer with paper and pencil.

You might also find it useful to read this:

http://www.catb.org/~esr/faqs/smart-questions.html


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Expected Value

2005-09-10 Thread George
How would I get the expected value out of this information. I have
tried many times to understand this but am unable to.

  The function expectP(z) computes E(X) for the random variable
representing a sample over the probability generated by pf for the
set of discrete items [1,10]. The constant c is needed so that the
probability sum to 1.0, as required by the definition of probability.
The function pf(r,c,x) returns the probability that item x will be
equal to a randomly chosen variable, denoted by P(x) or P(X=x) in
mathematical texts, where c is the constant mentioned above and r is
needed because we are considering a power law distribution.

The function expectP(z) computes E(X) with r=z, using pf(r,c,x) where x
ranges over the set of discrete items in [1,10]

The program:

def norm(r):
  calculate normalization factor for a given exponent
  # the function for this distribution is  P(x) = c*(x**-r)
  # and the job of this norm function is to calculate c based
  # on the range [1,10**5]
  sum = 0.0
  for i in range(1,1+10**5):
 # final sum would be more accurate by summing from small values
 # to large ones, but this is just a homework, so sum 1,2,..10**5
 sum += float(i)**-r
  return 1.0/sum

def pf(r,c,x):
  return a power-law probability for a given value
  # the function for this distribution is  P(x) = c*(x**-r)
  # where the constant c is such that it normalizes the distribution
  return c*(float(x)**-r)

#- between these lines, define expectP() function
-


#- end of expectP() definition


def showExpectP(limit):
  display ExpectP(limit) by rounding down to nearest integer
  k = expectP(limit)
  return int(k)

if __name__ == '__main__':
  import doctest, sys 
  doctest.testmod(sys.modules[__name__])

-- 
http://mail.python.org/mailman/listinfo/python-list


Expected Value

2005-09-09 Thread George
I have never done any programming with python in my life so I will most
definetly need help understanding how I can accomplish this part of my
program.

The function expectP(z) computes E(X) for the random variable
representing a sample over the probability generated by pf for the
set of discrete items [1,10]. The constant c is needed so that the
probability sum to 1.0, as required by the definition of probability.
The function pf(r,c,x) returns the probability that item x will be
equal to a randomly chosen variable, denoted by P(x) or P(X=x) in
mathematical texts, where c is the constant mentioned above and r is
needed because we are considering a power law distribution. I need help
in writing the expectP function and do I compile and execute this code
on a linux box.


Module to compute expected value.

 showExpectP(0.5)
33410
 showExpectP(0.85)
15578
 showExpectP(0.9)
12953
 showExpectP(0.99)
8693
 showExpectP(0.999)
8312



def norm(r):
  calculate normalization factor for a given exponent
  # the function for this distribution is  P(x) = c*(x**-r)
  # and the job of this norm function is to calculate c based
  # on the range [1,10**5]
  sum = 0.0
  for i in range(1,1+10**5):
 # final sum would be more accurate by summing from small values
 # to large ones, but this is just a homework, so sum 1,2,..10**5
 sum += float(i)**-r
  return 1.0/sum

def pf(r,c,x):
  return a power-law probability for a given value
  # the function for this distribution is  P(x) = c*(x**-r)
  # where the constant c is such that it normalizes the distribution
  return c*(float(x)**-r)

#- between these lines, define expectP() function
-


#- end of expectP() definition


def showExpectP(limit):
  display ExpectP(limit) by rounding down to nearest integer
  k = expectP(limit)
  return int(k)

if __name__ == '__main__':
  import doctest, sys
  doctest.testmod(sys.modules[__name__]) 

thankyou sooo much.

-- 
http://mail.python.org/mailman/listinfo/python-list