equinor / equinor/TimeSeriesAnalysis

Cannot import TimeSeriesDataSet class in Pythonnet

Open
#173 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
22
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Problem Description---
I'm trying to use the TimeSeriesDataSet class from the TimeSeriesAnalysis library through Pythonnet, but encountering import errors. I've verified in the source code that this class exists in the root namespace (TimeSeriesAnalysis), but I cannot import it in Python.

Error Messages---
When I try to import from the Dynamic sub-namespace:
```python
from TimeSeriesAnalysis.Dynamic import TimeSeriesDataSet
I get:
CopyImportError: cannot import name 'TimeSeriesDataSet' from 'TimeSeriesAnalysis.Dynamic' (unknown location)
When I try to import from the root namespace:
pythonCopyfrom TimeSeriesAnalysis import TimeSeriesDataSet
I get:
CopyImportError: cannot import name 'TimeSeriesDataSet' from 'TimeSeriesAnalysis' (unknown location)

What Works---
I can successfully import other classes from the same library:
pythonCopyfrom TimeSeriesAnalysis.Dynamic import (
UnitModel,
UnitParameters,
ISimulatableModel,
PidModel,
PidParameters,
PlantSimulator,
SignalType,
)
from TimeSeriesAnalysis.Utility import TimeSeriesCreator

Code Analysis---
I've examined the TimeSeriesDataSet.cs source file and confirmed it's in the root TimeSeriesAnalysis namespace:
csharpCopynamespace TimeSeriesAnalysis
{
public class TimeSeriesDataSet
{
// ...
}
}

My Code---
pythonCopyimport sys
import pythonnet
pythonnet.load("coreclr")
import clr

assembly_path = r"C:\Users\kyle4des\Desktop\TimeSeriesAnalysis\bin\Debug\netstandard2.0"
sys.path.append(assembly_path)

clr.AddReference("System")
clr.AddReference("System.Collections")
clr.AddReference("Newtonsoft.Json")
clr.AddReference("TimeSeriesAnalysis")

from TimeSeriesAnalysis import TimeSeriesDataSet # This fails

Questions---
Why can I import other classes but not TimeSeriesDataSet?
Is there a specific way to import this class through Pythonnet?
Could there be an issue with how the class is compiled or exposed in the DLL?
Are there any special attributes or configuration needed for this class to be accessible through Pythonnet?

Environment---
Python 3.9
Pythonnet (latest version)
Using .NET Standard 2.0 DLL

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.