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

Fix missing preferoptions in C# extension Frame.Readcsv from stream #471

Merged
merged 1 commit into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Deedle/FrameExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type Frame =
static member ReadCsv
( stream:Stream, [<Optional>] hasHeaders:Nullable<bool>, [<Optional>] inferTypes:Nullable<bool>, [<Optional>] inferRows:Nullable<int>,
[<Optional>] schema, [<Optional>] separators, [<Optional>] culture, [<Optional>] maxRows:Nullable<int>,
[<Optional>] missingValues) =
[<Optional>] missingValues, [<Optional>] preferOptions:Nullable<bool>) =
FrameUtils.readCsv
(new StreamReader(stream))
(if hasHeaders.HasValue then Some hasHeaders.Value else None)
Expand All @@ -139,6 +139,7 @@ type Frame =
(Some schema) (Some missingValues)
(if separators = null then None else Some separators) (Some culture)
(if maxRows.HasValue then Some maxRows.Value else None)
(if preferOptions.HasValue then Some preferOptions.Value else None)

// Note: The following is also used from F#

Expand Down
23 changes: 20 additions & 3 deletions tests/Deedle.CSharp.Tests/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,31 @@ public static Frame<int, string> LoadMSFT([CallerFilePath] string source = "")
return Frame.ReadCsv(file, inferRows:10);
}

[Test]
public static Frame<int, string> LoadMSFTStream([CallerFilePath] string source = "")
{
var file = Path.Combine(Path.GetDirectoryName(source), "..", "Deedle.Tests", "data", "MSFT.csv");
var sr = new StreamReader(file);
var csv = Frame.ReadCsv(sr.BaseStream);
sr.Close();
return csv;
}

[Test]
public static void CanSubtractNumericalValues()
{
var df = LoadMSFT();
var actual = df.Zip<float, float, float>(df, (n1, n2) => n1 - n2).GetAllValues<float>().Sum();
Assert.AreEqual(0.0, actual);
}
}

[Test]
public static void CanSubtractNumericalValuesStream()
{
var df = LoadMSFTStream();
var actual = df.Zip<float, float, float>(df, (n1, n2) => n1 - n2).GetAllValues<float>().Sum();
Assert.AreEqual(0.0, actual);
}
}

/* ----------------------------------------------------------------------------------
* Creating frames and getting frame data
Expand Down Expand Up @@ -182,5 +199,5 @@ public static void CanGetColumnDynamically()
Assert.AreEqual(11.1, s1[1]);
}
}
}
}
}