Git Product home page Git Product logo

Comments (10)

santoshphilip avatar santoshphilip commented on September 4, 2024

code review shows the following functions

class IDF3:
    def initread
    def initnew
    def initreadtxt

These functions use the latest idd packaged with eppy. The is no need to do the call IDF.setiddname (). I wrote it to quickly set up unit testing.

It is apparent that initnew () has the same functionality we are considering for new(). It also has the ease of use, that it avoids the extra step of setting the idd at the start.

It would be good to have a getiddversion() function as a quick step to see what version of idd is installed with eppy

from eppy.

pachi avatar pachi commented on September 4, 2024

IMHO, using IDF('non_existant_filename.idf') should create a blank file instead of raising an Exception. No new API is needed and things should just work.

If there is any concern about this silencing errors in filenames, an additional flag that raises an exception if file doesn't exist (which defaults to False) could be added.

i.e. IDF(filename, raise_missing=False)

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

pachi,
You make a good point.

My thinking is running in this direction:

idf = IDF(filename) # open an existing file

fhandle = open(filename, 'r')
idf = IDF(fhandle) # open a using a file handle

idftxt = """
Version, 8.3; 
! more idf objects
"""
from StringIO import StringIO
idf = IDF(StringIO(idftxt)) # open when you have the idd text

idf = IDF() # create an empty new file, with no filename
idf.saveas(filename)
    # this can to be saved with idf.saveas(filename)
    # there may even be times when you don't want to save it
    # should throw an exception if you try idf.save(), since it does not have a filename

    # the same idf.saveas(fileame), idd.save() rule should apply with  idf = IDF(StringIO(idftxt))

Right now all of the above will work except for idf = IDF()
We should think this through.

from eppy.

jamiebull1 avatar jamiebull1 commented on September 4, 2024

It would also be great if it recognised the version of an existing file and
picked the correct IDD.

On Fri, 18 Sep 2015 04:11 santoshphilip [email protected] wrote:

pachi,
You make a good point.

My thinking is running in this direction:

idf = IDF(filename) # open an existing file

fhandle = open(filename, 'r')
idf = IDF(fhandle) # open a using a file handle

idftxt = """
Version, 8.3;
! more idf objects
"""
from StringIO import StringIO
idf = IDF(StringIO(idftxt)) # open when you have the idd text

idf = IDF() # create an empty new file, with no filename
idf.saveas(filename)
# this can to be saved with idf.saveas(filename)
# there may even be times when you don't want to save it
# should throw an exception if you try idf.save(), since it does not have a filename

# the same idf.saveas(fileame), idd.save() rule should apply with  idf = IDF(StringIO(idftxt))

Right now all of the above will work except for idf = IDF()
We should think this through.


Reply to this email directly or view it on GitHub
#41 (comment).

from eppy.

pachi avatar pachi commented on September 4, 2024

Phillip, I think your idea is nice.

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

Regarding the correct IDD file
Issue #49 points to about picking up the latest IDD file automatically. This could be enhanced to select the right version of the idd file.

I like the API at the moment because everything is explicit. You have to explicitly pick the IDD file.
Having said that, it is a real pain in the neck and I feel the pain every time I use it.

I would be so nice to simply do:

import eppy # not what we do now
idf = eppy.IDF(filename)
zones = idf.idfobjects["ZONE"]

I can actually remember it and not have to open up the tutorial every time I start scripting with eppy :-(

At the same time it opens up system specific dependencies that are harder to maintain.

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

created a branch i41_idfnew for this issue

idf = IDF() # works now
idf.save() # throws an Exception
idf.saveas(filename) # will save the file if you wish to

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

playing with changing the imports. (not sure if it is a good direction to go)
The following works now:

from eppy import IDF
# seems more intuitive than  - from eppy.modeleditor import IDF
iddfile = "/Applications/EnergyPlus-8-3-0/Energy+.idd"
IDF.setiddname(iddfile)
idf = IDF()
idf.save() # throws an exception   
idf.saveas(filename) # will save the file if you wish to 

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

With a couple of quick and dirty updates, the following works:

from eppy import IDF # simpler now
idf = IDF() # latest IDD is automatically found, new IDF created
print idf.idfobjects["ZONE"]
# will print []

Unit tests are a little sparse and unstructured in this part of the code. I am going to spend some time looking at testing here before I merge it into develop

from eppy.

santoshphilip avatar santoshphilip commented on September 4, 2024

Jamie,
responding to your comment

It would also be great if it recognised the version of an existing file and
picked the correct IDD.

Right now the code finds the latest IDD using Darren's code from #49
If you can think of a clean way of finding any particular IDD, I can look at implementing it, since I am mucking around in this part of the code anyways.

from eppy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.