Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you like sets? I like sets! Full sets Module! #585

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

latot
Copy link
Contributor

@latot latot commented Sep 30, 2016

Hi @cbm755 this time i bring the full sets module (i skip some redundant functions), because we add intervals function with some things but is very incomplete, when i need works with it, it feels... without tools to handle it.

So i think with this we will can works properly with sets.

Obvs, the function names don't are absolutes, if you like we can discuss names for it, in the most of functions i use the sympy name, in others i change it to conserve the octave/matlab prefix.

And this time i take time to check every format!

This pr is required for improve solveset correctly.

Here are two special functions it not belongs directly from sympy sets:

  • domain: return a domain from sympy 'Complexes', 'Reals', etc (the only function added to user env)
  • point: express a point or a set of it (don't is from sets but its a feature of sympy).

Obvs you can like split this heavy pr, but i think before it select ready things and that type of things.
I think here no are unnecessary functions, things with which we can work.

The original issue: #575
have the original names of sympy functions and some data of this work.

i don't know if all this functions are available in the travis sympy, i'll check it.

As a note, sadly you can't call sets from sym, why?, in a example, to theoretically you need call like this:

sym('UniversalSet()')

but sadly for the S function don't like "" in the expression with sets:

>>> S("UniversalSet()")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/sympy/core/sympify.py", line 322, in sympify
    expr = parse_expr(a, local_dict=locals, transformations=transformations, evaluate=evaluate)
  File "/usr/lib64/python2.7/site-packages/sympy/parsing/sympy_parser.py", line 894, in parse_expr
    return eval_expr(code, local_dict, global_dict)
  File "/usr/lib64/python2.7/site-packages/sympy/parsing/sympy_parser.py", line 807, in eval_expr
    code, global_dict, local_dict)  # take local objects in preference
  File "<string>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/sympy/core/symbol.py", line 157, in __call__
    return Function(self.name)(*args)
  File "/usr/lib64/python2.7/site-packages/sympy/core/function.py", line 762, in __new__
    obj = super(AppliedUndef, cls).__new__(cls, *args, **options)
  File "/usr/lib64/python2.7/site-packages/sympy/core/cache.py", line 93, in wrapper
    retval = cfunc(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/sympy/core/compatibility.py", line 807, in wrapper
    result = user_function(*args, **kwds)
  File "/usr/lib64/python2.7/site-packages/sympy/core/function.py", line 431, in __new__
    pr = max(cls._should_evalf(a) for a in result.args)
ValueError: max() arg is an empty sequence
>>> S(UniversalSet())
UniversalSet()

but if you remove the quotes you will can't make symbols. other point its it will be to confuse to the user, call a lot of possibles things from sym, seems a bad idea, i think its more clear a new function to handle it.

I decide use the S.tuple instead of Point as point for two reasons, first the point function have this issue: sympy/sympy#11683, and in the sets doc the tuple is used to represent point in sets, so it should be safe for now (i write in the doc what happen when you plus two points).

Thx. Cya.

@latot latot force-pushed the more_sets branch 3 times, most recently from ad926a8 to 7e4f112 Compare September 30, 2016 02:01
@latot latot changed the title [WIP] You like sets? I like sets! Full sets Module! You like sets? I like sets! Full sets Module! Sep 30, 2016
@latot latot changed the title You like sets? I like sets! Full sets Module! Do you like sets? I like sets! Full sets Module! Sep 30, 2016
@cbm755
Copy link
Collaborator

cbm755 commented Sep 30, 2016

Wow! This is pretty cool.

Pytave might make at least some of this possible without us writing code (by exposing things like .openleft automatically).

@latot
Copy link
Contributor Author

latot commented Jan 26, 2017

Hi, all updated, but i was trying to check this in travis but isn't working D:

@latot
Copy link
Contributor Author

latot commented Jan 26, 2017

(travis don't is checking the pr)

@cbm755
Copy link
Collaborator

cbm755 commented Jan 26, 2017

looks like it has run now (?)

@latot latot force-pushed the more_sets branch 3 times, most recently from 071448d to 9817c11 Compare January 26, 2017 17:20
@latot
Copy link
Contributor Author

latot commented Jan 26, 2017

Yay!, all updated and working!

@latot
Copy link
Contributor Author

latot commented Apr 6, 2017

Hi, is possible start merging this?

Thx.

Copy link
Collaborator

@cbm755 cbm755 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I started reading through this. A detailed review for correctness will take quite some time!

%% @documentencoding UTF-8
%% @defmethod @@sym ainterval (@var{x})
%% Return the union of intervals of x when, @var{x} is in rectangular form
%% or the union of intervals of r when self is in polar form.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First line need to fit on one line (its used for lookfor).

%!test
%! a = interval (sym (0), 1);
%! b = interval (sym (0), 1, true, false);
%! assert( isequal( boundary (a), boundary (b)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I've been very sloppy in the past, but for new code, let's try to use core Octave style (except for sym()).



%% This function is tested in @sym/ainterval, @sym/binterval
%% @sym/ispolar, @sym/psets, @sym/sets and @sym/normalizethetaset
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an %! assert true or something here too so automated checks don't flag this as untested.

%% @documentencoding UTF-8
%% @defmethod @@sym complexregion (@var{x}, @var{y})
%% Represents the Set of all Complex Numbers.
%% It can represent a region of Complex Plane in
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line between the "lookfor" and the rest of the body. But this looks wrong? Should it represent all complex numbers if no arguments are passed or what does the lookfor summary line mean?


%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym complexregion (@var{x}, @var{y})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y should be called something else like @var{polar}. And please list both ways of calling it:

@defmethod  @@sym complexregion (@var{x})
@defmethodx @@sym complexregion (@var{x}, @var{polar})

%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym infimum (@var{x})
%% The infimum of @var{x}.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infimum of the set @var{x}.

%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym iscomplement (@var{x})
%% Retrurn True if @var{x} is complement.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling mistake and this lookfor line doesn't tell me any more than the name iscomplement already does. At least put the word "set" in there somewhere.

%% @result{} ans = (sym) True
%% @end group
%% @end example
%%
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some/most of these methods need @seealso

%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym isdisjoint (@var{x}, @var{y})
%% Returns True if @var{x} and @var{y} are disjoint.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure the word "set" appears in most of these "lookfor" summary lines,

%% -*- texinfo -*-
%% @documentencoding UTF-8
%% @defmethod @@sym isleftunbounded (@var{x})
%% Return True if the left endpoint is negative infinity.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"return True" is probably not needed (I forgot exactly, you could check the core Octave guidelines on this sort of thing). Use the word "Interval" somewhere.

@cbm755
Copy link
Collaborator

cbm755 commented Apr 7, 2017

My biggest concern about all this is whether we should just wait until (and if?) sym objects support x.is_leftopen calling directly without us writing any code.

That would keeps things as close to sympy as possible, keeping things slim.

OTOH, this is here now and looks like it will be good. I am undecided what to do. Which is probably why I've let this sit so long...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants