dlsun / symbulate

A symbolic algebra for specifying simulations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update on R-version of Symbulate

hayate0304 opened this issue · comments

Hi professors, I have questions to ask while coding in R. You can check out my "Rsymbulate" repo to see my work. First, I know my coding style in R may not be the one you like. There are a lot of way to create classes and methods in R. I'm using S3 system. So the methods and function look like draw(x) not x.draw()
image

-There is no self.box or this.box in R so I just use box = box inside the class.
Problems: I checked np.random.choice and size = None returns 1 value, size = 1 returns array(). But in R, I put size = 1 as default since we don't have to check the same thing as Python.

  • Why do some class not appear when I click "tab" for completion in Python such as Event, ArtbitrarySpace? For example, I write Box and click tab, then BoxModel appear.
  • For InfiniteSequence: I'm not sure how Python can provide the 'n' argument for this function. Maybe with the getitem() but I'm not sure.
    image
  • DeckOfCards: R doesn't have tuple, so I use vector of strings to store this class like this. I thought of using list to store this but then it is complicated to implement the dict feature of BoxModel for this.
    image
  • I'm working on the mul and pow of ProbabilitySpace.

Kien, could you please use your repo to file issues related to SymbulateR? I am now following your repo, and Dr. Ross will do the same.

I actually think your draw(x) method is exactly what I was envisioning. If you want to get something like Python's method chaining, you can use the magrittr library and write things like x %>% draw(). Essentially the pipe operator %>% takes the place of . You might be familiar with this style of programming if you have used the tidyverse (i.e., packages like dplyr).

You're right that R doesn't distinguish between a vector of length 1 and a single number. So your approach is fine.

The only objects that have tab completion are those that are exported by Python. You can find a list of them in __init__.py. You'll see that Event is not there.