Giter Site home page Giter Site logo

Comments (2)

jakobsarthur avatar jakobsarthur commented on July 28, 2024

So the above solution is not quite feasible as we're dealing with rows in the code instead of columns. An easy fix seems to be to take the transpose but that takes too long (13.5 s +/- ~100 ms) on my machine. So ended up with the following solution which is definitely more memory intensive (the product of self.A.sparse.to_dense() takes almost 2000MB instead of ~124MB).
dtypes = self.A.dtypes
self.A = self.A.sparse.to_dense()
self.A.loc[bo_cutoff,:] = self.A.loc[bo_cutoff,:].abs()
self.A = self.A.astype(dtypes)

from ecospold2matrix.

andthewatersays avatar andthewatersays commented on July 28, 2024

Hello,

I have the same problem with the "TypeError: SparseArray does not support item assignment via setitem".
I have tried to add as you suggest this 4 lines (dtypes = self.A.dtypes
self.A = self.A.sparse.to_dense()
self.A.loc[bo_cutoff,:] = self.A.loc[bo_cutoff,:].abs()
self.A = self.A.astype(dtypes))
but now I have a new error :

ValueError Traceback (most recent call last)
in
----> 1 parser.ecospold_to_Leontief(with_absolute_flows=True)

~/opt/anaconda3/lib/python3.7/site-packages/ecospold2matrix/ecospold2matrix.py in ecospold_to_Leontief(self, fileformats, with_absolute_flows, lci_check, rtol, atol, imax, characterisation_file, ardaidmatching_file)
432
433 # Save system to file
--> 434 self.save_system(fileformats)
435
436 # Read/load lci cummulative emissions and perform quality check

~/opt/anaconda3/lib/python3.7/site-packages/ecospold2matrix/ecospold2matrix.py in save_system(self, file_formats)
2202 STR_header = STR_header.reshape((1, -1))
2203
-> 2204 C = scipy.sparse.csr_matrix(self.C.sparse.to_coo())
2205 IMP_header = self.IMP.columns.values
2206 IMP_header = IMP_header.reshape((1, -1))

~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/arrays/sparse.py in to_coo(self)
2225 from scipy.sparse import coo_matrix
2226
-> 2227 dtype = find_common_type(self._parent.dtypes)
2228 if isinstance(dtype, SparseDtype):
2229 dtype = dtype.subtype

~/opt/anaconda3/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in find_common_type(types)
1136
1137 if len(types) == 0:
-> 1138 raise ValueError("no types given")
1139
1140 first = types[0]

ValueError: no types given

Did you manage to solve your error or did you have other errors as I have ?

from ecospold2matrix.

Related Issues (10)

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.