Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Aug 11, 2022
1 parent b4a3096 commit 16c5474
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ type Table
Integer -> self.make_column (self.internal_columns.at selector)
Text ->
candidates = self.internal_columns + self.context.meta_index
internal_column = candidates.find (p -> p.name == selector)
self.make_column internal_column . map_error (_ -> No_Such_Column_Error selector)
internal_column = candidates.find (p -> p.name == selector) . map_error (_ -> No_Such_Column_Error selector)
self.make_column internal_column

## UNSTABLE
Returns the number of columns in the table.
length : Integer
length = self.internal_columns.length
length self = self.internal_columns.length

## Returns a new table with a chosen subset of columns, as specified by the
`columns`, from the input table. Any unmatched input columns will be
Expand Down Expand Up @@ -430,7 +430,7 @@ type Table
- index: The column to use as the index of the table.
set_index : Text | Column | Vector Text -> Table
set_index self index = Panic.recover Any <|
new_index = (Helpers.unify_vector_singleton index).map (self.at >> .as_internal)
new_index = (Helpers.unify_vector_singleton index).map ((self.at _) >> .as_internal)
new_ctx = self.context.set_index new_index
new_cols = self.internal_columns.filter col->
turned_into_index = new_index.exists i-> i.name == col.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ type Table
## UNSTABLE
Returns the number of columns in the table.
length : Integer
length = self.java_table.getColumns.length
length self = self.java_table.getColumns.length

## Returns a new table with a chosen subset of columns, as specified by the
`columns`, from the input table. Any unmatched input columns will be
Expand Down
2 changes: 1 addition & 1 deletion distribution/lib/Standard/Test/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ fail_match_on_unexpected_error error frames_to_skip =
payload = error.catch
loc = Meta.get_source_location 1+frames_to_skip
msg = "An unexpected dataflow error (" + payload.to_text + ") has been matched (at " + loc + ")."
fail msg
fail msg+'\n'+error.get_stack_trace_text


## PRIVATE
Expand Down
28 changes: 14 additions & 14 deletions test/Table_Tests/src/Excel_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -518,24 +518,24 @@ spec =
table = xlsx_sheet.read (File_Format.Excel (Sheet 1))
check_table table

table_2 = xlsx_sheet.read (File_Format.Excel (Sheet 1 (table.length - col_a.length)))
table_2.length . should_equal col_a.length
table_2 = xlsx_sheet.read (File_Format.Excel (Sheet 1 (table.row_count - col_a.length)))
table_2.row_count . should_equal col_a.length
check_table <| table_2

Test.specify "should let you read by sheet name" <|
table = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1"))
check_table table

table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length)))
table_2.length . should_equal col_a.length
table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length)))
table_2.row_count . should_equal col_a.length
check_table <| table_2

Test.specify "should let you read XLS by sheet index" <|
table = xls_sheet.read (File_Format.Excel (Sheet 1))
check_table table

table_2 = xls_sheet.read (File_Format.Excel (Sheet 1 (table.length - col_a.length)))
table_2.length . should_equal col_a.length
table_2 = xls_sheet.read (File_Format.Excel (Sheet 1 (table.row_count - col_a.length)))
table_2.row_count . should_equal col_a.length
check_table <| table_2

Test.specify "should let you read XLS by sheet name" <|
Expand All @@ -546,31 +546,31 @@ spec =
table = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C"))
check_table table

table_2 = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C" (table.length - col_a.length)))
table_2.length . should_equal col_a.length
table_2 = xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A:C" (table.row_count - col_a.length)))
table_2.row_count . should_equal col_a.length
check_table <| table_2

check_table <| xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!10:13"))
check_table <| xlsx_sheet.read (File_Format.Excel (Cell_Range "Sheet1!A10:C13"))

Test.specify "should let you read by range name" <|
table = xlsx_sheet.read (File_Format.Excel (Cell_Range "myData"))
table.length . should_equal col_a.length
table.row_count . should_equal col_a.length
check_table <| table

Test.specify "should let you restrict number of rows read and skip rows" <|
table = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1"))
check_table table

table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length)))
table_2.length . should_equal col_a.length
table_2 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length)))
table_2.row_count . should_equal col_a.length
check_table <| table_2

table_3 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.length - col_a.length) 2))
table_3.length . should_equal 2
table_3 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" (table.row_count - col_a.length) 2))
table_3.row_count . should_equal 2

table_4 = xlsx_sheet.read (File_Format.Excel (Sheet "Sheet1" row_limit=6))
table_4.length . should_equal 6
table_4.row_count . should_equal 6

Test.group "Problems" <|
Test.specify "should handle non-existing file gracefully" <|
Expand Down

0 comments on commit 16c5474

Please sign in to comment.