Code Monkey home page Code Monkey logo

tau.jl's Introduction

Tau.jl



CI codecov

This Julia package defines the Tau constant and related functions.

tau ≈ 2*pi

Usage

After installing this package with Pkg.add("Tau"), it can be used as follows:

julia> using Tau

julia> tau === τ  2*pi
true

julia> typeof(tau)
IrrationalConstants.Twoπ

Note: to input the τ character, type \tau then press Tab.

The tau variants of sinpi, cospi, sincospi, cispi, and mod2pi are also defined:

julia> sintau(1//4)
1.0

julia> costau(1//2)
-1.0

julia> sincostau(1//2)
(0.0, -1.0)

julia> cistau(1//2)
-1.0 + 0.0im

julia> modtau(9*pi/4)
0.7853981633974481

Alternatively, one can use the Unicode aliases sinτ, cosτ, sincosτ, cisτ, and modτ.

The tau != 2pi inequality

When this package was first created, the equality tau == 2pi did hold true, in accordance to the mathematical definition of the constant. However, that is not valid anymore -- the two values are only approximately equal: tau ≈ 2*pi.

For a detailed explanation of the reasons for this, see this document.

tau.jl's People

Contributors

aerlinger avatar dependabot[bot] avatar devmotion avatar giordano avatar juliatagbot avatar kmsquire avatar ranocha avatar staticfloat avatar stevengj avatar timholy avatar waldyrious avatar wookay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tau.jl's Issues

trig functions are not type-stable for complex inputs

Came across this while working to improve test coverage:

julia> show(Base.return_types(sintau, Tuple{Complex}))
Any[Any]

julia> show(Base.return_types(costau, Tuple{Complex}))
Any[Any]

julia> show(Base.return_types(modtau, Tuple{Complex}))
Any[Any]

Create a script to help conversion of 2pi

From issue #22:

[Automatically converting 2pi to tau could actually be] counterproductive to the "tauist cause": if one chooses to use the Tau package, it would make sense for them to take the extra step to change their code to explicitly reflect their choice of circle constant, rather than leaving the 2pi's around.

With that in mind, though, I think it would be nice to provide some sort of warning for when a downstream package uses 2pi in its code -- which could be done by overriding *(2, pi), without changing its resulting type. I'm not sure if it's possible to distinguish code from a module from code from modules it imports (we wouldn't want to warn a user of instances of 2pi in packages they didn't author);

If that distinction is not possible (or the warning approach found too intrusive), then an alternative could be a helper script or method in this package that would process a given module or file and output a list of locations where 2pi could be replaced by tau. This is easy enough to do by hand, but depending on the search method, one could easily miss valid instances -- 2pi, 2*pi, 2 * pi, 2.0 * pi, pi*2, etc. -- so an automated process might be useful.

To which @giordano replied:

I don't have a strong opinion on this. In any case, I wouldn't make it part of the package itself, at least an extra script to be placed outside src directory.

So this issue it to track the implementation of such a script.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Add examples

It would be nice to have an examples directory with common functions written using tau.

[PkgEval] Tau may have a testing issue on Julia 0.2 (2014-07-08)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.2

  • On 2014-07-07 the testing status was Tests pass.
  • On 2014-07-08 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

INFO: Cloning cache of Tau from git://github.com/Aerlinger/Tau.jl.git
INFO: Installing Tau v0.0.3
INFO: REQUIRE updated.
ERROR: test error during :((Base.return_types(f,(T,))==[T]))
return_types not defined
 in anonymous at test.jl:53
 in do_test at test.jl:37
 in anonymous at no file:25
 in include at boot.jl:238
at /home/idunning/pkgtest/.julia/v0.2/Tau/test/runtests.jl:27
INFO: REQUIRE updated.

Add sintau, costau, modtau

I don't know of any precedent for these, but since base has sinpi, cospi, and mod2pi, these might be useful.

Document the functions

sintau etc have no documentation. It would be helpful to know what they are supposed to do.

(re)implement equality with 2pi

I have been collecting some loose notes about this but hadn't posted a plan publicly as I didn't have a clear plan of how to go about tackling this. But given @giordano's recent involvement with the package (and with the overall handling of Irrational in julia), I feel the time is right to move ahead and make a decision.

As the README indicates, this package was originally meant to provide the tau == 2pi equality (which should by definition be true). This is not possible at the moment due to the * operator implicit in 2pi converting the result of that expression to a float, which Irrationals are explicitly defined as not equal to. However, since this package was created explicitly to give special meaning to the value of 2pi, it would make sense for it to ensure that 2pi handles as the same Irrational as well. This may not be in scope for base Julia (@StefanKarpinski often expresses his concern that at some point these changes will drift towards implementing a full-fledged math parsing engine or CAS), but it sounds reasonably in scope for a package like this.

One way of doing so could be using Julia's core feature of multiple dispatch to override the * operator for the case where the operands are pi and 2, as I suggested a while ago in this thread. There is even some precedent for such special cases in base julia: exp.jl, for instance, has a special case for exp(1), implemented using a simple if test.

Instead of an if test, I have been looking at Value types to implement this. PatternDispatch could also provide inspiration for possible alternative approaches. These options may be overkill for the single 2pi case, but may be adequate if we want something more generic.

Indeed, a more general solution could be more appropriate: integer multiples of pi (or tau) should, for semantic reasons, be handled with the same manner as pi/tau itself. @simonbyrne suggested such a PiMultiple type in the PR that introduced sinpi/cospi, and I think the Tau package could make that experiment with a TauMultiple type.

Ok, now that I made the case, I'm curious about any arguments against. In particular, I'm wondering why @giordano considers that "it's exactly the fact that tau isn't the same as 2 * pi that makes this package particularly useful."

Missing `cistau`

What is says on the box.

julia> using Tau

julia> costau
cosτ (generic function with 2 methods)

julia> sintau
sinτ (generic function with 2 methods)

julia> cistau
ERROR: UndefVarError: cistau not defined

[PkgEval] Tau may have a testing issue on Julia 0.4 (2015-01-30)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2015-01-29 the testing status was Tests pass.
  • On 2015-01-30 the testing status changed to Tests fail, but package loads.

Tests pass. means that PackageEvaluator found the tests for your package, executed them, and they all passed.

Tests fail, but package loads. means that PackageEvaluator found the tests for your package, executed them, and they didn't pass. However, trying to load your package with using worked.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("Tau")' log
INFO: Installing Tau v0.0.3
INFO: Package database updated
INFO: METADATA is out-of-date a you may not have the latest version of Tau
INFO: Use `Pkg.update()` to get the latest versions of your packages

>>> 'using Tau' log
Julia Version 0.4.0-dev+2997
Commit e41a507 (2015-01-30 05:35 UTC)
Platform Info:
  System: Linux (x86_64-unknown-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Sandybridge)
  LAPACK: libopenblas
  LIBM: libopenlibm
  LLVM: libLLVM-3.3

>>> test log
ERROR: LoadError: test failed: (a = 6.2831853071795... == 6.283185307179586)
 in expression: tau == 2pi
 in error at error.jl:19
 in default_handler at test.jl:27
 in do_test at test.jl:50
 in include at ./boot.jl:249
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:319
 in _start at ./client.jl:403
while loading /home/idunning/pkgtest/.julia/v0.4/Tau/test/runtests.jl, in expression starting on line 4


INFO: Testing Tau
=================================[ ERROR: Tau ]=================================

failed process: Process(`/home/idunning/julia04/usr/bin/julia --check-bounds=yes --code-coverage=none --color=no /home/idunning/pkgtest/.julia/v0.4/Tau/test/runtests.jl`, ProcessExited(1)) [1]

================================================================================
INFO: No packages to install, update or remove
ERROR: Tau had test errors
 in error at error.jl:19
 in test at pkg/entry.jl:717
 in anonymous at pkg/dir.jl:28
 in cd at ./file.jl:20
 in cd at pkg/dir.jl:28
 in test at pkg.jl:68
 in process_options at ./client.jl:241
 in _start at ./client.jl:403

>>> end of log

Tests failing in julia nightly

See for example https://travis-ci.org/JuliaMath/Tau.jl/jobs/245339601 (from #25):

INFO: Testing Tau
Error During Test
  Test threw an exception of type ErrorException
  Expression: #= /home/travis/.julia/v0.7/Tau/test/runtests.jl:39 =# @inferred(sintau(T(x))) == sign(x) * zero(T)
  return type BigFloat does not match inferred return type Any
  Stacktrace:
   [1] macro expansion at /home/travis/.julia/v0.7/Tau/test/runtests.jl:39 [inlined]
   [2] anonymous at ./<missing>:?
   [3] include_from_node1(::Module, ::String) at ./loading.jl:549
   [4] include(::Module, ::String) at ./sysimg.jl:14
   [5] process_options(::Base.JLOptions) at ./client.jl:310
   [6] _start() at ./client.jl:378
ERROR: LoadError: There was an error during testing
while loading /home/travis/.julia/v0.7/Tau/test/runtests.jl, in expression starting on line 38

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.