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

Documentation added for Rows class. #552

Merged
merged 10 commits into from
Jan 27, 2023
Merged

Conversation

Shershon25
Copy link
Contributor

Have added documentation for the Rows class. Suggestions and corrections are most welcomed.

Copy link
Member

@adnanhemani adnanhemani left a comment

Choose a reason for hiding this comment

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

Thanks for this! Let's try to make the revisions here and then we should be in a good state to merge!

args:
table- accepts a table object of class Table()

>>> t = td.Table().with_columns({
Copy link
Member

Choose a reason for hiding this comment

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

I'm unsure why we're not instantiating the Table class directly here. What's the td object here? I don't see it anywhere in the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was a mistake on my side. I didn't add the proper initialization for Table() class. I have updated it now.

'points': [ 1, 2, 2, 10],
})

>>> td.Table().Rows(t).__getitem__(0)
Copy link
Member

Choose a reason for hiding this comment

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

You can reuse objects from previous docs. Let's save one Rows object in the class initializer and reuse that for the remaining methods in this class.

@@ -5735,9 +5771,35 @@ def __getitem__(self, i):
return self._row(c[i] for c in self._table._columns.values())

def __len__(self):
"""
Returns the no.of rows in the table.
Copy link
Member

Choose a reason for hiding this comment

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

please no short-forms in the docs, as much as possible

'count': [ 9, 3, 3, 1],
'points': [ 1, 2, 2, 10],
})
>>> td.Table().Rows(t).__len__()
Copy link
Member

Choose a reason for hiding this comment

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

We can jus use the Python len function to demonstrate this function's logic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted.

@@ -5719,12 +5719,48 @@ def asdict(self):
return collections.OrderedDict(zip(self._table.labels, self))

class Rows(collections.abc.Sequence):
"""An iterable view over the rows in a table."""
"""
An iterable row-styled view of the table object that is passed as an argument.
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the original statement here - the intended/standard usage of this class doesn't have users manually creating this class.

@Shershon25
Copy link
Contributor Author

@adnanhemani I have updated the docs according to the changes suggested.

Copy link
Member

@adnanhemani adnanhemani left a comment

Choose a reason for hiding this comment

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

Hi, getting closer! In addition to the comments, the doc build is now failing as well :/ (check the GH Action attached to the repo). Please fix these, thank you!

args:
table- accepts a table object of class Table()

>>> from datascience import Table
Copy link
Member

Choose a reason for hiding this comment

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

Table should already be imported from other doctests above, no need to re-import it.

})

>>> r = Table.Rows(t)
print(r)
Copy link
Member

Choose a reason for hiding this comment

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

In doctests, we don't need to print any values. You can simply call >>> r and it will output the right representation of the object.

An iterable view over the rows in a table.

args:
table- accepts a table object of class Table()
Copy link
Member

Choose a reason for hiding this comment

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

Can we please follow the standard formatting for args/return values? Here's a good example: https://github.com/data-8/datascience/blob/master/datascience/tables.py#L380-L402

E.g.:

...

Args:
    table (str): ...

Copy link
Member

Choose a reason for hiding this comment

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

Also "Table" here can be written as Table or Table - but no parenthesis please.

"""
Access the i-th row of the given table.

args:
Copy link
Member

Choose a reason for hiding this comment

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

Format comment, same as above

returns:
Returns a Row object containing the i-th row of the given table

>>> r.__getitem__(0)
Copy link
Member

Choose a reason for hiding this comment

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

To show __getitem__, you can just use the [] notation. Example: r[0] should give you the same result. Change required because it is more Pythonic and easier to read/remember for beginning learners.

Returns the printable representation of the given table as string.
Uses the standard repr() function.

>>> r.__repr__()
Copy link
Member

Choose a reason for hiding this comment

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

Similar as the last comment, but we should show this as repr(r) instead.

@Shershon25
Copy link
Contributor Author

Hey! I have updated the docs again. I corrected the incorrect prefix because of which the build was failing. If any other corrections are there, do let me know.

@adnanhemani
Copy link
Member

Hi! I think this is awesome!! Style and comments-wise, I think I'm ready to approve. But the build is failing (see above). Can you please take a look and ensure that all tests pass? Once that's done, I think I can approve and merge! Thank you for your hard work on this!

@coveralls
Copy link

Coverage Status

Coverage: 92.053% (+0.07%) from 91.986% when pulling d4dbb6f on Shershon25:master into 8d3fb1e on data-8:master.

@adnanhemani
Copy link
Member

Hi, your changes were still failing the build, so I went ahead and made the required changes to get it to work. Thank you for this work!!

@adnanhemani adnanhemani merged commit 614db00 into data-8:master Jan 27, 2023
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

3 participants