[Numpy-discussion] [SPAM]Re: introducing Numpy.net, a pure C# implementation of Numpy

Paul Hobson pmhobson at gmail.com
Mon Mar 18 16:18:42 EDT 2019


Just reply to the discussion, I may have made a boo boo in replying to your
> first post.
>
> I'm curious. Implementing NumPy in another language seems like quite a bit
> of work. Did you have any tools to make it easier? I assume the C api is
> gone, so that the translation is NumPy program specific. I've never used
> C#, was there a reason to avoid C? What about IronPython? IIRC there was
> some work to make NumPy run on IronPython before that project was ended.
> I'm also curious what the application was that made it impossible to stay
> with python, I suppose the customer wanted C#, but I'd like to know why
> plain old Python was not an option.
>
>
Chuck,

To start: I'd like to be clear that I'm not trying to speak for the OP, but
I thought I'd share my experiences.

I'm a civil engineer who adopted Python early in his career and became the
"data guy" in the office pretty early on. Our company's IT department
manages lots of Windows Servers running SQL Server. In my case, running
python apps on our infrastructure just isn't feasible or supported by the
IT department. Typically, we move to outside hosting when we're going that
route. However, sometimes there are a litany of reasons to stay with our in
house infrastructure. In that case, C# makes it very simple to set up and
deploy a web API against a SQL Server database. It's very much a
walled-garden approach to the web, but it can be quite efficient,
especially when you're billing clients by the hour. Additionally, C#'s ORM
treats each table in the database pretty much as dataframe. I've ported
many of my pandas-based workflows over to C# without much issue.

For example in C# I did:

var results = StormEvent
.Where(se => new List<String> { "CI", "JI" }.Contains(se.MonitoringLocations
.sitename))
.Where(se => se.pCoseParameter.pName.ToLower().Contains("flow"))
.Where(se => se.wateryear_int.Equals(2014))
.GroupBy(
se => new {se.MonitoringLocations.sitename, se.paramName},
(key, df) => new
{
ml = key.sitename,
param = key.paramName
total = df.Select(d => d.paramValue).Sum()
}
);

Whereas in pandas I would do:

results = (
StormEvents
.merge(MonitoringLocations, on='monlocID', lsuffix='_ml', rsuffix='')
.merge(Parameters, on='paramID', lsuffix='_param', rsuffix='')
.loc[lambda x: x['sitename'].isin(['CI', 'CI'])]
.loc[lambda x: x['param'].str.lower().str.contains("flow")]
.loc[lambda x: x['wateryear_int'] == 2014]
.groupby(by=['sitename', 'paramID'])
.sum()['paramValue']
)

I'm not trying to sell you on C#, I'll always go python if I can. But
depending on your organization's infrastructure and project constraints, it
can be surprisingly pleasant to work with.

The point of all of this is that in those situations, have a numpy-like
library would be very nice indeed. I've very excited to hear that the OP's
work has been open sourced.

Kudos!
-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190318/694883ba/attachment.html>


More information about the NumPy-Discussion mailing list