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

Propose New Type Interval #542

Closed
latot opened this issue Sep 6, 2016 · 13 comments
Closed

Propose New Type Interval #542

latot opened this issue Sep 6, 2016 · 13 comments

Comments

@latot
Copy link
Contributor

latot commented Sep 6, 2016

Hi, well thinking again, actually when we add functions to sets we are doing bigger and bigger the files while the type of data are completely differents, so i propose make a new type, actually we have @symfun, @sym and some @logical and @double functions, so do a @interval to call the functions.

I think with this will be easier to work.

This start when i was checking the changes of this pr #328 and your comment:

Lots of questions now that we have sets! Here is special treatment for isempty. What about
numel, and size and length and... and ...

Edited: set its already a function, so now is interval.

Thx. Cya.

@latot latot changed the title Propose New Type Set Propose New Type Interval Sep 6, 2016
@latot
Copy link
Contributor Author

latot commented Sep 6, 2016

A little question D:
i have problems with classes, like my firsts steps in this, i make a new folder, @interval then i put the interval file there, with this little changes:

function I = interval(varargin)
  if (nargin < 2 || nargin > 4)
    print_usage();
  end
  varargin = sym(varargin);
  I = python_cmd ('return Interval(*_ins),', varargin{:});
  I = class(I, 'interval');
end

and now trying to execute this:

>> c=interval(1, 9)
c = <class interval>
>> c=interval(1, sym(9))
c = (sym) [1, 9]

This is weird!
The interval function use sym(varargin) so shouldn't be a difference but it only works when it have at least a sym (interval of @sym its generated for octave if i'm right, so both are equals).
What do you think?

Thx.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 6, 2016

Your 2nd example calls @sym/interval, that's why it's different.

@latot
Copy link
Contributor Author

latot commented Sep 6, 2016

yes, but @sym/interval its the same as @interval/interval, so i know tis call the other but i cat'n understand why the result is different.

Thx.

@latot
Copy link
Contributor Author

latot commented Sep 6, 2016

Okis, checking again, the files are differents, that why with one works and with the other not.

Thx the help!

@latot
Copy link
Contributor Author

latot commented Sep 6, 2016

what doc do you can recommend me to learn to write types/classes?
i search about classes but i it feel i have the half of info to start writing it, i read symfun.m and sym.m, and still are things i don't understand.
D:

This is my newbie file: https://github.com/latot/octsympy/blob/interval/inst/%40interval/interval.m

still something fails, ..., basically this:
this relatively works

>> interval(1, 2)
ans = (interval) [1, 2]  (1×4 matrix)

this don't:

>> interval(1, 2, sym(3))
error: Python exception: NotImplementedError: left_open and right_open can have only true/false values, got 3 and False
    occurred at line 1 of the Python code block
error: called from
    python_cmd at line 174 column 5
    interval at line 62 column 5

i use logical so the sym(3) should be converted to True but nothing, and the last:

>> interval(1, sym(2))
ans = (sym) [1, 2]

The class changes, as a note, only exist the file @interval/interval.m, the file @sym/interval.m was removed.

Thx. Cya.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 7, 2016

I used the Octave docs to learn classes, maybe some Matlab docs are useful too.

I don't really understand the superiorto bit (maybe I did but I forgot ;-)

I'm not at all sure that sym(3) will get converted to a python bool...

I'm not sure what we get by making an interval class.

In the future, maybe we want all sym objects to actually be pyobject (see Pytave) and then class(x) would return their Sympy python class.

a = interval(1, 2)
isa(a, 'sym')   % true
isa(a, 'pyobject')   % true
class(a)     % calls @pyobject/class, answers with `py.sympy.Interval` or similar.

@latot
Copy link
Contributor Author

latot commented Sep 7, 2016

that looks great, the reason of the issue, is (thinking only in sym and intervals), we have basically there two types of data, and if we split it to @sym and @interval we will don't need start checking every type in the code.
Maybe are other way to do this.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

Perhaps we could try overloading @sym/class right now? No need to wait for full PyTave support.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

we will don't need start checking every type in the code.

Do we do a lot of that right now for intervals?

My goal is to make Symbolic "thinner" around SymPy. I feel adding more classes for particular types of SymPy objects does the opposite. So there will have to be some big benefit; and I don't see what that is.

@latot
Copy link
Contributor Author

latot commented Sep 14, 2016

sorry but i have little problems interpreting the overloading "line", what do you mean? (only as a note, i know what is overload a function/operator) (maybe your intention was say start implementing the class def).

execute one action depending if is set or matrix: https://github.com/cbm755/octsympy/blob/master/inst/%40sym/intersect.m
don't is very expensive but i think if its possible avoid that, try split it.

only as idea, its possible make a classdef of classdef?, like a master classdef to handle values types and similars and the other to set the opertaions. (or something similar).

@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

sorry but i have little problems interpreting the

Let's take that discussion elsewhere: #549.

like a master classdef to handle values types and similars and the other to set the opertaions

Yes it is possible to subclass.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

execute one action depending if is set or matrix:

So the natural place to split is for SymPy class Set (not Interval). Now I understand your comment earlier "set its already a function, so now is interval."

This thread is really just PR #328. I'll close this: it'll be cross-referenced from #328.

@latot
Copy link
Contributor Author

latot commented Sep 14, 2016

okidokis

@latot latot closed this as completed Sep 14, 2016
@cbm755 cbm755 mentioned this issue Sep 14, 2016
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

No branches or pull requests

2 participants