Skip to content

Commit

Permalink
Better distribution: drop case-sensitive name and ensure that RapidJS…
Browse files Browse the repository at this point in the history
…ON is in the source distribution. (#121)

* Better distribution: drop case-sensitive name and ensure that RapidJSON is in the source distribution.

* Sneak in 'softmax' as a pseudo-reducer.
  • Loading branch information
jpivarski authored Feb 19, 2020
1 parent 6d19cf6 commit b25d31b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 98 deletions.
2 changes: 1 addition & 1 deletion VERSION_INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.120
0.1.121
6 changes: 6 additions & 0 deletions awkward1/operations/reducers.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,10 @@ def linearfit(x, y, weight=None, axis=None, keepdims=False):

return awkward1._util.wrap(out, awkward1._util.behaviorof(x, y))

def softmax(x, axis=None, keepdims=False):
with numpy.errstate(invalid="ignore"):
expx = numpy.exp(x)
denom = sum(expx, axis=axis, keepdims=keepdims)
return numpy.true_divide(expx, denom)

__all__ = [x for x in list(globals()) if not x.startswith("_") and x not in ("collections", "numpy", "awkward1")]
94 changes: 0 additions & 94 deletions awkward1/signatures/Identities_8cpp.xml

This file was deleted.

8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ def build_extension(self, ext):
setup(name = "awkward1",
packages = setuptools.find_packages(exclude=["tests"]),
scripts = [],
data_files = ([(os.path.join("awkward1", "include", "awkward"), glob.glob("include/awkward/*.h")),
data_files = ([("", glob.glob("rapidjson/include/rapidjson/*.h")),
("", glob.glob("rapidjson/include/rapidjson/*/*.h")),
(os.path.join("awkward1", "include", "awkward"), glob.glob("include/awkward/*.h")),
(os.path.join("awkward1", "include", "awkward", "cpu-kernels"), glob.glob("include/awkward/cpu-kernels/*.h")),
(os.path.join("awkward1", "include", "awkward", "python"), glob.glob("include/awkward/python/*.h")),
(os.path.join("awkward1", "include", "awkward", "array"), glob.glob("include/awkward/array/*.h")),
Expand Down Expand Up @@ -114,8 +116,8 @@ def build_extension(self, ext):
classifiers = [
# "Development Status :: 1 - Planning",
# "Development Status :: 2 - Pre-Alpha",
"Development Status :: 3 - Alpha",
# "Development Status :: 4 - Beta",
# "Development Status :: 3 - Alpha",
"Development Status :: 4 - Beta",
# "Development Status :: 5 - Production/Stable",
# "Development Status :: 6 - Mature",
# "Development Status :: 7 - Inactive",
Expand Down
4 changes: 4 additions & 0 deletions tests/test_PR115_generic_reducer_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,3 +1180,7 @@ def test_nonreducers():
fit = awkward1.linearfit(x, y, axis=-1)
assert awkward1.tolist(fit[0]) == pytest.approx({"intercept": 0.11999999999999772, "slope": 0.9800000000000005, "intercept_error": 1.0488088481701516, "slope_error": 0.31622776601683794})
assert awkward1.tolist(fit[1]) == pytest.approx({"intercept": 0.04000000000000228, "slope": 0.9999999999999994, "intercept_error": 1.0488088481701516, "slope_error": 0.31622776601683794})

def test_softmax():
array = awkward1.Array([[numpy.log(2), numpy.log(2), numpy.log(4)], [], [numpy.log(5), numpy.log(5)]])
assert awkward1.tolist(awkward1.softmax(array, axis=-1)) == [pytest.approx([0.25, 0.25, 0.5]), [], pytest.approx([0.5, 0.5])]

0 comments on commit b25d31b

Please sign in to comment.