Skip to content

Commit

Permalink
adding tutorial on revisioning; removing trailing white space from tu…
Browse files Browse the repository at this point in the history
…torials
  • Loading branch information
jonrkarr committed Apr 29, 2020
1 parent a73c7d7 commit 1b0dc02
Show file tree
Hide file tree
Showing 5 changed files with 1,064 additions and 20 deletions.
8 changes: 4 additions & 4 deletions examples/tutorials/1. Building and visualizing schemas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"First, define attributes to represent the street, city, state, zip code, and country of an address. \n",
"First, define attributes to represent the street, city, state, zip code, and country of an address.\n",
"\n",
"Next, use `obj_tables.Model.Meta` to control how adresses are encoded into and decoded from tables.\n",
"* Use `table_format = obj_tables.TableFormat.multiple_cells` to indicate that addresses should be embedded into and extracted out of tables for companies and people.\n",
Expand Down Expand Up @@ -94,7 +94,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, create a class to represent companies. \n",
"Next, create a class to represent companies.\n",
"* Use `unique=True` to indicate each company must have a unique name.\n",
"* Use `primary=True` to indicate that company names can be used as a foreign key to encode relationships to companies into cells of tables.\n",
"* Use `obj_tables.OneToOneAttribute` to indicate that each company can have an address."
Expand Down Expand Up @@ -175,7 +175,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"*ObjTables* supports a wide range of attributes in addition to those illustrated here. This includes attributes that can represent mathematical expressions, NumPy arrays, Pandas DataFrames, chemical structures, and biological sequences. \n",
"*ObjTables* supports a wide range of attributes in addition to those illustrated here. This includes attributes that can represent mathematical expressions, NumPy arrays, Pandas DataFrames, chemical structures, and biological sequences.\n",
"\n",
"* Strings\n",
" * `obj_tables.StringAttribute`: attribute for strings\n",
Expand Down Expand Up @@ -220,7 +220,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Most attributes support optional arguments which can be used to define constraints on their values. For example, \n",
"Most attributes support optional arguments which can be used to define constraints on their values. For example,\n",
"\n",
"* `obj_tables.StringAttribute`: supports two optional arguments, `min_length` and `max_length` which can be used to define the minimum and maximum valid string lengths.\n",
"* `obj_tables.RegexAttribute`: supports one optional argument, `pattern` which can be used to define a regular expression that each value must match.\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
" attribute_order = ('street', 'city', 'state', 'zip_code', 'country',)\n",
" verbose_name = 'Address'\n",
" verbose_name_plural = 'Addresses'\n",
" \n",
"\n",
"\n",
"class Company(obj_tables.Model):\n",
" name = obj_tables.StringAttribute(unique=True, primary=True, verbose_name='Name')\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
" * Provides drop-down menus for each enumeration and \\*-to-one relationship.\n",
" * Uses Excel validation to help users quickly find and correct errors.\n",
" * Hides all unused rows and columns.\n",
" \n",
"\n",
"* **Share or publish a dataset**: We recommend using Excel workbooks to share and publish datasets because an entire dataset and its schema can be captured by a single file and because Excel workbooks are easy for humans to read.\n",
"\n",
"* **Revision a dataset**: We recommend using collections of CSV or TSV files to revision datasets with version control systems such as Git. Version control systems can easily difference and merge CSV and TSV files.\n",
Expand Down Expand Up @@ -99,7 +99,7 @@
" attribute_order = ('street', 'city', 'state', 'zip_code', 'country',)\n",
" verbose_name = 'Address'\n",
" verbose_name_plural = 'Addresses'\n",
" \n",
"\n",
"\n",
"class Company(obj_tables.Model):\n",
" name = obj_tables.StringAttribute(unique=True, primary=True, verbose_name='Name')\n",
Expand Down Expand Up @@ -132,7 +132,7 @@
" attribute_order = ('name', 'type', 'company', 'email_address', 'phone_number', 'address',)\n",
" verbose_name = 'Person'\n",
" verbose_name_plural = 'People'\n",
" \n",
"\n",
"\n",
"# Add the classes to a module\n",
"schema = type('address_book', (types.ModuleType, ), {\n",
Expand Down Expand Up @@ -309,13 +309,13 @@
"\n",
"if not os.path.isdir(os.path.join(dir, 'Address book.csv')):\n",
" os.makedirs(os.path.join(dir, 'Address book.csv'))\n",
" \n",
"\n",
"if not os.path.isdir(os.path.join(dir, 'Address book.tsv')):\n",
" os.makedirs(os.path.join(dir, 'Address book.tsv'))\n",
" \n",
"\n",
"# export address book\n",
"for file in [xlsx_file, csv_file, tsv_file, multi_csv_file, multi_tsv_file, json_file, yml_file]:\n",
" obj_tables.io.Writer().run(file, address_book, models=schema.models, \n",
" obj_tables.io.Writer().run(file, address_book, models=schema.models,\n",
" write_toc=True,\n",
" write_schema=True)\n",
"\n",
Expand Down Expand Up @@ -361,7 +361,7 @@
" models=schema.models)\n",
"\n",
" # Check that the imported address book is equal to the original\n",
" for cls in address_book_by_class.keys(): \n",
" for cls in address_book_by_class.keys():\n",
" objs = sorted(address_book_by_class[cls], key=lambda obj: obj.name)\n",
" copies = sorted(address_book_by_class_copy[cls], key=lambda obj: obj.name)\n",
" for obj, copy in zip(objs, copies):\n",
Expand Down Expand Up @@ -396,7 +396,7 @@
" schema_name='Address book',\n",
" models=schema.models)\n",
"\n",
"for cls in address_book_by_class.keys(): \n",
"for cls in address_book_by_class.keys():\n",
" for obj, copy in zip(address_book_by_class[cls], address_book_by_class_copy[cls]):\n",
" assert obj.is_equal(copy)"
]
Expand All @@ -416,8 +416,8 @@
" * Orders the worksheets and columns.\n",
" * Removes extraneous worksheets and columns that are not controlled by the schema.\n",
" * Additional changes to Excel files:\n",
" * Optionally includes additional worksheets that contain a table of contents and the schema for the dataset. \n",
" * Highlights, freezes, and protects the column headings of each table. \n",
" * Optionally includes additional worksheets that contain a table of contents and the schema for the dataset.\n",
" * Highlights, freezes, and protects the column headings of each table.\n",
" * Uses comments to provide inline help for each column.\n",
" * Provides drop-down menus for each enumeration and \\*-to-one relationship.\n",
" * Uses Excel validation to help users quickly find and correct errors.\n",
Expand All @@ -438,7 +438,7 @@
" schema_name='Address book',\n",
" models=schema.models)\n",
"\n",
"for cls in address_book_by_class.keys(): \n",
"for cls in address_book_by_class.keys():\n",
" for obj, copy in zip(address_book_by_class[cls], address_book_by_class_copy[cls]):\n",
" assert obj.is_equal(copy)"
]
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/4. Merging and cutting datasets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@
" children = {\n",
" 'company_address_book': ('address_book', 'company', 'address',),\n",
" }\n",
" \n",
"\n",
"\n",
"class AddressBook(obj_tables.Model):\n",
" id = obj_tables.StringAttribute(unique=True, primary=True, verbose_name='Id')\n",
" companies = obj_tables.OneToManyAttribute(Company, related_name='address_book')\n",
" people = obj_tables.OneToManyAttribute(Person, related_name='address_book')\n",
" \n",
"\n",
" class Meta(obj_tables.Model.Meta):\n",
" table_format = obj_tables.TableFormat.column\n",
" attribute_order = ('id', 'companies', 'people')\n",
Expand Down

0 comments on commit 1b0dc02

Please sign in to comment.